mirror of
https://github.com/Waujito/youtubeUnblock.git
synced 2024-12-22 06:15:31 +00:00
Cleanup code, update readme, fix gen_fake_sni
This commit is contained in:
parent
57c5b1f6aa
commit
8808c49fbd
11
README.md
11
README.md
@ -30,6 +30,13 @@ Systemd daemon is also available. Do `systemctl enable --now youtubeUnblock.serv
|
||||
|
||||
Also DNS over HTTPS (DOH) is preferred for additional anonimity.
|
||||
|
||||
## Troubleshooting
|
||||
If you have any troubles with youtubeUnblock, here are some options to tune. If them don't work in your case, please, open an issue. You can pass these options in make CFLAGS (`make CFLAGS=...`) or edit CFLAGS variable in Makefile.
|
||||
Available flags:
|
||||
- -DUSE_SEG2_DELAY This flag forces youtubeUnblock to wait little bit before send the 2nd part of the split packet. You can tune the amount of time in `#define SEG2_DELAY 100` where 100 stands for milliseconds.
|
||||
- -DNO_FAKE_SNI This flag forces youtubeUnblock to send at least three packets instead of one with TLS ClientHello: Fake ClientHello, 1st part of original ClientHello, 2nd part of original ClientHello.
|
||||
- -DNOUSE_GSO This flag disables fix for Google Chrome fat ClientHello. The GSO is well tested now, so this flag probably won't fix anything.
|
||||
|
||||
## OpenWRT case
|
||||
The package is also compatible with routers. The router should be running by free opensource linux-based system such as [OpenWRT](https://openwrt.org/). You should cross-compile it under your host machine. Be ready for compilation errors and a lot of googling about it. It is not such a trivial process! You can get crosscompilation toolsuite compatible with your router from OpenWRT repositories. For example, I have ramips/mt76x8 based router so for me the toolsuite is on https://downloads.openwrt.org/releases/23.05.3/targets/ramips/mt76x8/ and called `openwrt-toolchain-23.05.3-ramips-mt76x8_gcc-12.3.0_musl.Linux-x86_64.tar.xz`. You can find out more about your router model on it's openwrt page. When you download the toolsuite, untar it somewhere. Now we are ready for compilation. My cross gcc asked me to create a staging dir for it and pass it as an environment variable. Also you should notice toolsuite packages and replace my make command with yours. ```STAGING_DIR=temp make CC=/usr/bin/mipsel-openwrt-linux-gcc LD=/usr/bin/mipsel-openwrt-linux-gcc AR=/usr/bin/mipsel-openwrt-linux-ar OBJDUMP=/usr/bin/mipsel-openwrt-linux-objdump NM=/usr/bin/mipsel-openwrt-linux-nm STRIP=/usr/bin/mipsel-openwrt-linux-strip CROSS_COMPILE_PLATFORM=mipsel-buildroot-linux-gnu```. Take a look at `CROSS_COMPILE_PLATFORM` It is required by autotools but I think it is not necessary. Anyways I put `mipsel-buildroot-linux-gnu` in here. For your model may be an [automake cross-compile manual](https://www.gnu.org/software/automake/manual/html_node/Cross_002dCompilation.html) will be helpful. When compilation is done, the binary file will be in build directory. Copy it to your router. Note that an ssh access is likely to be required to proceed. sshfs don't work on my model so I injected the application to the router via Software Upload Package page. It has given me an error, but also a `/tmp/upload.ipk` file which I copied in root directory, `chmod +x`-ed and run.
|
||||
|
||||
@ -37,8 +44,4 @@ Now let's talk about a router configuration. I installed a normal iptables user-
|
||||
|
||||
Next step is to daemonize the application in openwrt. Copy youtubeUnblock.owrt to /etc/init.d/youtubeUnblock and put the program into /usr/bin/. (Don't forget to `chmod +x` both). Now run `/etc/init.d/youtubeUnblock start`. You can alo run `/etc/init.d/youtubeUnblock enable` to force OpenWRT autostart the program on boot.
|
||||
|
||||
|
||||
## Further development
|
||||
Please note that the application needs in further development. Some googlevideo servers may still be unabailable, some may drop out hello packets on Firefox while some may do so on Chrome. If you got in trouble try to disable GSO (Pass -DNOUSE_GSO as CC_FLAGS). Also you may set the program to use IP fragmentation instead of TCP (-DUSE_IP_FRAGMENTATION).
|
||||
|
||||
**If you have any questions/suggestions/problems feel free to open an issue.**
|
||||
|
@ -33,7 +33,7 @@
|
||||
|
||||
#define RAWSOCKET_MARK 0xfc70
|
||||
|
||||
#ifndef NO_SEG2_DELAY
|
||||
#ifdef USE_SEG2_DELAY
|
||||
#define SEG2_DELAY 100
|
||||
#endif
|
||||
|
||||
@ -589,15 +589,26 @@ static struct pkt_buff *gen_fake_sni(const struct iphdr *iph, const struct tcphd
|
||||
|
||||
int ret = 0;
|
||||
struct iphdr *niph = nfq_ip_get_hdr(pkt);
|
||||
if (!niph) goto err;
|
||||
if (!niph) {
|
||||
perror("gen_fake_sni: ip header is null");
|
||||
goto err;
|
||||
}
|
||||
|
||||
niph->protocol = IPPROTO_TCP;
|
||||
niph->tot_len = htons(pkt_size);
|
||||
|
||||
ret = nfq_ip_set_transport_header(pkt, niph);
|
||||
if (ret < 0) goto err;
|
||||
if (ret < 0) {
|
||||
perror("gen_fake_sni: set transport header");
|
||||
goto err;
|
||||
}
|
||||
|
||||
struct tcphdr *ntcph = nfq_tcp_get_hdr(pkt);
|
||||
if (!ntcph) goto err;
|
||||
if (!ntcph) {
|
||||
perror("gen_fake_sni: nfq_tcp_get_hdr");
|
||||
goto err;
|
||||
}
|
||||
|
||||
niph->tot_len = htons(pkt_size);
|
||||
ntcph->th_dport = tcph->th_dport;
|
||||
ntcph->th_sport = tcph->th_sport;
|
||||
nfq_ip_set_checksum(niph);
|
||||
@ -605,7 +616,6 @@ static struct pkt_buff *gen_fake_sni(const struct iphdr *iph, const struct tcphd
|
||||
|
||||
return pkt;
|
||||
err:
|
||||
fprintf(stderr, "Error in gen fake sni\n");
|
||||
pktb_free(pkt);
|
||||
return NULL;
|
||||
|
||||
@ -712,6 +722,12 @@ static int process_packet(const struct packet_data packet) {
|
||||
packet.payload,
|
||||
packet.payload_len,
|
||||
0);
|
||||
|
||||
if (pktb == NULL) {
|
||||
perror("pktb_alloc of payload");
|
||||
pktb_free(fake_sni);
|
||||
goto fallback;
|
||||
}
|
||||
|
||||
if (tcp4_frag(pktb, mid_offset, &frag1, &frag2) < 0) {
|
||||
perror("tcp4_frag");
|
||||
@ -723,11 +739,10 @@ static int process_packet(const struct packet_data packet) {
|
||||
ret = send_raw_socket(frag2);
|
||||
if (ret < 0) {
|
||||
errno = ret;
|
||||
perror("raw frags send");
|
||||
perror("raw frags send: frag2");
|
||||
pktb_free(frag1);
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
#ifdef SEG2_DELAY
|
||||
struct dps_t *dpdt = malloc(sizeof(struct dps_t));
|
||||
@ -739,10 +754,12 @@ static int process_packet(const struct packet_data packet) {
|
||||
#else
|
||||
ret = send_raw_socket(frag1);
|
||||
if (ret < 0) {
|
||||
free(frag1);
|
||||
errno = ret;
|
||||
perror("raw frags send: frag1");
|
||||
pktb_free(frag1);
|
||||
goto err;
|
||||
}
|
||||
free(frag1);
|
||||
pktb_free(frag1);
|
||||
#endif
|
||||
err:
|
||||
pktb_free(frag2);
|
||||
@ -851,9 +868,17 @@ int main(int argc, const char *argv[])
|
||||
}
|
||||
|
||||
#ifdef USE_TCP_SEGMENTATION
|
||||
printf("Using TCP segmentation!\n");
|
||||
printf("Using TCP segmentation\n");
|
||||
#else
|
||||
printf("Using IP fragmentation!\n");
|
||||
printf("Using IP fragmentation\n");
|
||||
#endif
|
||||
|
||||
#ifdef SEG2_DELAY
|
||||
printf("Some outgoing googlevideo request segments will be delayed for %d ms as of SEG2_DELAY define\n", SEG2_DELAY);
|
||||
#endif
|
||||
|
||||
#ifdef FAKE_SNI
|
||||
printf("Fake SNI will be sent before each googlevideo request\n");
|
||||
#endif
|
||||
|
||||
if (open_socket()) {
|
||||
@ -889,7 +914,7 @@ int main(int argc, const char *argv[])
|
||||
nfq_nlmsg_cfg_put_params(nlh, NFQNL_COPY_PACKET, 0xffff);
|
||||
|
||||
#ifdef USE_GSO
|
||||
printf("GSO is enabled!\n");
|
||||
printf("GSO is enabled\n");
|
||||
|
||||
mnl_attr_put_u32(nlh, NFQA_CFG_FLAGS, htonl(NFQA_CFG_F_GSO));
|
||||
mnl_attr_put_u32(nlh, NFQA_CFG_MASK, htonl(NFQA_CFG_F_GSO));
|
||||
|
Loading…
Reference in New Issue
Block a user