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