网上找的一个go程序,获取机器的出口IP的,在Windows 10上build成exe时被自带防护工具给拦截了
package main
import (
"fmt"
"io"
"net/http"
)
func main() {
responseClient, errClient := http.Get("https://checkip.amazonaws.com/") // 获取外网 IP
if errClient != nil {
fmt.Printf("获取外网 IP 失败,请检查网络\n")
panic(errClient)
}
// 程序在使用完 response 后必须关闭 response 的主体。
defer responseClient.Body.Close()
body, _ := io.ReadAll(responseClient.Body)
clientIP := fmt.Sprintf("%s", string(body))
print(clientIP)
}
go build getmyip.go
go build command-line-arguments: open C:\Users\someone\AppData\Local\Temp\go-build3600752379\b001\exe\a.out.exe: Operation did not complete successfully because the file contains a virus or potentially unwanted software.
之前使用的是:icanhazip.com ,这个确实很多网站被当做恶意软件的,没想到amazon的也是。
但是我自己起一个 icanhazip的python server后,使用 IP+端口访问,也是类似的问题
# gunicorn -b 0.0.0.0:9080 icanhaz:app
[2024-02-21 10:37:42 +0000] [1897721] [INFO] Starting gunicorn 21.2.0
[2024-02-21 10:37:42 +0000] [1897721] [INFO] Listening at: http://0.0.0.0:9080 (1897721)
[2024-02-21 10:37:42 +0000] [1897721] [INFO] Using worker: sync
[2024-02-21 10:37:42 +0000] [1897722] [INFO] Booting worker with pid: 1897722
直接go run都没问题,但是一build要么像上面不能build成功,要么build成功了一执行就被删除了。
我手动允许一下:
威胁还不一样?
windows有点搞笑了吧?这是为啥呢?