mirror of
https://github.com/Waujito/youtubeUnblock.git
synced 2024-12-22 06:15:31 +00:00
Fix split on preset domain list
This commit is contained in:
parent
666b3575fc
commit
9dc40bbdf1
13
args.c
13
args.c
@ -385,18 +385,7 @@ int parse_args(int argc, char *argv[]) {
|
||||
|
||||
config.fake_custom_pkt_sz = custom_len;
|
||||
config.fake_custom_pkt = (char *)custom_buf;
|
||||
|
||||
// if (strcmp(optarg, "default") == 0) {
|
||||
// config.fake_sni_type = FAKE_PAYLOAD_DEFAULT;
|
||||
// } else if (strcmp(optarg, "random") == 0) {
|
||||
// config.fake_sni_type = FAKE_PAYLOAD_RANDOM;
|
||||
// } else if (strcmp(optarg, "custom") == 0) {
|
||||
// config.fake_sni_type = FAKE_PAYLOAD_CUSTOM;
|
||||
// } else {
|
||||
// goto invalid_opt;
|
||||
// }
|
||||
//
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OPT_FK_WINSIZE:
|
||||
num = parse_numeric_option(optarg);
|
||||
|
10
mangle.c
10
mangle.c
@ -139,7 +139,11 @@ int process_tcp_packet(const uint8_t *raw_payload, uint32_t raw_payload_len) {
|
||||
if (tcph->syn) goto accept;
|
||||
|
||||
struct tls_verdict vrd = analyze_tls_data(data, dlen);
|
||||
lgtrace_addp("Analyzed, %d", vrd.target_sni);
|
||||
lgtrace_addp("Analyzed");
|
||||
|
||||
if (vrd.sni_len != 0) {
|
||||
lgtrace_addp("SNI detected: %.*s", vrd.sni_len, data + vrd.sni_offset);
|
||||
}
|
||||
|
||||
if (vrd.target_sni) {
|
||||
lgdebugmsg("Target SNI detected: %.*s", vrd.sni_len, data + vrd.sni_offset);
|
||||
@ -191,7 +195,7 @@ int process_tcp_packet(const uint8_t *raw_payload, uint32_t raw_payload_len) {
|
||||
switch (config.fragmentation_strategy) {
|
||||
case FRAG_STRAT_TCP: {
|
||||
ipd_offset = vrd.sni_target_offset;
|
||||
mid_offset = ipd_offset + vrd.sni_len / 2;
|
||||
mid_offset = ipd_offset + vrd.sni_target_len / 2;
|
||||
|
||||
uint32_t poses[2];
|
||||
int cnt = 0;
|
||||
@ -222,7 +226,7 @@ int process_tcp_packet(const uint8_t *raw_payload, uint32_t raw_payload_len) {
|
||||
case FRAG_STRAT_IP:
|
||||
if (ipxv == IP4VERSION) {
|
||||
ipd_offset = ((char *)data - (char *)tcph) + vrd.sni_target_offset;
|
||||
mid_offset = ipd_offset + vrd.sni_len / 2;
|
||||
mid_offset = ipd_offset + vrd.sni_target_len / 2;
|
||||
mid_offset += 8 - mid_offset % 8;
|
||||
|
||||
uint32_t poses[2];
|
||||
|
6
tls.c
6
tls.c
@ -124,6 +124,7 @@ struct tls_verdict analyze_tls_data(
|
||||
vrd.sni_offset = (uint8_t *)sni_name - data;
|
||||
vrd.sni_target_offset = vrd.sni_offset;
|
||||
vrd.sni_len = sni_len;
|
||||
vrd.sni_target_len = vrd.sni_len;
|
||||
|
||||
if (config.all_domains) {
|
||||
vrd.target_sni = 1;
|
||||
@ -149,6 +150,7 @@ struct tls_verdict analyze_tls_data(
|
||||
domain_len)) {
|
||||
vrd.target_sni = 1;
|
||||
vrd.sni_target_offset = (const uint8_t *)sni_startp - data;
|
||||
vrd.sni_target_len = domain_len;
|
||||
goto check_domain;
|
||||
}
|
||||
|
||||
@ -249,6 +251,7 @@ brute:
|
||||
vrd.sni_len = domain_len;
|
||||
vrd.sni_offset = (k - domain_len - 1);
|
||||
vrd.sni_target_offset = vrd.sni_offset;
|
||||
vrd.sni_target_len = vrd.sni_len;
|
||||
NETBUF_FREE(buf);
|
||||
NETBUF_FREE(nzbuf);
|
||||
goto out;
|
||||
@ -277,7 +280,6 @@ int gen_fake_sni(struct fake_type type,
|
||||
|
||||
get_random_bytes(&data_len, sizeof(data_len));
|
||||
data_len = data_len % 1200;
|
||||
// data_len = get_random_u32() % 1200;
|
||||
#else
|
||||
data_len = random() % 1200;
|
||||
#endif
|
||||
@ -326,7 +328,7 @@ int gen_fake_sni(struct fake_type type,
|
||||
break;
|
||||
default: // FAKE_PAYLOAD_RANDOM
|
||||
#ifdef KERNEL_SPACE
|
||||
get_random_bytes(bfdptr, data_len);
|
||||
get_random_bytes(bfdptr, data_len);
|
||||
#else
|
||||
getrandom(bfdptr, data_len, 0);
|
||||
#endif
|
||||
|
1
tls.h
1
tls.h
@ -11,6 +11,7 @@ struct tls_verdict {
|
||||
int target_sni; /* google video hello packet */
|
||||
int sni_offset; /* offset from start of tcp _payload_ */
|
||||
int sni_target_offset; /* offset of target domain instead of entire sni */
|
||||
int sni_target_len; /* offset of target domain instead of entire sni */
|
||||
int sni_len;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user