@@ -32335,6 +32335,46 @@ test_tor_dns_intercept() {
32335
32335
service firewall restart
32336
32336
}
32337
32337
32338
+ test_Intercept_TCP() {
32339
+ cat << "EOF" > /etc/nftables.d/tor.sh
32340
+ TOR_CHAIN="dstnat_$(uci -q get firewall.tcp_int.src)"
32341
+ TOR_RULE="$(nft -a list chain inet fw4 ${TOR_CHAIN} \
32342
+ | sed -n -e "/Intercept-TCP/p")"
32343
+ nft replace rule inet fw4 ${TOR_CHAIN} \
32344
+ handle ${TOR_RULE##* } \
32345
+ fib daddr type != { local, broadcast } ${TOR_RULE}
32346
+ EOF
32347
+ uci -q delete firewall.tor_nft
32348
+ uci set firewall.tor_nft="include"
32349
+ uci set firewall.tor_nft.path="/etc/nftables.d/tor.sh"
32350
+ uci -q delete firewall.tcp_int
32351
+ uci set firewall.tcp_int="redirect"
32352
+ uci set firewall.tcp_int.name="Intercept-TCP"
32353
+ uci set firewall.tcp_int.src="lan"
32354
+ uci set firewall.tcp_int.src_dport="0-65535"
32355
+ uci set firewall.tcp_int.dest_port="$TOR_TRANS_port"
32356
+ uci set firewall.tcp_int.proto="tcp"
32357
+ uci set firewall.tcp_int.family="any"
32358
+ uci set firewall.tcp_int.target="DNAT"
32359
+
32360
+ uci -q delete firewall.tcp2_int
32361
+ uci set firewall.tcp2_int="redirect"
32362
+ uci set firewall.tcp2_int.name="Intercept-TCP"
32363
+ uci set firewall.tcp2_int.src="INET"
32364
+ uci set firewall.tcp2_int.src_dport="0-65535"
32365
+ uci set firewall.tcp2_int.dest_port="$TOR_TRANS_port"
32366
+ uci set firewall.tcp2_int.proto="tcp"
32367
+ uci set firewall.tcp2_int.family="any"
32368
+ uci set firewall.tcp2_int.target="DNAT"
32369
+
32370
+ # Disable LAN to WAN forwarding
32371
+ uci -q delete firewall.@forwarding[0]
32372
+ uci -q delete firewall.@forwarding[4]
32373
+ uci commit firewall
32374
+ service firewall restart
32375
+
32376
+ }
32377
+
32338
32378
setup_tor_routing() {
32339
32379
iptables -t nat -A PREROUTING -i inet -p tcp --syn -j REDIRECT --to-ports $TOR_TRANS_port
32340
32380
iptables -A FORWARD -i inet -o wan -j ACCEPT
0 commit comments