2024-08-10 23:10:18 +00:00
|
|
|
#ifndef YTB_CONFIG_H
|
|
|
|
#define YTB_CONFIG_H
|
|
|
|
|
2024-09-01 13:07:47 +00:00
|
|
|
#ifndef KERNEL_SPACE
|
|
|
|
#define USER_SPACE
|
|
|
|
#endif
|
|
|
|
|
2024-10-13 21:11:58 +00:00
|
|
|
#include "raw_replacements.h"
|
2024-12-06 10:45:50 +00:00
|
|
|
#include "types.h"
|
2024-10-13 21:11:58 +00:00
|
|
|
|
2024-08-10 23:10:18 +00:00
|
|
|
typedef int (*raw_send_t)(const unsigned char *data, unsigned int data_len);
|
|
|
|
/**
|
|
|
|
* Sends the packet after delay_ms. The function should schedule send and return immediately
|
|
|
|
* (for example, open daemon thread)
|
|
|
|
*/
|
2024-10-12 09:19:33 +00:00
|
|
|
typedef int (*delayed_send_t)(const unsigned char *data, unsigned int data_len, unsigned int delay_ms);
|
2024-08-10 23:10:18 +00:00
|
|
|
|
|
|
|
struct instance_config_t {
|
|
|
|
raw_send_t send_raw_packet;
|
|
|
|
delayed_send_t send_delayed_packet;
|
|
|
|
};
|
|
|
|
extern struct instance_config_t instance_config;
|
2024-08-07 10:32:01 +00:00
|
|
|
|
2024-12-06 10:45:50 +00:00
|
|
|
struct udp_dport_range {
|
|
|
|
uint16_t start;
|
|
|
|
uint16_t end;
|
|
|
|
};
|
|
|
|
|
2024-10-13 20:31:26 +00:00
|
|
|
struct section_config_t {
|
|
|
|
const char *domains_str;
|
|
|
|
unsigned int domains_strlen;
|
|
|
|
|
2024-08-07 10:32:01 +00:00
|
|
|
int fragmentation_strategy;
|
2024-08-10 23:10:18 +00:00
|
|
|
int frag_sni_reverse;
|
|
|
|
int frag_sni_faked;
|
|
|
|
int faking_strategy;
|
2024-08-17 09:51:53 +00:00
|
|
|
int frag_middle_sni;
|
|
|
|
int frag_sni_pos;
|
2024-08-10 23:10:18 +00:00
|
|
|
unsigned char faking_ttl;
|
|
|
|
int fake_sni;
|
|
|
|
unsigned int fake_sni_seq_len;
|
2024-09-26 15:11:05 +00:00
|
|
|
|
|
|
|
#define FAKE_PAYLOAD_RANDOM 0
|
|
|
|
#define FAKE_PAYLOAD_CUSTOM 1
|
|
|
|
// In default mode all other options will be skipped.
|
|
|
|
#define FAKE_PAYLOAD_DEFAULT 2
|
|
|
|
int fake_sni_type;
|
|
|
|
|
2024-08-10 23:10:18 +00:00
|
|
|
/* In milliseconds */
|
2024-08-07 10:32:01 +00:00
|
|
|
unsigned int seg2_delay;
|
2024-10-13 20:31:26 +00:00
|
|
|
int synfake;
|
|
|
|
unsigned int synfake_len;
|
|
|
|
|
2024-09-03 18:22:17 +00:00
|
|
|
const char *exclude_domains_str;
|
|
|
|
unsigned int exclude_domains_strlen;
|
2024-08-08 12:29:04 +00:00
|
|
|
unsigned int all_domains;
|
2024-09-26 15:11:05 +00:00
|
|
|
|
2024-08-11 12:34:58 +00:00
|
|
|
const char *fake_sni_pkt;
|
|
|
|
unsigned int fake_sni_pkt_sz;
|
2024-09-26 15:11:05 +00:00
|
|
|
|
|
|
|
const char *fake_custom_pkt;
|
|
|
|
unsigned int fake_custom_pkt_sz;
|
|
|
|
|
2024-08-11 21:45:30 +00:00
|
|
|
unsigned int fk_winsize;
|
2024-09-26 15:11:05 +00:00
|
|
|
int fakeseq_offset;
|
2024-10-13 20:31:26 +00:00
|
|
|
|
|
|
|
#define SNI_DETECTION_PARSE 0
|
|
|
|
#define SNI_DETECTION_BRUTE 1
|
|
|
|
int sni_detection;
|
|
|
|
|
2024-12-06 10:45:50 +00:00
|
|
|
int udp_mode;
|
|
|
|
unsigned int udp_fake_seq_len;
|
|
|
|
unsigned int udp_fake_len;
|
|
|
|
int udp_faking_strategy;
|
|
|
|
|
|
|
|
struct udp_dport_range *udp_dport_range;
|
|
|
|
int udp_dport_range_len;
|
|
|
|
int udp_filter_quic;
|
2024-10-13 20:31:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define MAX_CONFIGLIST_LEN 64
|
|
|
|
|
|
|
|
struct config_t {
|
|
|
|
unsigned int queue_start_num;
|
|
|
|
int threads;
|
|
|
|
int use_gso;
|
|
|
|
int use_ipv6;
|
2024-08-29 06:09:57 +00:00
|
|
|
unsigned int mark;
|
2024-10-26 13:18:13 +00:00
|
|
|
int daemonize;
|
|
|
|
// Same as daemon() noclose
|
|
|
|
int noclose;
|
2024-11-26 16:58:55 +00:00
|
|
|
int syslog;
|
2024-10-13 20:31:26 +00:00
|
|
|
|
|
|
|
#define VERBOSE_INFO 0
|
|
|
|
#define VERBOSE_DEBUG 1
|
|
|
|
#define VERBOSE_TRACE 2
|
|
|
|
int verbose;
|
|
|
|
|
|
|
|
struct section_config_t default_config;
|
|
|
|
struct section_config_t custom_configs[MAX_CONFIGLIST_LEN];
|
|
|
|
int custom_configs_len;
|
2024-08-07 10:32:01 +00:00
|
|
|
};
|
2024-08-10 23:10:18 +00:00
|
|
|
|
2024-08-07 10:32:01 +00:00
|
|
|
extern struct config_t config;
|
|
|
|
|
2024-10-13 20:31:26 +00:00
|
|
|
#define ITER_CONFIG_SECTIONS(section) \
|
|
|
|
for (struct section_config_t *section = &config.default_config + config.custom_configs_len; section >= &config.default_config; section--)
|
|
|
|
|
|
|
|
#define CONFIG_SECTION_NUMBER(section) (int)((section) - &config.default_config)
|
|
|
|
|
2024-08-03 23:20:09 +00:00
|
|
|
#define MAX_THREADS 16
|
|
|
|
|
|
|
|
#ifndef THREADS_NUM
|
|
|
|
#define THREADS_NUM 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if THREADS_NUM > MAX_THREADS
|
|
|
|
#error "Too much threads"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef NOUSE_GSO
|
|
|
|
#define USE_GSO
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define FRAG_STRAT_TCP 0
|
|
|
|
#define FRAG_STRAT_IP 1
|
|
|
|
#define FRAG_STRAT_NONE 2
|
|
|
|
|
2024-08-05 20:37:45 +00:00
|
|
|
#ifndef FRAGMENTATION_STRATEGY
|
2024-08-03 23:20:09 +00:00
|
|
|
#define FRAGMENTATION_STRATEGY FRAG_STRAT_TCP
|
2024-08-05 20:37:45 +00:00
|
|
|
#endif
|
2024-08-03 23:20:09 +00:00
|
|
|
|
2024-08-29 06:09:57 +00:00
|
|
|
#define DEFAULT_RAWSOCKET_MARK (1 << 15)
|
2024-08-03 23:20:09 +00:00
|
|
|
|
|
|
|
#ifdef USE_SEG2_DELAY
|
|
|
|
#define SEG2_DELAY 100
|
|
|
|
#endif
|
|
|
|
|
2024-08-10 23:10:18 +00:00
|
|
|
#define FAKE_TTL 8
|
2024-08-07 00:31:10 +00:00
|
|
|
|
2024-08-10 23:10:18 +00:00
|
|
|
// Will invalidate fake packets by out-of-ack_seq out-of-seq request
|
2024-09-26 15:11:05 +00:00
|
|
|
#define FAKE_STRAT_RAND_SEQ (1 << 0)
|
2024-08-10 23:10:18 +00:00
|
|
|
// Will assume that GGC server is located further than FAKE_TTL
|
|
|
|
// Thus, Fake packet will be eliminated automatically.
|
2024-09-26 15:11:05 +00:00
|
|
|
#define FAKE_STRAT_TTL (1 << 1)
|
|
|
|
#define FAKE_STRAT_PAST_SEQ (1 << 2)
|
|
|
|
#define FAKE_STRAT_TCP_CHECK (1 << 3)
|
|
|
|
#define FAKE_STRAT_TCP_MD5SUM (1 << 4)
|
2024-12-04 20:48:18 +00:00
|
|
|
#define FAKE_STRAT_UDP_CHECK (1 << 5)
|
2024-08-07 00:31:10 +00:00
|
|
|
|
2024-12-04 20:48:18 +00:00
|
|
|
#define FAKE_STRAT_COUNT 6
|
2024-09-26 15:11:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This macros iterates through all faking strategies and executes code under it.
|
|
|
|
* destination strategy will be available under name of `strategy` variable.
|
|
|
|
*/
|
|
|
|
#define ITER_FAKE_STRAT(fake_bitmask, strategy) \
|
|
|
|
for (int strategy = 1; strategy <= (1 << FAKE_STRAT_COUNT); strategy <<= 1) \
|
|
|
|
if ((fake_bitmask) & strategy)
|
2024-08-05 20:13:35 +00:00
|
|
|
|
2024-08-10 23:10:18 +00:00
|
|
|
#ifndef FAKING_STRATEGY
|
2024-08-21 08:53:10 +00:00
|
|
|
#define FAKING_STRATEGY FAKE_STRAT_PAST_SEQ
|
2024-08-05 20:37:45 +00:00
|
|
|
#endif
|
2024-08-05 20:13:35 +00:00
|
|
|
|
2024-09-26 15:11:05 +00:00
|
|
|
#define MAX_FAKE_SIZE 1300
|
|
|
|
|
2024-08-04 12:55:07 +00:00
|
|
|
#if !defined(SILENT) && !defined(KERNEL_SPACE)
|
2024-08-03 23:20:09 +00:00
|
|
|
#define DEBUG
|
|
|
|
#endif
|
2024-08-04 12:55:07 +00:00
|
|
|
|
2024-08-06 21:22:52 +00:00
|
|
|
// The Maximum Transmission Unit size for rawsocket
|
|
|
|
// Larger packets will be fragmented. Applicable for Chrome's kyber.
|
2024-10-25 22:12:52 +00:00
|
|
|
#define AVAILABLE_MTU 1400
|
2024-08-08 12:29:04 +00:00
|
|
|
|
2024-08-10 18:38:25 +00:00
|
|
|
#define DEFAULT_QUEUE_NUM 537
|
|
|
|
|
2024-08-10 23:10:18 +00:00
|
|
|
#define MAX_PACKET_SIZE 8192
|
|
|
|
|
2024-09-07 06:13:50 +00:00
|
|
|
#define DEFAULT_SNISTR "googlevideo.com,ggpht.com,ytimg.com,youtube.com,play.google.com,youtu.be,googleapis.com,googleusercontent.com,gstatic.com,l.google.com"
|
|
|
|
|
|
|
|
static const char defaul_snistr[] = DEFAULT_SNISTR;
|
2024-08-10 23:10:18 +00:00
|
|
|
|
2024-12-06 10:45:50 +00:00
|
|
|
enum {
|
|
|
|
UDP_MODE_DROP,
|
|
|
|
UDP_MODE_FAKE,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
UDP_FILTER_QUIC_DISABLED,
|
|
|
|
UDP_FILTER_QUIC_ALL,
|
|
|
|
};
|
|
|
|
|
|
|
|
#define default_section_config { \
|
|
|
|
.frag_sni_reverse = 1, \
|
|
|
|
.frag_sni_faked = 0, \
|
|
|
|
.fragmentation_strategy = FRAGMENTATION_STRATEGY, \
|
|
|
|
.faking_strategy = FAKING_STRATEGY, \
|
|
|
|
.faking_ttl = FAKE_TTL, \
|
|
|
|
.fake_sni = 1, \
|
|
|
|
.fake_sni_seq_len = 1, \
|
|
|
|
.fake_sni_type = FAKE_PAYLOAD_DEFAULT, \
|
|
|
|
.frag_middle_sni = 1, \
|
|
|
|
.frag_sni_pos = 1, \
|
|
|
|
.fakeseq_offset = 10000, \
|
|
|
|
.synfake = 0, \
|
|
|
|
.synfake_len = 0, \
|
|
|
|
\
|
|
|
|
.seg2_delay = 0, \
|
|
|
|
\
|
|
|
|
.domains_str = defaul_snistr, \
|
|
|
|
.domains_strlen = sizeof(defaul_snistr), \
|
|
|
|
\
|
|
|
|
.exclude_domains_str = "", \
|
|
|
|
.exclude_domains_strlen = 0, \
|
|
|
|
\
|
|
|
|
.fake_sni_pkt = fake_sni_old, \
|
|
|
|
.fake_sni_pkt_sz = sizeof(fake_sni_old) - 1, \
|
|
|
|
.fake_custom_pkt = custom_fake_buf, \
|
|
|
|
.fake_custom_pkt_sz = 0, \
|
|
|
|
.sni_detection = SNI_DETECTION_PARSE, \
|
|
|
|
\
|
|
|
|
.udp_mode = UDP_MODE_FAKE, \
|
|
|
|
.udp_fake_seq_len = 6, \
|
|
|
|
.udp_fake_len = 64, \
|
|
|
|
.udp_faking_strategy = FAKE_STRAT_UDP_CHECK, \
|
|
|
|
.udp_dport_range = NULL, \
|
|
|
|
.udp_dport_range_len = 0, \
|
|
|
|
.udp_filter_quic = UDP_FILTER_QUIC_DISABLED, \
|
|
|
|
}
|
|
|
|
|
2024-08-10 23:10:18 +00:00
|
|
|
#endif /* YTB_CONFIG_H */
|