|
@@ -84,18 +84,21 @@ func changeIP() {
|
|
|
exec.Command("pppoe-start").Run()
|
|
|
fmt.Println("wait...")
|
|
|
time.Sleep(10 * time.Second) //避免换IP后无法获取IP
|
|
|
- newIp := getMyIp() //获取新IP
|
|
|
+ //newIp := getMyIp() //获取新IP
|
|
|
+ newIp := GetInterfaceIpv4Addr("ppp0")
|
|
|
fmt.Println("newIp:", newIp)
|
|
|
if newIp != "" && newIp != myoldip {
|
|
|
fmt.Println("公网IP由", myoldip, "换为", newIp)
|
|
|
- ds, us := checkSpeed(config.CheckSpeedAddr, true) //测速
|
|
|
- if ds >= config.DownSpeedLimit && us >= config.UploadSpeedLimit { //网速达标
|
|
|
- fmt.Println("IP测速通过", newIp)
|
|
|
- myoldip = newIp
|
|
|
- break
|
|
|
- } else {
|
|
|
- fmt.Println("IP测速不通过", newIp, ds, us)
|
|
|
- }
|
|
|
+ myoldip = newIp
|
|
|
+ break
|
|
|
+ //ds, us := checkSpeed(config.CheckSpeedAddr, true) //测速
|
|
|
+ //if ds >= config.DownSpeedLimit && us >= config.UploadSpeedLimit { //网速达标
|
|
|
+ // fmt.Println("IP测速通过", newIp)
|
|
|
+ // myoldip = newIp
|
|
|
+ // break
|
|
|
+ //} else {
|
|
|
+ // fmt.Println("IP测速不通过", newIp, ds, us)
|
|
|
+ //}
|
|
|
} else {
|
|
|
fmt.Println("获取新IP失败...")
|
|
|
}
|
|
@@ -161,13 +164,13 @@ func getMyIp() (ip string) {
|
|
|
|
|
|
func checkIpAndPort() (sPorts, fPorts []string) {
|
|
|
//检测IP
|
|
|
- if !changing { //正在切换IP,不做测速检测
|
|
|
- fmt.Println("测速...")
|
|
|
- ds, us := checkSpeed(config.CheckSpeedAddr, false) //测速
|
|
|
- if ds < config.DownSpeedLimit || us < config.UploadSpeedLimit { //网速不达标,切换IP
|
|
|
- go runChangeIP() //重新切换IP
|
|
|
- }
|
|
|
- }
|
|
|
+ //if !changing { //正在切换IP,不做测速检测
|
|
|
+ // fmt.Println("测速...")
|
|
|
+ // ds, us := checkSpeed(config.CheckSpeedAddr, false) //测速
|
|
|
+ // if ds < config.DownSpeedLimit || us < config.UploadSpeedLimit { //网速不达标,切换IP
|
|
|
+ // go runChangeIP() //重新切换IP
|
|
|
+ // }
|
|
|
+ //}
|
|
|
fmt.Println("检测端口...")
|
|
|
//检测端口
|
|
|
sPorts, fPorts = checkPort()
|