diff --git a/README.md b/README.md index b5a55ed..f8610a5 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ Available flags: - `--frag={tcp,ip,none}` Specifies the fragmentation strategy for the packet. tcp is used by default. Ip fragmentation may be blocked by TSPU. None specifies no fragmentation. Probably this won't work, but may be will work for some fake sni strategies. - `--frag-sni-reverse={0|1}` Specifies youtubeUnblock to send Client Hello fragments in the reverse order. Defaults to 1. - `--frag-sni-faked={0|1}` Specifies youtubeUnblock to send fake packets near Client Hello (fills payload with zeroes). Defaults to 0. +- `--fk-winsize=` Specifies window size for the fragmented TCP packet. Applicable if you want for response to be fragmented. May slowdown connection initialization. - `--seg2delay=` - This flag forces youtubeUnblock to wait little bit before send the 2nd part of the split packet. - `--silent` - Disables verbose mode. - `--no-gso` Disables support for Google Chrome fat packets which uses GSO. This feature is well tested now, so this flag probably won't fix anything. diff --git a/args.c b/args.c index 5f06fd4..fd1b49e 100644 --- a/args.c +++ b/args.c @@ -52,6 +52,7 @@ struct config_t config = { #define OPT_FRAG 4 #define OPT_FRAG_SNI_REVERSE 12 #define OPT_FRAG_SNI_FAKED 13 +#define OPT_FK_WINSIZE 14 #define OPT_SEG2DELAY 5 #define OPT_THREADS 6 #define OPT_SILENT 7 @@ -71,6 +72,7 @@ static struct option long_opt[] = { {"frag", 1, 0, OPT_FRAG}, {"frag-sni-reverse", 1, 0, OPT_FRAG_SNI_REVERSE}, {"frag-sni-faked", 1, 0, OPT_FRAG_SNI_FAKED}, + {"fk-winsize", 1, 0, OPT_FK_WINSIZE}, {"seg2delay", 1, 0, OPT_SEG2DELAY}, {"threads", 1, 0, OPT_THREADS}, {"silent", 0, 0, OPT_SILENT}, @@ -117,6 +119,7 @@ void print_usage(const char *argv0) { printf("\t--frag={tcp,ip,none}\n"); printf("\t--frag-sni-reverse={0|1}\n"); printf("\t--frag-sni-faked={0|1}\n"); + printf("\t--fk-winsize=\n"); printf("\t--seg2delay=\n"); printf("\t--threads=\n"); printf("\t--silent\n"); @@ -232,6 +235,15 @@ int parse_args(int argc, char *argv[]) { config.fake_sni_seq_len = num; break; + case OPT_FK_WINSIZE: + num = parse_numeric_option(optarg); + if (errno != 0 || num < 0) { + printf("Invalid option %s\n", long_opt[optIdx].name); + goto error; + } + + config.fk_winsize = num; + break; case OPT_SEG2DELAY: num = parse_numeric_option(optarg); if (errno != 0 || num < 0) { @@ -321,6 +333,10 @@ void print_welcome() { break; } + if (config.fk_winsize) { + printf("Response TCP window will be set to %d with the appropriate scale\n", config.fk_winsize); + } + if (config.use_gso) { printf("GSO is enabled\n"); diff --git a/config.h b/config.h index be0d4ca..93db448 100644 --- a/config.h +++ b/config.h @@ -33,6 +33,7 @@ struct config_t { unsigned int all_domains; const char *fake_sni_pkt; unsigned int fake_sni_pkt_sz; + unsigned int fk_winsize; }; extern struct config_t config; diff --git a/mangle.c b/mangle.c index dd903d5..321a27c 100644 --- a/mangle.c +++ b/mangle.c @@ -63,6 +63,11 @@ int process_packet(const uint8_t *raw_payload, uint32_t raw_payload_len) { int ret = tcp4_payload_split(payload, payload_len, &iph, &iph_len, &tcph, &tcph_len, &data, &dlen); + + if (config.fk_winsize) { + tcph->window = htons(config.fk_winsize); + } + ip4_set_checksum(iph); tcp4_set_checksum(tcph, iph); @@ -590,9 +595,6 @@ int tcp4_frag(const __u8 *pkt, __u32 buflen, __u32 payload_offset, s2_tcph->seq = htonl(ntohl(s2_tcph->seq) + payload_offset); - s1_tcph->window = htons(1); - s2_tcph->window = htons(1); - if (config.verbose) printf("Packet split in portion %u %u\n", s1_plen, s2_plen); diff --git a/youtubeUnblock.c b/youtubeUnblock.c index 17eb2e1..1b72351 100644 --- a/youtubeUnblock.c +++ b/youtubeUnblock.c @@ -10,7 +10,9 @@ #include #include -#include +/* Warning is ok, use this for Entware */ +#include + #include #include #include