mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
move IsHostnameLocal to common/util
This commit is contained in:
parent
6fef2caaa8
commit
990d165937
2 changed files with 21 additions and 20 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"net/http"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/pion/ice/v2"
|
||||
"github.com/pion/sdp/v3"
|
||||
|
@ -165,3 +166,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