:art:服务端的初始化
This commit is contained in:
27
utils/network.go
Normal file
27
utils/network.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"gitee.ltd/lxh/logger/log"
|
||||
"wireguard-dashboard/client"
|
||||
)
|
||||
|
||||
type network struct{}
|
||||
|
||||
func Network() network {
|
||||
return network{}
|
||||
}
|
||||
|
||||
// GetHostPublicIP
|
||||
// @description: 获取本机公网地址
|
||||
// @receiver network
|
||||
// @return string
|
||||
func (network) GetHostPublicIP() string {
|
||||
var response = map[string]string{}
|
||||
_, err := client.HttpClient.R().SetResult(&response).Get("https://httpbin.org/ip")
|
||||
if err != nil {
|
||||
log.Errorf("获取本机公网IP失败: %v", err.Error())
|
||||
return ""
|
||||
}
|
||||
|
||||
return response["origin"]
|
||||
}
|
||||
Reference in New Issue
Block a user