mirror of
https://github.com/minoplhy/chibisafe-netproxy.git
synced 2024-11-22 03:27:08 +00:00
fix: seperate port
This commit is contained in:
parent
b5dfbf5395
commit
2650a8c31f
@ -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) {
|
||||||
|
Loading…
Reference in New Issue
Block a user