From d05037f53059f36ea515f923a2661dbd81d8a63c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Sat, 13 Aug 2022 12:23:47 +0800 Subject: [PATCH] - update --- client.go | 3 ++- const.go | 2 +- go.mod | 2 +- go.sum | 4 ++-- vendor/go.dtapp.net/goip/.gitignore | 1 - vendor/go.dtapp.net/goip/README.md | 9 +++++---- vendor/go.dtapp.net/goip/const.go | 2 +- vendor/go.dtapp.net/goip/ip.go | 11 ++++++----- vendor/modules.txt | 2 +- 9 files changed, 19 insertions(+), 17 deletions(-) diff --git a/client.go b/client.go index 65961ea..242011b 100644 --- a/client.go +++ b/client.go @@ -1,6 +1,7 @@ package wikeyun import ( + "context" "go.dtapp.net/dorm" "go.dtapp.net/goip" "go.dtapp.net/golog" @@ -50,7 +51,7 @@ func NewClient(config *ConfigClient) (*Client, error) { } } - xip := goip.GetOutsideIp() + xip := goip.GetOutsideIp(context.Background()) if xip != "" && xip != "0.0.0.0" { c.clientIp = xip } diff --git a/const.go b/const.go index 8955d68..fa40ea9 100644 --- a/const.go +++ b/const.go @@ -12,4 +12,4 @@ const ( logTable = "wikeyun" ) -const Version = "1.0.8" +const Version = "1.0.9" diff --git a/go.mod b/go.mod index 9174d4c..be20570 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 require ( go.dtapp.net/dorm v1.0.17 - go.dtapp.net/goip v1.0.24 + go.dtapp.net/goip v1.0.25 go.dtapp.net/golog v1.0.24 go.dtapp.net/gorequest v1.0.26 go.dtapp.net/gostring v1.0.6 diff --git a/go.sum b/go.sum index 3ab1243..1be06f2 100644 --- a/go.sum +++ b/go.sum @@ -501,8 +501,8 @@ github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxt github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0= go.dtapp.net/dorm v1.0.17 h1:3VQKUl05CDxFg3T1c/M8wYf2I+H+oVGBDh4NCV30nn0= go.dtapp.net/dorm v1.0.17/go.mod h1:bHG7BmgeLaAlc56myYF63lwZAIuMeWRAqHBb/L84dLM= -go.dtapp.net/goip v1.0.24 h1:62k3xt9I/YLUwA5tLp7YC8XPskkswc4RJrvxRRxjwIY= -go.dtapp.net/goip v1.0.24/go.mod h1:tps0yoq5kSykLGDb01vuai47hzAQ6nYUPFWLdlQA2Oo= +go.dtapp.net/goip v1.0.25 h1:GSgQkR7dc28TX8E1mF3wAy+EEGZ++tgqc8Q85OKZPEY= +go.dtapp.net/goip v1.0.25/go.mod h1:dKeNuWJttH4AvvYVHV0FagB6BVvFM1HGDKFxLKr+hkQ= go.dtapp.net/gojson v1.0.1 h1:MHeSGlq1KxzL7rCkm18fhwW4GNORHohdDMmxY5PupKY= go.dtapp.net/gojson v1.0.1/go.mod h1:TkkpTNxHBKxul0e7gC5MrL1K4ICFB9mQ7wHzjBah3/k= go.dtapp.net/golog v1.0.24 h1:A26GN2fEJOsMWRb+jqG2LKRmB8aEuWFYNNXGT23VNbc= diff --git a/vendor/go.dtapp.net/goip/.gitignore b/vendor/go.dtapp.net/goip/.gitignore index 0a5d8bc..0d98f22 100644 --- a/vendor/go.dtapp.net/goip/.gitignore +++ b/vendor/go.dtapp.net/goip/.gitignore @@ -5,5 +5,4 @@ .vscode *.log gomod.sh -/vendor/ download_test.go \ No newline at end of file diff --git a/vendor/go.dtapp.net/goip/README.md b/vendor/go.dtapp.net/goip/README.md index 6416a7c..eadad93 100644 --- a/vendor/go.dtapp.net/goip/README.md +++ b/vendor/go.dtapp.net/goip/README.md @@ -2,7 +2,7 @@ Golang Ip -📦 Golang Ip库 +📦 Golang Ip [comment]: <> (go) [![godoc](https://pkg.go.dev/badge/go.dtapp.net/goip?status.svg)](https://pkg.go.dev/go.dtapp.net/goip) @@ -22,17 +22,18 @@ go get -v -u go.dtapp.net/goip package main import ( + "context" "go.dtapp.net/goip" "testing" ) func TestGoIp(t *testing.T) { // 获取Mac地址 - t.Log(goip.GetMacAddr()) + t.Log(goip.GetMacAddr(context.Background())) // 内网ip - t.Log(goip.GetInsideIp()) + t.Log(goip.GetInsideIp(context.Background())) // 外网ip - t.Log(goip.GetOutsideIp()) + t.Log(goip.GetOutsideIp(context.Background())) } ``` \ No newline at end of file diff --git a/vendor/go.dtapp.net/goip/const.go b/vendor/go.dtapp.net/goip/const.go index b5d9f08..17cc0e6 100644 --- a/vendor/go.dtapp.net/goip/const.go +++ b/vendor/go.dtapp.net/goip/const.go @@ -1,3 +1,3 @@ package goip -const Version = "1.0.24" +const Version = "1.0.25" diff --git a/vendor/go.dtapp.net/goip/ip.go b/vendor/go.dtapp.net/goip/ip.go index 5689de1..28613e9 100644 --- a/vendor/go.dtapp.net/goip/ip.go +++ b/vendor/go.dtapp.net/goip/ip.go @@ -1,13 +1,14 @@ package goip import ( + "context" "encoding/json" "go.dtapp.net/gorequest" "net" ) // GetInsideIp 内网ip -func GetInsideIp() string { +func GetInsideIp(ctx context.Context) string { conn, err := net.Dial("udp", "8.8.8.8:80") if err != nil { panic(err) @@ -19,7 +20,7 @@ func GetInsideIp() string { } // Ips 获取全部网卡的全部IP -func Ips() (map[string]string, error) { +func Ips(ctx context.Context) (map[string]string, error) { ips := make(map[string]string) @@ -53,11 +54,11 @@ var respGetOutsideIp struct { } // GetOutsideIp 外网ip -func GetOutsideIp() (ip string) { +func GetOutsideIp(ctx context.Context) (ip string) { ip = "0.0.0.0" get := gorequest.NewHttp() get.SetUri("https://api.dtapp.net/ip") - response, err := get.Get() + response, err := get.Get(ctx) if err != nil { return } @@ -73,7 +74,7 @@ func GetOutsideIp() (ip string) { } // GetMacAddr 获取Mac地址 -func GetMacAddr() (arrays []string) { +func GetMacAddr(ctx context.Context) (arrays []string) { netInterfaces, err := net.Interfaces() if err != nil { return arrays diff --git a/vendor/modules.txt b/vendor/modules.txt index 3d4bd79..54a1728 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -226,7 +226,7 @@ github.com/youmark/pkcs8 # go.dtapp.net/dorm v1.0.17 ## explicit; go 1.19 go.dtapp.net/dorm -# go.dtapp.net/goip v1.0.24 +# go.dtapp.net/goip v1.0.25 ## explicit; go 1.19 go.dtapp.net/goip go.dtapp.net/goip/ip2region