test cmd
This commit is contained in:
parent
e498b1adc5
commit
d66bfc0ee9
16
switch.go
16
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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user