mirror of
https://github.com/Waujito/youtubeUnblock.git
synced 2024-12-22 14:26:11 +00:00
Fix #17
This commit is contained in:
parent
72a7c21b17
commit
709fc4c3be
@ -577,14 +577,20 @@ nextMessage:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct pkt_buff *gen_fake_sni(const struct iphdr *iph, const struct tcphdr *tcph) {
|
static struct pkt_buff *gen_fake_sni(const struct iphdr *iph, const struct tcphdr *tcph) {
|
||||||
|
uint8_t sniph_buf[60];
|
||||||
int ip_len = iph->ihl * 4;
|
int ip_len = iph->ihl * 4;
|
||||||
int tcp_len = tcph->doff * 4;
|
|
||||||
|
|
||||||
size_t pkt_size = ip_len + sizeof(fake_sni);
|
size_t pkt_size = ip_len + sizeof(fake_sni);
|
||||||
|
|
||||||
|
memcpy(sniph_buf, iph, ip_len);
|
||||||
|
struct iphdr *sniph = (struct iphdr *)sniph_buf;
|
||||||
|
|
||||||
|
sniph->protocol = IPPROTO_TCP;
|
||||||
|
sniph->tot_len = htons(pkt_size);
|
||||||
|
|
||||||
struct pkt_buff *pkt = pktb_alloc(AF_INET, NULL, 0, pkt_size);
|
struct pkt_buff *pkt = pktb_alloc(AF_INET, NULL, 0, pkt_size);
|
||||||
if (pkt == NULL) return NULL;
|
if (pkt == NULL) return NULL;
|
||||||
|
|
||||||
pktb_mangle(pkt, 0, 0, 0, (const char *)iph, ip_len);
|
pktb_mangle(pkt, 0, 0, 0, (char *)sniph_buf, ip_len);
|
||||||
pktb_mangle(pkt, ip_len, 0, 0, fake_sni, sizeof(fake_sni));
|
pktb_mangle(pkt, ip_len, 0, 0, fake_sni, sizeof(fake_sni));
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -594,9 +600,6 @@ static struct pkt_buff *gen_fake_sni(const struct iphdr *iph, const struct tcphd
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
niph->protocol = IPPROTO_TCP;
|
|
||||||
niph->tot_len = htons(pkt_size);
|
|
||||||
|
|
||||||
ret = nfq_ip_set_transport_header(pkt, niph);
|
ret = nfq_ip_set_transport_header(pkt, niph);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
perror("gen_fake_sni: set transport header");
|
perror("gen_fake_sni: set transport header");
|
||||||
|
Loading…
Reference in New Issue
Block a user