noauth을 때 사설 IP대역만 허용
This commit is contained in:
@ -430,6 +430,23 @@ func whitelistKey(email string) string {
|
||||
|
||||
return email
|
||||
}
|
||||
func isPrivateIP(ip net.IP) bool {
|
||||
if ip[0] == 10 {
|
||||
return true
|
||||
}
|
||||
|
||||
if ip[0] == 172 {
|
||||
if ip[1] >= 16 && ip[1] < 32 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
if ip[0] == 192 && ip[1] == 168 {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMux, prefix string) error {
|
||||
var allServices []*serviceDescription
|
||||
@ -443,7 +460,7 @@ func (mg *Maingate) RegisterHandlers(ctx context.Context, serveMux *http.ServeMu
|
||||
ipaddr := "127.0.0.1"
|
||||
for _, addr := range addrs {
|
||||
if ipnet, ok := addr.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
|
||||
if ipnet.IP.To4() != nil {
|
||||
if ipnet.IP.To4() != nil && ipnet.IP.IsPrivate() {
|
||||
ipaddr = ipnet.IP.String()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user