mirror of
https://github.com/Waujito/youtubeUnblock.git
synced 2025-12-31 03:38:07 +03:00
Allow to select synfake length
This commit is contained in:
19
mangle.c
19
mangle.c
@@ -94,25 +94,36 @@ int process_tcp_packet(const uint8_t *raw_payload, uint32_t raw_payload_len) {
|
||||
uint8_t payload[MAX_PACKET_SIZE];
|
||||
memcpy(payload, ipxh, iph_len);
|
||||
memcpy(payload + iph_len, tcph, tcph_len);
|
||||
memcpy(payload + iph_len + tcph_len, config.fake_sni_pkt, config.fake_sni_pkt_sz);
|
||||
uint32_t fake_len = config.fake_sni_pkt_sz;
|
||||
|
||||
if (config.synfake_len)
|
||||
fake_len = min(config.synfake_len, fake_len);
|
||||
|
||||
memcpy(payload + iph_len + tcph_len, config.fake_sni_pkt, fake_len);
|
||||
|
||||
|
||||
struct tcphdr *tcph = (struct tcphdr *)(payload + iph_len);
|
||||
if (ipxv == IP4VERSION) {
|
||||
struct iphdr *iph = (struct iphdr *)payload;
|
||||
iph->tot_len = htons(iph_len + tcph_len + config.fake_sni_pkt_sz);
|
||||
iph->tot_len = htons(iph_len + tcph_len + fake_len);
|
||||
set_ip_checksum(payload, iph_len);
|
||||
set_tcp_checksum(tcph, iph, iph_len);
|
||||
} else if (ipxv == IP6VERSION) {
|
||||
struct ip6_hdr *ip6h = (struct ip6_hdr *)payload;
|
||||
ip6h->ip6_ctlun.ip6_un1.ip6_un1_plen = ntohs(tcph_len + config.fake_sni_pkt_sz);
|
||||
ip6h->ip6_ctlun.ip6_un1.ip6_un1_plen =
|
||||
ntohs(tcph_len + fake_len);
|
||||
set_ip_checksum(ip6h, iph_len);
|
||||
set_tcp_checksum(tcph, ip6h, iph_len);
|
||||
}
|
||||
|
||||
|
||||
|
||||
instance_config.send_raw_packet(payload, iph_len + tcph_len + config.fake_sni_pkt_sz);
|
||||
ret = instance_config.send_raw_packet(payload, iph_len + tcph_len + fake_len);
|
||||
if (ret < 0) {
|
||||
lgerror("send_syn_altered", ret);
|
||||
goto accept;
|
||||
}
|
||||
lgtrace_addp("rawsocket sent %d", ret);
|
||||
goto drop;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user