diff --git a/.github/workflows/build-ros-list.yml b/.github/workflows/build-ros-list.yml index 7ee64a12..2658f5d8 100644 --- a/.github/workflows/build-ros-list.yml +++ b/.github/workflows/build-ros-list.yml @@ -39,45 +39,45 @@ jobs: run: rm target/* - name: Rebuild target branch run: | - echo $'/ip firewall address-list/n' > target/china4.txt - echo $'/ipv6 firewall address-list/n' > target/china6.txt - ./netgen.py ref1/china4.txt -o target/china4.txt -p 'add address=' -s $'comment="" disabled=no list=China\n' - ./netgen.py ref1/china6.txt -o target/china6.txt -p 'add address=' -s $'comment="" disabled=no list=China\n' + echo $'/ip firewall address-list/nremove [find list=List_China]/n' > target/china4.txt + echo $'/ipv6 firewall address-list/nremove [find list=List_China]/n' > target/china6.txt + ./netgen.py ref1/china4.txt -o target/china4.txt -p 'add address=' -s ' list=List_China' + ./netgen.py ref1/china6.txt -o target/china6.txt -p 'add address=' -s ' list=List_China' - echo $'/ip firewall address-list/n' > target/telecom4.txt - echo $'/ipv6 firewall address-list/n' > target/telecom6.txt - ./netgen.py ref1/telecom4.txt -o target/telecom4.txt -p 'add address=' -s $'comment="" disabled=no list=ChinaTelecom\n' - ./netgen.py ref1/telecom6.txt -o target/telecom6.txt -p 'add address=' -s $'comment="" disabled=no list=ChinaTelecom\n' + echo $'/ip firewall address-list/nremove [find list=List_Telecom]/n' > target/telecom4.txt + echo $'/ipv6 firewall address-list/nremove [find list=List_Telecom]/n' > target/telecom6.txt + ./netgen.py ref1/telecom4.txt -o target/telecom4.txt -p 'add address=' -s ' list=List_Telecom' + ./netgen.py ref1/telecom6.txt -o target/telecom6.txt -p 'add address=' -s ' list=List_Telecom' - echo $'/ip firewall address-list/n' > target/unicom4.txt - echo $'/ipv6 firewall address-list/n' > target/unicom6.txt - ./netgen.py ref1/unicom4.txt -o target/unicom4.txt -p 'add address=' -s $'comment="" disabled=no list=ChinaUnicom\n' - ./netgen.py ref1/unicom6.txt -o target/unicom6.txt -p 'add address=' -s $'comment="" disabled=no list=ChinaUnicom\n' + echo $'/ip firewall address-list/nremove [find list=List_Unicom]/n' > target/unicom4.txt + echo $'/ipv6 firewall address-list/nremove [find list=List_Unicom]/n' > target/unicom6.txt + ./netgen.py ref1/unicom4.txt -o target/unicom4.txt -p 'add address=' -s ' list=List_Unicom' + ./netgen.py ref1/unicom6.txt -o target/unicom6.txt -p 'add address=' -s ' list=List_Unicom' - echo $'/ip firewall address-list/n' > target/mobile4.txt - echo $'/ipv6 firewall address-list/n' > target/mobile6.txt - ./netgen.py ref1/mobile4.txt -o target/mobile4.txt -p 'add address=' -s $'comment="" disabled=no list=ChinaMobile\n' - ./netgen.py ref1/mobile6.txt -o target/mobile6.txt -p 'add address=' -s $'comment="" disabled=no list=ChinaMobile\n' + echo $'/ip firewall address-list/nremove [find list=List_Mobile]/n' > target/mobile4.txt + echo $'/ipv6 firewall address-list/nremove [find list=List_Mobile]/n' > target/mobile6.txt + ./netgen.py ref1/mobile4.txt -o target/mobile4.txt -p 'add address=' -s ' list=List_Mobile' + ./netgen.py ref1/mobile6.txt -o target/mobile6.txt -p 'add address=' -s ' list=List_Mobile' - echo $'/ip firewall address-list/n' > target/chinae2v4.txt - echo $'/ipv6 firewall address-list/n' > target/chinae2v6.txt - ./netgen.py ref1/china4.txt -e ref1/telecom4.txt ref1/unicom4.txt -o target/chinae2v4.txt -p 'add address=' -s $'comment="" disabled=no list=ChinaE2\n' - ./netgen.py ref1/china6.txt -e ref1/telecom6.txt ref1/unicom6.txt -o target/chinae2v6.txt -p 'add address=' -s $'comment="" disabled=no list=ChinaE2\n' + echo $'/ip firewall address-list/nremove [find list=List_ChinaE2]/n' > target/chinae2v4.txt + echo $'/ipv6 firewall address-list/nremove [find list=List_ChinaE2]/n' > target/chinae2v6.txt + ./netgen.py ref1/china4.txt -e ref1/telecom4.txt ref1/unicom4.txt -o target/chinae2v4.txt -p 'add address=' -s ' list=List_ChinaE2' + ./netgen.py ref1/china6.txt -e ref1/telecom6.txt ref1/unicom6.txt -o target/chinae2v6.txt -p 'add address=' -s ' list=List_ChinaE2' - echo $'/ip firewall address-list/n' > target/chinae3v4.txt - echo $'/ipv6 firewall address-list/n' > target/chinae3v6.txt - ./netgen.py ref1/china4.txt -e ref1/telecom4.txt ref1/unicom4.txt ref1/mobile4.txt -o target/chinae3v4.txt -p 'add address=' -s $'comment="" disabled=no list=ChinaE3\n' - ./netgen.py ref1/china6.txt -e ref1/telecom6.txt ref1/unicom6.txt ref1/mobile6.txt -o target/chinae3v6.txt -p 'add address=' -s $'comment="" disabled=no list=ChinaE3\n' + echo $'/ip firewall address-list/nremove [find list=List_ChinaE3]/n' > target/chinae3v4.txt + echo $'/ipv6 firewall address-list/nremove [find list=List_ChinaE3]/n' > target/chinae3v6.txt + ./netgen.py ref1/china4.txt -e ref1/telecom4.txt ref1/unicom4.txt ref1/mobile4.txt -o target/chinae3v4.txt -p 'add address=' -s ' list=List_ChinaE3' + ./netgen.py ref1/china6.txt -e ref1/telecom6.txt ref1/unicom6.txt ref1/mobile6.txt -o target/chinae3v6.txt -p 'add address=' -s ' list=List_ChinaE3' - echo $'/ip firewall address-list/n' > target/foreign4.txt - echo $'/ipv6 firewall address-list/n' > target/foreign6.txt - ./netgen.py 0.0.0.0/0 -e private4.txt ref1/china4.txt -o target/foreign4.txt -p 'add address=' -s $'comment="" disabled=no list=Foreign\n' - ./netgen.py ::/0 -e private6.txt ref1/china6.txt -o target/foreign6.txt -p 'add address=' -s $'comment="" disabled=no list=Foreign\n' + echo $'/ip firewall address-list/nremove [find list=List_Foreign]/n' > target/foreign4.txt + echo $'/ipv6 firewall address-list/nremove [find list=List_Foreign]/n' > target/foreign6.txt + ./netgen.py 0.0.0.0/0 -e private4.txt ref1/china4.txt -o target/foreign4.txt -p 'add address=' -s ' list=List_Foreign' + ./netgen.py ::/0 -e private6.txt ref1/china6.txt -o target/foreign6.txt -p 'add address=' -s ' list=List_Foreign' - echo $'/ip firewall address-list/n' > target/private4.txt - echo $'/ipv6 firewall address-list/n' > target/private6.txt - ./netgen.py private4.txt -o target/private4.txt -p 'add address=' -s $'comment="" disabled=no list=Private\n' - ./netgen.py private6.txt -o target/private6.txt -p 'add address=' -s $'comment="" disabled=no list=Private\n' + echo $'/ip firewall address-list/nremove [find list=List_Private]/n' > target/private4.txt + echo $'/ipv6 firewall address-list/nremove [find list=List_Private]/n' > target/private6.txt + ./netgen.py private4.txt -o target/private4.txt -p 'add address=' -s ' list=List_Private' + ./netgen.py private6.txt -o target/private6.txt -p 'add address=' -s ' list=List_Private' cd target tree -H . -P "*.txt" -T "ROS List - $(date +%Y-%m-%d)" > index.html diff --git a/.github/workflows/build-sha.yml b/.github/workflows/build-sha.yml index 895331ab..a1cc9da5 100644 --- a/.github/workflows/build-sha.yml +++ b/.github/workflows/build-sha.yml @@ -50,10 +50,10 @@ jobs: echo 'ip route add 128.0.0.0/1 dev wgcf || true' >> target/wgcf-up.sh echo 'ip route add ::/1 dev wgcf || true' >> target/wgcf-up.sh echo 'ip route add 8000::/1 dev wgcf || true' >> target/wgcf-up.sh - ./netgen.py ref1/china4.txt -o target/wgcf-up.sh -p 'ip route add ' -s $' dev eth0 via 10.11.0.1 || true\n' - ./netgen.py ref1/china6.txt -o target/wgcf-up.sh -p 'ip route add ' -s $' dev eth0 via fe80::6a77:24ff:fed6:809d || true\n' - ./netgen.py private4.txt -o target/wgcf-up.sh -p 'ip route add ' -s $' dev eth0 via 10.11.0.1 || true\n' - ./netgen.py private6.txt -o target/wgcf-up.sh -p 'ip route add ' -s $' dev eth0 via fe80::6a77:24ff:fed6:809d || true\n' + ./netgen.py ref1/china4.txt -o target/wgcf-up.sh -p 'ip route add ' -s ' dev eth0 via 10.11.0.1 || true' + ./netgen.py ref1/china6.txt -o target/wgcf-up.sh -p 'ip route add ' -s ' dev eth0 via fe80::6a77:24ff:fed6:809d || true' + ./netgen.py private4.txt -o target/wgcf-up.sh -p 'ip route add ' -s ' dev eth0 via 10.11.0.1 || true' + ./netgen.py private6.txt -o target/wgcf-up.sh -p 'ip route add ' -s ' dev eth0 via fe80::6a77:24ff:fed6:809d || true' echo 'iptables -t nat -D POSTROUTING -o wgcf -j MASQUERADE || true' >> target/wgcf-down.sh echo 'ip6tables -t nat -D POSTROUTING -o wgcf -j MASQUERADE || true' >> target/wgcf-down.sh echo 'iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE || true' >> target/wgcf-down.sh @@ -65,10 +65,10 @@ jobs: echo 'ip route del 128.0.0.0/1 dev wgcf || true' >> target/wgcf-down.sh echo 'ip route del ::/1 dev wgcf || true' >> target/wgcf-down.sh echo 'ip route del 8000::/1 dev wgcf || true' >> target/wgcf-down.sh - ./netgen.py ref1/china4.txt -o target/wgcf-down.sh -p 'ip route del ' -s $' dev eth0 via 10.11.0.1 || true\n' - ./netgen.py ref1/china6.txt -o target/wgcf-down.sh -p 'ip route del ' -s $' dev eth0 via fe80::6a77:24ff:fed6:809d || true\n' - ./netgen.py private4.txt -o target/wgcf-up.sh -p 'ip route del ' -s $' dev eth0 via 10.11.0.1 || true\n' - ./netgen.py private6.txt -o target/wgcf-up.sh -p 'ip route del ' -s $' dev eth0 via fe80::6a77:24ff:fed6:809d || true\n' + ./netgen.py ref1/china4.txt -o target/wgcf-down.sh -p 'ip route del ' -s ' dev eth0 via 10.11.0.1 || true' + ./netgen.py ref1/china6.txt -o target/wgcf-down.sh -p 'ip route del ' -s ' dev eth0 via fe80::6a77:24ff:fed6:809d || true' + ./netgen.py private4.txt -o target/wgcf-up.sh -p 'ip route del ' -s ' dev eth0 via 10.11.0.1 || true' + ./netgen.py private6.txt -o target/wgcf-up.sh -p 'ip route del ' -s ' dev eth0 via fe80::6a77:24ff:fed6:809d || true' cp cf-watch.sh target/ cd target chmod +x *.sh diff --git a/netgen.py b/netgen.py index 71417df2..0259581e 100755 --- a/netgen.py +++ b/netgen.py @@ -91,7 +91,7 @@ def main(args): out_networks.extend(out6) output_lines = [ - f"{getattr(args,'prefix','')}{str(network)}{getattr(args,'suffix','')}" + f"{getattr(args,'prefix','')}{str(network)}{getattr(args,'suffix','')}\n" for network in out_networks ] @@ -155,7 +155,7 @@ if __name__ == '__main__': '-p', '--prefix', type=str, default='', help='write line prefix' ) parser.add_argument( - '-s', '--suffix', type=str, default='\n', help='write line suffix' + '-s', '--suffix', type=str, default='', help='write line suffix' ) parser.set_defaults(func=main) args = parser.parse_args()