diff --git a/switch.go b/switch.go index 7fc7175..097044f 100644 --- a/switch.go +++ b/switch.go @@ -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)