#!/bin/sh
# create static_router.rsc and firewall address list
# CN IP Address
wget --no-check-certificate -c -O /data/repo/software/ispip/all_cn.txt https://ispip.clang.cn/all_cn.txt
# wget --no-check-certificate -c -O all_cn.txt http://www.iwik.org/ipcountry/CN.cidr

# /ip route add dst-address=223.29.252.0/22 gateway=121.14.41.209 comment=CN
# /ip route remove  [/ip route find comment=CN]
cd /data/repo/software/ispip/
net_name="pppoe-out1"
# static_router (default in chn)
{
echo "/ip route"
for cidr in $(cat all_cn.txt) ; do
  echo "add dst-address=$cidr gateway=$net_name comment=CN"
done
} > /data/repo/software/ispip/szhome_router.rsc

# ovpn_static_router
net_gateway="ovpn-out1"
{
echo "/ip route
add dst-address=66.22.212.0/22 gateway=$net_name comment=DC
add dst-address=66.22.210.0/22 gateway=$net_name comment=DC
add dst-address=66.22.218.0/23 gateway=$net_name comment=DC
add dst-address=185.151.204.0/24 gateway=$net_name comment=DC
add dst-address=162.159.128.232/29 gateway=$net_name comment=DC
add dst-address=162.159.129.232/29 gateway=$net_name comment=DC
add dst-address=162.159.130.232/29 gateway=$net_name comment=DC
add dst-address=162.159.133.232/29 gateway=$net_name comment=DC
add dst-address=162.159.134.232/29 gateway=$net_name comment=DC
add dst-address=162.159.135.232/29 gateway=$net_name comment=DC
add dst-address=162.159.136.232/29 gateway=$net_name comment=DC
add dst-address=162.159.137.232/29 gateway=$net_name comment=DC
add dst-address=162.159.138.232/29 gateway=$net_name comment=DC
add dst-address=31.13.0.0/16 gateway=$net_name comment=Whatsapp
add dst-address=157.240.0.0/16 gateway=$net_name comment=Whatsapp
add dst-address=203.205.234.0/23 gateway=$net_name comment=Wechat
add dst-address=203.205.136.0/23 gateway=$net_name comment=Wechat
add dst-address=43.129.192.0/18 gateway=$net_name comment=Wechat
add dst-address=203.205.252.0/23 gateway=$net_name comment=Wechat
add dst-address=101.227.0.0/16 gateway=$net_name comment=Wechat
add dst-address=14.22.9.0/24 gateway=$net_name comment=Wechat
add dst-address=119.147.4.0/24 gateway=$net_name comment=Wechat
add dst-address=129.226.0.0/16 gateway=$net_name comment=Wechat
add dst-address=163.60.15.0/24 gateway=$net_name comment=Wechat
add dst-address=183.3.224.0/20 gateway=$net_name comment=Wechat
add dst-address=203.105.235.0/24 gateway=$net_name comment=Wechat
add dst-address=58.30.192.0/19 gateway=$net_name comment=Wechat
add dst-address=211.152.148.0/24 gateway=$net_name comment=Wechat
add dst-address=203.205.254.0/23 gateway=$net_name comment=Wechat
add dst-address=113.96.0.0/12 gateway=$net_name comment=Wechat
add dst-address=43.154.192.0/18 gateway=$net_name comment=Wechat
add dst-address=43.152.14.0/24 gateway=$net_name comment=Wechat
add dst-address=119.28.164.0/23 gateway=$net_name comment=Wechat
"
for cidr in $(cat all_cn.txt) ; do
  echo "add dst-address=$cidr gateway=$net_name comment=CN"
done

} > /data/repo/software/ispip/l2tp_router.rsc

rm -rf /data/repo/software/ispip/all_cn.txt
