mirror of
https://github.com/Waujito/youtubeUnblock.git
synced 2026-04-06 04:57:50 +03:00
Add --no-dport-filter flag
This flag allows to reduce amount of network packet to analyze.
This commit is contained in:
10
src/args.c
10
src/args.c
@@ -269,6 +269,7 @@ enum {
|
||||
OPT_PACKET_MARK,
|
||||
OPT_SYNFAKE,
|
||||
OPT_SYNFAKE_LEN,
|
||||
OPT_NO_DPORT_FILTER,
|
||||
OPT_SEG2DELAY,
|
||||
OPT_THREADS,
|
||||
OPT_SILENT,
|
||||
@@ -318,6 +319,7 @@ static struct option long_opt[] = {
|
||||
{"udp-faking-strategy", 1, 0, OPT_UDP_FAKING_STRATEGY},
|
||||
{"udp-dport-filter", 1, 0, OPT_UDP_DPORT_FILTER},
|
||||
{"udp-filter-quic", 1, 0, OPT_UDP_FILTER_QUIC},
|
||||
{"no-dport-filter", 0, 0, OPT_NO_DPORT_FILTER},
|
||||
{"threads", 1, 0, OPT_THREADS},
|
||||
{"silent", 0, 0, OPT_SILENT},
|
||||
{"trace", 0, 0, OPT_TRACE},
|
||||
@@ -381,6 +383,7 @@ void print_usage(const char *argv0) {
|
||||
printf("\t--udp-faking-strategy={checksum|ttl|none}\n");
|
||||
printf("\t--udp-dport-filter=<5,6,200-500>\n");
|
||||
printf("\t--udp-filter-quic={disabled|all|parse}\n");
|
||||
printf("\t--no-dport-filter\n");
|
||||
printf("\t--threads=<threads number>\n");
|
||||
printf("\t--packet-mark=<mark>\n");
|
||||
printf("\t--connbytes-limit=<pkts>\n");
|
||||
@@ -712,6 +715,9 @@ int yparse_args(int argc, char *argv[]) {
|
||||
sect_config->fk_winsize = num;
|
||||
break;
|
||||
|
||||
case OPT_NO_DPORT_FILTER:
|
||||
sect_config->dport_filter = 0;
|
||||
break;
|
||||
case OPT_SEG2DELAY:
|
||||
num = parse_numeric_option(optarg);
|
||||
if (errno != 0 || num < 0) {
|
||||
@@ -1014,6 +1020,10 @@ static size_t print_config_section(const struct section_config_t *section, char
|
||||
}
|
||||
}
|
||||
|
||||
if (section->dport_filter == 0) {
|
||||
print_cnf_buf("--no-dport-filter");
|
||||
}
|
||||
|
||||
return buffer_size - buf_sz;
|
||||
}
|
||||
// Returns written buffer length
|
||||
|
||||
@@ -92,6 +92,8 @@ struct section_config_t {
|
||||
unsigned int fk_winsize;
|
||||
int fakeseq_offset;
|
||||
|
||||
int dport_filter;
|
||||
|
||||
#define SNI_DETECTION_PARSE 0
|
||||
#define SNI_DETECTION_BRUTE 1
|
||||
int sni_detection;
|
||||
@@ -244,6 +246,7 @@ enum {
|
||||
.synfake = 0, \
|
||||
.synfake_len = 0, \
|
||||
\
|
||||
.dport_filter = 1, \
|
||||
.seg2_delay = 0, \
|
||||
\
|
||||
.sni_detection = SNI_DETECTION_PARSE, \
|
||||
|
||||
@@ -214,6 +214,11 @@ int process_tcp_packet(const struct section_config_t *section, const uint8_t *ra
|
||||
goto accept;
|
||||
}
|
||||
|
||||
// As defined by TLS standard.
|
||||
if (section->dport_filter && ntohs(tcph->dest) != 443) {
|
||||
goto accept;
|
||||
}
|
||||
|
||||
if (tcph->syn && section->synfake) {
|
||||
lgtrace_addp("TCP syn alter");
|
||||
|
||||
|
||||
@@ -431,6 +431,10 @@ int detect_udp_filtered(const struct section_config_t *section,
|
||||
}
|
||||
|
||||
if (section->udp_filter_quic != UDP_FILTER_QUIC_DISABLED) {
|
||||
if (section->dport_filter && ntohs(udph->dest) != 443)
|
||||
goto match_port;
|
||||
|
||||
|
||||
const struct quic_lhdr *qch;
|
||||
size_t qch_len;
|
||||
struct quic_cids qci;
|
||||
|
||||
Reference in New Issue
Block a user