fix: seperate port

This commit is contained in:
minoplhy 2024-04-11 22:15:33 +07:00
parent b5dfbf5395
commit 2650a8c31f
Signed by: minoplhy
GPG Key ID: 41D406044E2434BF

View File

@ -1,8 +1,15 @@
package handler package handler
import "net" import (
"net"
"strings"
)
func IsInternalIP(ip string) bool { func IsInternalIP(ip string) bool {
parts := strings.Split(ip, ":")
ip = parts[0]
// Parse the IP address // Parse the IP address
ipAddress := net.ParseIP(ip) ipAddress := net.ParseIP(ip)
if ipAddress == nil { if ipAddress == nil {
@ -18,7 +25,7 @@ func IsInternalIP(ip string) bool {
for _, internalRange := range internalRanges { for _, internalRange := range internalRanges {
_, ipNet, err := net.ParseCIDR(internalRange) _, ipNet, err := net.ParseCIDR(internalRange)
if err != nil { if err != nil {
return false continue
} }
if ipNet.Contains(ipAddress) { if ipNet.Contains(ipAddress) {