mirror of
https://github.com/Waujito/youtubeUnblock.git
synced 2024-12-22 14:26:11 +00:00
Support for openWRT SDK build system
This commit is contained in:
parent
be40bc91e7
commit
82d65b8f96
14
Makefile
14
Makefile
@ -1,11 +1,11 @@
|
|||||||
BUILD_DIR := $(CURDIR)/build
|
BUILD_DIR := $(CURDIR)/build
|
||||||
DEPSDIR := $(BUILD_DIR)/deps
|
DEPSDIR := $(BUILD_DIR)/deps
|
||||||
|
|
||||||
CC := gcc
|
CC:=gcc
|
||||||
CCLD := $(CC)
|
CCLD:=$(CC)
|
||||||
LD := ld
|
LD:=ld
|
||||||
CFLAGS:=-Wall -Wpedantic -Wno-unused-variable -I$(DEPSDIR)/include -Os
|
override CFLAGS += -Wall -Wpedantic -Wno-unused-variable -I$(DEPSDIR)/include
|
||||||
LDFLAGS:=-L$(DEPSDIR)/lib -static
|
override LDFLAGS += -L$(DEPSDIR)/lib
|
||||||
|
|
||||||
LIBNFNETLINK_CFLAGS := -I$(DEPSDIR)/include
|
LIBNFNETLINK_CFLAGS := -I$(DEPSDIR)/include
|
||||||
LIBNFNETLINK_LIBS := -L$(DEPSDIR)/lib
|
LIBNFNETLINK_LIBS := -L$(DEPSDIR)/lib
|
||||||
@ -65,11 +65,11 @@ $(LIBNETFILTER_QUEUE): $(LIBNFNETLINK) $(LIBMNL)
|
|||||||
|
|
||||||
$(APP): $(OBJS) $(LIBNETFILTER_QUEUE) $(LIBMNL)
|
$(APP): $(OBJS) $(LIBNETFILTER_QUEUE) $(LIBMNL)
|
||||||
@echo 'CCLD $(APP)'
|
@echo 'CCLD $(APP)'
|
||||||
@$(CCLD) $(OBJS) -o $(APP) -L$(DEPSDIR)/lib -lmnl -lnetfilter_queue
|
$(CCLD) $(OBJS) -o $(APP) $(LDFLAGS) -lmnl -lnetfilter_queue
|
||||||
|
|
||||||
$(BUILD_DIR)/%.o: %.c $(LIBNETFILTER_QUEUE) $(LIBMNL)
|
$(BUILD_DIR)/%.o: %.c $(LIBNETFILTER_QUEUE) $(LIBMNL)
|
||||||
@echo 'CC $@'
|
@echo 'CC $@'
|
||||||
@$(CC) -c $(CFLAGS) $^ -o $@
|
$(CC) -c $(CFLAGS) $(LDFLAGS) $< -o $@
|
||||||
|
|
||||||
install: all
|
install: all
|
||||||
install -d $(PREFIX)/bin/
|
install -d $(PREFIX)/bin/
|
||||||
|
@ -62,6 +62,10 @@ Also you can copy `owrt/537-youtubeUnblock.nft` to `/usr/share/nftables.d/rulese
|
|||||||
|
|
||||||
Next step is to daemonize the application in openwrt. Copy `owrt/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, but I don't recommend this since if the packet has bug you may lose access to the router (I think you will be able to reset it with reset settings tricks documented for your router).
|
Next step is to daemonize the application in openwrt. Copy `owrt/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, but I don't recommend this since if the packet has bug you may lose access to the router (I think you will be able to reset it with reset settings tricks documented for your router).
|
||||||
|
|
||||||
|
## Building OpenWRT .ipk package
|
||||||
|
OpenWRT provides a high-level SDK for package to be built. Next I will describe how to build the package fully compatible with your router. This way requires more steps but is preferred because it will produce ready-to-manage opkg package.
|
||||||
|
First step is to download or compile OpenWRT SDK for your specific platform. The SDK can be compiled according to [this tutorial](https://openwrt.org/docs/guide-developer/toolchain/using_the_sdk). Beside of raw source code of SDK OpenWRT also offers precompiled SDKs for your router. You can find it near the toolchain from previous section. It is called openwrt-sdk-23.05.3-ramips-mt76x8_gcc-12.3.0_musl.Linux-x86_64 for me. You will need to [install build system requirements on your system](https://openwrt.org/docs/guide-developer/toolchain/install-buildsystem) If you have any problems, use docker ubuntu:24.04 image. Next untar the SDK, cd it. Do `echo "src-git youtubeUnblock https://github.com/Waujito/youtubeUnblock.git;openwrt" >> feeds.conf`, `./scripts/feeds update -a youtubeUnblock`, `./scripts/feeds install -a -p youtubeUnblock`, `make package/youtubeUnblock/compile`. Now the packet is built and you can import it to the router. Find it in `bin/packages/<target>/youtubeUnblock/youtubeUnblock-<version>.ipk`. Go to your router interface and put it via System-Software-install_package. Now the package is on the router. Goto System-Startup, restart firewall and start youtubeUnblock. You are done!
|
||||||
|
|
||||||
## Performance
|
## Performance
|
||||||
If you have bad performance you can queue to youtubeUnblock only first, say, 20 packets from the connection. To do so, use nftables conntrack packets counter: `nft add rule inet fw4 mangle_forward tcp dport 443 ct original "packets < 20" counter queue num 537 bypass`. For my 1 CPU core device it worked pretty well. This works because we do care about only first packets with ClientHello. We don't need to process others.
|
If you have bad performance you can queue to youtubeUnblock only first, say, 20 packets from the connection. To do so, use nftables conntrack packets counter: `nft add rule inet fw4 mangle_forward tcp dport 443 ct original "packets < 20" counter queue num 537 bypass`. For my 1 CPU core device it worked pretty well. This works because we do care about only first packets with ClientHello. We don't need to process others.
|
||||||
|
|
||||||
|
0
owrt/youtubeUnblock.owrt
Normal file → Executable file
0
owrt/youtubeUnblock.owrt
Normal file → Executable file
Loading…
Reference in New Issue
Block a user