From d66bfc0ee96291d3b54bc9220f6d73b9d7c8ee3f Mon Sep 17 00:00:00 2001 From: eson <474420502@qq.com> Date: Tue, 18 Dec 2018 00:42:59 +0800 Subject: [PATCH] test cmd --- switch.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) 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)