zapret/tpws/tamper.h

37 lines
1.1 KiB
C
Raw Normal View History

2021-03-04 14:30:38 +03:00
#pragma once
#include <stdbool.h>
2023-10-12 12:35:06 +03:00
#include <stdint.h>
2021-03-04 14:30:38 +03:00
#include <sys/types.h>
2024-09-19 21:06:58 +03:00
#include "params.h"
#define SPLIT_FLAG_DISORDER 0x01
#define SPLIT_FLAG_OOB 0x02
2023-10-26 15:12:32 +03:00
typedef enum {UNKNOWN=0, HTTP, TLS} t_l7proto;
2024-10-15 13:28:38 +03:00
#define L7_PROTO_HTTP 1
#define L7_PROTO_TLS 2
#define L7_PROTO_UNKNOWN 0x80000000
2024-10-15 13:29:16 +03:00
const char *l7proto_str(t_l7proto l7);
2024-10-15 13:28:38 +03:00
2023-10-26 15:12:32 +03:00
typedef struct
{
// common state
t_l7proto l7proto;
bool bTamperInCutoff;
2024-09-19 21:06:58 +03:00
bool b_ah_check;
2024-10-14 14:58:31 +03:00
bool b_not_act;
2023-10-26 15:12:32 +03:00
char *hostname;
2024-09-19 21:06:58 +03:00
struct desync_profile *dp; // desync profile cache
2023-10-26 15:12:32 +03:00
} t_ctrack;
2024-09-19 21:06:58 +03:00
void apply_desync_profile(t_ctrack *ctrack, const struct sockaddr *dest);
void tamper_out(t_ctrack *ctrack, const struct sockaddr *dest, uint8_t *segment,size_t segment_buffer_size,size_t *size, size_t *split_pos, uint8_t *split_flags);
void tamper_in(t_ctrack *ctrack, const struct sockaddr *client, uint8_t *segment,size_t segment_buffer_size,size_t *size);
2023-10-26 15:12:32 +03:00
// connection reset by remote leg
void rst_in(t_ctrack *ctrack, const struct sockaddr *client);
2023-10-26 15:12:32 +03:00
// local leg closed connection (timeout waiting response ?)
void hup_out(t_ctrack *ctrack, const struct sockaddr *client);