This commit is contained in:
eson 2018-12-18 00:42:59 +08:00
parent e498b1adc5
commit d66bfc0ee9

View File

@ -54,17 +54,27 @@ func (swi *Switch) Run(addr string, ipregion string) {
swi.ipregion = regexp.MustCompile(ipregion)
cmd := exec.Command("/bin/sh", "-c", "sudo iptables -t nat -N IPSWITCH")
cmd.Output()
cmd.Run()
if err := cmd.Process.Release(); err != nil {
panic(err)
}
cmd = exec.Command("/bin/sh", "-c", "sudo iptables -t nat -F IPSWITCH")
cmd.Output()
cmd.Run()
if err := cmd.Process.Release(); err != nil {
panic(err)
}
for range swi.Worker.ForLoop {
cmd := exec.Command("/bin/sh", "-c", "sudo iptables -t nat -A IPSWITCH -p icmp -s 1.1.1.1 -j DNAT --to 1.1.1.1:8885")
_, err := cmd.Output()
err := cmd.Run()
if err != nil {
panic(err)
}
if err := cmd.Process.Release(); err != nil {
panic(err)
}
}
http.ListenAndServe(addr, nil)