mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 11:11:30 -04:00
Move IP check
This commit is contained in:
parent
990d165937
commit
f1e9f58b47
1 changed files with 10 additions and 11 deletions
|
@ -674,15 +674,6 @@ func checkIsRelayURLAcceptable(
|
|||
if util.IsHostnameLocal(hostname) {
|
||||
return fmt.Errorf("rejected Relay URL: private hostnames are not allowed")
|
||||
}
|
||||
ipArray, err := net.LookupIP(hostname)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Could not look up IP")
|
||||
}
|
||||
for _, ip := range ipArray {
|
||||
if !isRemoteAddress(ip) {
|
||||
return fmt.Errorf("rejected Relay URL: private IPs are not allowed")
|
||||
}
|
||||
}
|
||||
ip := net.ParseIP(hostname)
|
||||
// Otherwise it's a domain name, or an invalid IP.
|
||||
if ip != nil {
|
||||
|
@ -691,8 +682,16 @@ func checkIsRelayURLAcceptable(
|
|||
return fmt.Errorf("rejected Relay URL: private IPs are not allowed")
|
||||
}
|
||||
} else {
|
||||
// move net.LookupIP(hostname) and isRemoteAddress checks here
|
||||
}
|
||||
ipArray, err := net.LookupIP(hostname)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Could not look up IP")
|
||||
}
|
||||
for _, ip := range ipArray {
|
||||
if !isRemoteAddress(ip) {
|
||||
return fmt.Errorf("rejected Relay URL: private IPs are not allowed")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if !allowNonTLSRelay && parsedRelayURL.Scheme != "wss" {
|
||||
return fmt.Errorf("rejected Relay URL protocol: non-TLS not allowed")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue