Last active
April 22, 2023 06:49
-
-
Save updateing/5ab6cafc20c5f17d2897db2329a2feb3 to your computer and use it in GitHub Desktop.
Clash TPROXY startup scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generated by xtables-save v1.8.2 on Sun Apr 4 19:09:44 2021 | |
*nat | |
:PREROUTING ACCEPT [2191:359909] | |
:INPUT ACCEPT [1063:168760] | |
:POSTROUTING ACCEPT [906:80396] | |
:OUTPUT ACCEPT [897:79912] | |
:clash - [0:0] | |
-A PREROUTING -p tcp -j clash | |
-A OUTPUT -d 198.18.0.0/16 -p tcp -j REDIRECT --to-ports 7892 | |
-A clash -d 0.0.0.0/8 -j RETURN | |
-A clash -d 10.0.0.0/8 -j RETURN | |
-A clash -d 127.0.0.0/8 -j RETURN | |
-A clash -d 169.254.0.0/16 -j RETURN | |
-A clash -d 172.16.0.0/12 -j RETURN | |
-A clash -d 192.168.0.0/16 -j RETURN | |
-A clash -d 224.0.0.0/4 -j RETURN | |
-A clash -d 240.0.0.0/4 -j RETURN | |
-A clash -d 192.168.254.1/32 -j RETURN | |
-A clash -p tcp -j REDIRECT --to-ports 7892 | |
COMMIT | |
# Completed on Sun Apr 4 19:09:44 2021 | |
# Generated by xtables-save v1.8.2 on Sun Apr 4 19:09:44 2021 | |
*mangle | |
:PREROUTING ACCEPT [121642:131102755] | |
:INPUT ACCEPT [118439:130690010] | |
:FORWARD ACCEPT [1722:96588] | |
:OUTPUT ACCEPT [73665:122507329] | |
:POSTROUTING ACCEPT [75426:122606674] | |
:clash - [0:0] | |
-A PREROUTING -p udp -j clash | |
-A OUTPUT -d 198.18.0.0/16 -p udp -j MARK --set-xmark 0x1/0xffffffff | |
-A clash -d 0.0.0.0/8 -j RETURN | |
-A clash -d 10.0.0.0/8 -j RETURN | |
-A clash -d 127.0.0.0/8 -j RETURN | |
-A clash -d 169.254.0.0/16 -j RETURN | |
-A clash -d 172.16.0.0/12 -j RETURN | |
-A clash -d 192.168.0.0/16 -j RETURN | |
-A clash -d 224.0.0.0/4 -j RETURN | |
-A clash -d 240.0.0.0/4 -j RETURN | |
-A clash -d 192.168.254.1/32 -j RETURN | |
-A clash -p udp -j TPROXY --on-port 7893 --on-ip 0.0.0.0 --tproxy-mark 0x1/0xffffffff | |
COMMIT | |
# Completed on Sun Apr 4 19:09:44 2021 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Clash | |
After=network-online.target | |
[Service] | |
Type=simple | |
User=root | |
ExecStart=/root/clash/clash-linux-armv8-current -d /root/clash | |
ExecStartPost=sh -c "(ip rule add fwmark 1 table 100 ; ip route add local default dev lo table 100) || true" | |
ExecStopPost=sh -c "(ip rule del fwmark 1 table 100 ; ip route flush table 100) || true" | |
[Install] | |
WantedBy=multi-user.target |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
URL='https://xxx' | |
FILENAME=config-xxx.yaml | |
HEADER=header.yaml | |
[ -f "$FILENAME" ] && mv "$FILENAME" "$FILENAME".old | |
wget -O "$FILENAME" "$URL" | |
# Remove everything not in /^proxies/ to $ (EOF) | |
sed -i '/^proxies/,$ p;d' "$FILENAME" | |
cat "$HEADER" "$FILENAME" > new | |
mv new "$FILENAME" | |
HEADER=header.yaml | |
[ -f "$FILENAME" ] && mv "$FILENAME" "$FILENAME".old | |
wget -O "$FILENAME" "$URL" | |
# Remove everything not in /^proxies/ to $ (EOF) | |
sed -i '/^proxies/,$ p;d' "$FILENAME" | |
cat "$HEADER" "$FILENAME" > /tmp/new | |
mv /tmp/new "$FILENAME" | |
[ "$1" != noapply ] && { | |
ln -sf "$FILENAME" config.yaml | |
systemctl restart clash | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment