mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Merge branch 'bug40378' into 'main'
resolve host to IP to check if it's local before connecting See merge request tpo/anti-censorship/pluggable-transports/snowflake!413
This commit is contained in:
commit
b882d9456b
3 changed files with 49 additions and 6 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"net/http"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/pion/ice/v4"
|
||||
"github.com/pion/sdp/v3"
|
||||
|
@ -171,3 +172,22 @@ func GetCandidateAddrs(sdpStr string) []net.IP {
|
|||
}
|
||||
return sortedIpAddr
|
||||
}
|
||||
|
||||
// Checks whether the hostname is local
|
||||
func IsHostnameLocal(hostname string) bool {
|
||||
// Per https://en.wikipedia.org/wiki/Special-use_domain_name
|
||||
tlds := []string{
|
||||
".internal",
|
||||
".invalid",
|
||||
".local",
|
||||
".localhost",
|
||||
".onion",
|
||||
".test",
|
||||
}
|
||||
for _, tld := range tlds {
|
||||
if strings.HasSuffix(hostname, tld) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return hostname == "localhost"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue