diff --git a/main.go b/main.go index 7a730f3..1ecbc7e 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,7 @@ import ( "net/http" "os" "os/exec" + "path/filepath" "runtime" "strings" "time" @@ -98,12 +99,34 @@ func SubProcess(args []string) *exec.Cmd { return cmd } +func get_ini() string { + exePath, err := os.Executable() + if err != nil { + fmt.Println("无法获取可执行文件路径:", err) + return "" + } + + exeDir := filepath.Dir(exePath) + exeDir = filepath.Join(exeDir, "public_ip.ini") + fmt.Println(exeDir) + + return exeDir +} + func main() { var version = "1.0.0" + // 获取当前可执行文件的路径 + INI_FILE := get_ini() + _, err := os.Stat(INI_FILE) + if os.IsNotExist(err) { + fmt.Println("配置文件不存在") + os.Exit(0) + } + // 读取配置文件 - cfgs, err := ini.Load("public_ip.ini") + cfgs, err := ini.Load(INI_FILE) if err != nil { fmt.Println(err) } diff --git a/public_ip b/public_ip index 68775ae..1bbbea6 100644 Binary files a/public_ip and b/public_ip differ diff --git a/public_ip-Daemon.exe b/public_ip-Daemon.exe index 3806111..d95f9a7 100644 Binary files a/public_ip-Daemon.exe and b/public_ip-Daemon.exe differ diff --git a/public_ip-Dos.exe b/public_ip-Dos.exe index 6dea07c..97581fd 100644 Binary files a/public_ip-Dos.exe and b/public_ip-Dos.exe differ diff --git a/public_ip.ini b/public_ip.ini index cdf73c7..18f8300 100644 --- a/public_ip.ini +++ b/public_ip.ini @@ -3,11 +3,11 @@ Get_Find_Ip_Url="http://58.34.44.125:6108/ip/find/ip/url" # 获取公网Ip后需要发送的Url地址 -SedIpURL="http://58.34.44.125:6108/ip/set/ip?ip=%s&storeNo=%s" +SedIpURL="http:// 58.34.44.125:6108/ip/set/ip?ip=%s&storeNo=%s" # 门店编号 StoreNo=2 # 等待时间 -While_Time=20 +While_Time=60