2021-03-04 11:30:38 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "params.h"
|
2023-10-26 12:12:32 +00:00
|
|
|
#include "pools.h"
|
2021-03-18 14:21:25 +00:00
|
|
|
#include "conntrack.h"
|
2021-03-04 11:30:38 +00:00
|
|
|
#include "desync.h"
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/types.h>
|
2022-05-15 12:54:35 +00:00
|
|
|
#include <net/if.h>
|
2021-03-04 11:30:38 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#define Q_RCVBUF (128*1024) // in bytes
|
|
|
|
#define Q_SNDBUF (64*1024) // in bytes
|
|
|
|
#define RAW_SNDBUF (64*1024) // in bytes
|
|
|
|
|
|
|
|
#define Q_MAXLEN 1024 // in packets
|
|
|
|
|
2021-12-26 14:11:21 +00:00
|
|
|
#define BADSEQ_INCREMENT_DEFAULT -10000
|
2021-12-28 09:50:04 +00:00
|
|
|
#define BADSEQ_ACK_INCREMENT_DEFAULT -66000
|
2021-12-26 14:11:21 +00:00
|
|
|
|
2022-01-03 09:38:18 +00:00
|
|
|
#define IPFRAG_UDP_DEFAULT 8
|
|
|
|
#define IPFRAG_TCP_DEFAULT 32
|
|
|
|
|
2022-04-12 12:52:06 +00:00
|
|
|
#define UDPLEN_INCREMENT_DEFAULT 2
|
|
|
|
|
2023-10-26 12:12:32 +00:00
|
|
|
#define HOSTLIST_AUTO_FAIL_THRESHOLD_DEFAULT 2
|
|
|
|
#define HOSTLIST_AUTO_FAIL_TIME_DEFAULT 60
|
|
|
|
#define HOSTLIST_AUTO_RETRANS_THRESHOLD_DEFAULT 3
|
|
|
|
|
|
|
|
|
2021-03-04 11:30:38 +00:00
|
|
|
struct params_s
|
|
|
|
{
|
|
|
|
bool debug;
|
2021-03-12 11:33:48 +00:00
|
|
|
uint16_t wsize,wssize;
|
|
|
|
uint8_t wscale,wsscale;
|
2021-12-27 13:51:30 +00:00
|
|
|
char wssize_cutoff_mode; // n - packets, d - data packets, s - relative sequence
|
2021-03-18 14:21:25 +00:00
|
|
|
unsigned int wssize_cutoff;
|
2021-03-04 11:30:38 +00:00
|
|
|
#ifdef __linux__
|
|
|
|
int qnum;
|
|
|
|
#elif defined(BSD)
|
|
|
|
uint16_t port; // divert port
|
|
|
|
#endif
|
2022-05-15 12:54:35 +00:00
|
|
|
char bind_fix4,bind_fix6;
|
2021-03-04 11:30:38 +00:00
|
|
|
bool hostcase, hostnospace, domcase;
|
|
|
|
char hostspell[4];
|
2021-04-07 09:13:46 +00:00
|
|
|
enum dpi_desync_mode desync_mode0,desync_mode,desync_mode2;
|
2021-03-04 11:30:38 +00:00
|
|
|
bool desync_retrans,desync_skip_nosni,desync_any_proto;
|
2022-01-03 09:38:18 +00:00
|
|
|
unsigned int desync_repeats,desync_split_pos,desync_ipfrag_pos_tcp,desync_ipfrag_pos_udp;
|
2021-12-27 13:51:30 +00:00
|
|
|
char desync_cutoff_mode; // n - packets, d - data packets, s - relative sequence
|
2021-03-22 09:02:55 +00:00
|
|
|
unsigned int desync_cutoff;
|
2021-12-10 19:08:52 +00:00
|
|
|
uint8_t desync_ttl, desync_ttl6;
|
2022-01-01 17:22:04 +00:00
|
|
|
uint8_t desync_fooling_mode;
|
2021-03-04 11:30:38 +00:00
|
|
|
uint32_t desync_fwmark; // unused in BSD
|
2021-12-26 14:11:21 +00:00
|
|
|
uint32_t desync_badseq_increment, desync_badseq_ack_increment;
|
2023-09-07 16:03:37 +00:00
|
|
|
uint8_t fake_http[1432],fake_tls[1432],fake_quic[1472],fake_wg[1472],fake_dht[1472],fake_unknown[1432],fake_unknown_udp[1472], udplen_pattern[1472];
|
|
|
|
size_t fake_http_size,fake_tls_size,fake_quic_size,fake_wg_size,fake_dht_size,fake_unknown_size,fake_unknown_udp_size;
|
2022-07-27 09:00:36 +00:00
|
|
|
int udplen_increment;
|
2021-03-04 11:30:38 +00:00
|
|
|
bool droproot;
|
|
|
|
uid_t uid;
|
|
|
|
gid_t gid;
|
2021-03-18 14:21:25 +00:00
|
|
|
|
2022-07-26 16:15:28 +00:00
|
|
|
strpool *hostlist, *hostlist_exclude;
|
|
|
|
struct str_list_head hostlist_files, hostlist_exclude_files;
|
2023-11-09 09:08:09 +00:00
|
|
|
char hostlist_auto_filename[PATH_MAX], hostlist_auto_debuglog[PATH_MAX];
|
2023-10-26 12:12:32 +00:00
|
|
|
int hostlist_auto_fail_threshold, hostlist_auto_fail_time, hostlist_auto_retrans_threshold;
|
|
|
|
hostfail_pool *hostlist_auto_fail_counters;
|
2022-07-26 16:15:28 +00:00
|
|
|
|
2022-01-01 17:22:04 +00:00
|
|
|
unsigned int ctrack_t_syn, ctrack_t_est, ctrack_t_fin, ctrack_t_udp;
|
2021-03-18 14:21:25 +00:00
|
|
|
t_conntrack conntrack;
|
2021-03-04 11:30:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct params_s params;
|
|
|
|
|
|
|
|
#define DLOG(format, ...) {if (params.debug) printf(format, ##__VA_ARGS__);}
|
2023-11-09 09:08:09 +00:00
|
|
|
|
|
|
|
#define LOG_APPEND(filename, format, ...) \
|
|
|
|
{ \
|
|
|
|
FILE *F = fopen(filename,"at"); \
|
|
|
|
if (F) \
|
|
|
|
{ \
|
|
|
|
fprint_localtime(F); \
|
|
|
|
fprintf(F, " : " format "\n", ##__VA_ARGS__); \
|
|
|
|
fclose(F); \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
#define HOSTLIST_DEBUGLOG_APPEND(format, ...) if (*params.hostlist_auto_debuglog) LOG_APPEND(params.hostlist_auto_debuglog, format, ##__VA_ARGS__)
|