diff --git a/dip.go b/dip.go index c7277ba..63afa16 100644 --- a/dip.go +++ b/dip.go @@ -87,6 +87,7 @@ func (group *DIPGroup) Choose(addr string) { group.Current.ActiveTime = now // log.Println("new set addr:", group.Current.Host, "restartAddr:", restartAddr, "resp", resp.Content()) SetAddrForward(group.IPTableNum, addr, ip) + } } diff --git a/switch.go b/switch.go index d169b7c..7fc7175 100644 --- a/switch.go +++ b/switch.go @@ -26,7 +26,7 @@ type Switch struct { func SetAddrForward(num, addr, ip string) { port := strings.Split(addr, ":")[1] cmd := exec.Command("/bin/sh", "-c", "sudo iptables -t nat -R IPSWITCH "+num+" -p tcp --dport "+port+" -j DNAT --to "+ip+":8885") - err := cmd.Run() + _, err := cmd.Output() if err != nil { panic(err) } @@ -54,14 +54,14 @@ 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.Run() + cmd.Output() cmd = exec.Command("/bin/sh", "-c", "sudo iptables -t nat -F IPSWITCH") - cmd.Run() + cmd.Output() 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.Run() + _, err := cmd.Output() if err != nil { panic(err) } @@ -93,7 +93,7 @@ func (swi *Switch) checkInReady(ip string, now int64) { dipg.Group[ip].ActiveTime = now if dh, ok := dipg.Waitor[ip]; ok { - if dh.OverTime(now, 12) > 0 { + if dh.OverTime(now, 20) > 0 { delete(dipg.Waitor, ip) } else { return