mirror of
https://github.com/nestriness/nestri.git
synced 2025-12-12 08:45:38 +02:00
fix(relay): Use built-in method for checking private IP
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
|||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/pion/webrtc/v4"
|
"github.com/pion/webrtc/v4"
|
||||||
)
|
)
|
||||||
@@ -126,13 +125,7 @@ func getLocalIP() string {
|
|||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
for _, address := range addrs {
|
for _, address := range addrs {
|
||||||
// Skip IPs starting with 10 or below, as might be private or internal network
|
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() && !ipnet.IP.IsPrivate() && !ipnet.IP.IsUnspecified() {
|
||||||
for i := 0; i < 11; i++ {
|
|
||||||
if strings.HasPrefix(address.String(), strconv.Itoa(i)) {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
|
|
||||||
if ipnet.IP.To4() != nil || ipnet.IP != nil {
|
if ipnet.IP.To4() != nil || ipnet.IP != nil {
|
||||||
return ipnet.IP.String()
|
return ipnet.IP.String()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user