mirror of
https://github.com/Waujito/youtubeUnblock.git
synced 2024-12-22 06:15:31 +00:00
Add option to change TCP winsize
This commit is contained in:
parent
b2cff9699b
commit
e649ef5567
@ -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=<winsize>` Specifies window size for the fragmented TCP packet. Applicable if you want for response to be fragmented. May slowdown connection initialization.
|
||||
- `--seg2delay=<delay>` - 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.
|
||||
|
16
args.c
16
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=<winsize>\n");
|
||||
printf("\t--seg2delay=<delay>\n");
|
||||
printf("\t--threads=<threads number>\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");
|
||||
|
1
config.h
1
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;
|
||||
|
8
mangle.c
8
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);
|
||||
|
||||
|
@ -10,7 +10,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <linux/netfilter/nfnetlink_queue.h>
|
||||
/* Warning is ok, use this for Entware */
|
||||
#include <libnetfilter_queue/linux_nfnetlink_queue.h>
|
||||
|
||||
#include <libmnl/libmnl.h>
|
||||
#include <libnetfilter_queue/libnetfilter_queue.h>
|
||||
#include <libnetfilter_queue/libnetfilter_queue_ipv4.h>
|
||||
|
Loading…
Reference in New Issue
Block a user