!121 fix: rdp ssh

* fix: rdp ssh
This commit is contained in:
zongyangleo
2024-05-21 04:06:13 +00:00
committed by Coder慌
parent c4cb4234fd
commit a7632fbf58
5 changed files with 47 additions and 19 deletions

View File

@@ -3,6 +3,7 @@ package netx
import (
"mayfly-go/pkg/logx"
"net"
"strings"
"github.com/lionsoul2014/ip2region/binding/golang/xdb"
)
@@ -68,3 +69,13 @@ func Ip2Region(ip string) string {
}
return region
}
func GetOutBoundIP() string {
conn, err := net.Dial("udp", "8.8.8.8:53")
if err != nil {
return "0.0.0.0"
}
localAddr := conn.LocalAddr().(*net.UDPAddr)
ip := strings.Split(localAddr.String(), ":")[0]
return ip
}

View File

@@ -0,0 +1,10 @@
package netx
import (
"fmt"
"testing"
)
func TestIp(t *testing.T) {
fmt.Println(GetOutBoundIP())
}