Host can have :port attached, so it is better to check if string contains rather ends with a particular TLD.
This commit is contained in:
parent
7b5b9a7ce8
commit
ffe60bae85
@ -4,9 +4,9 @@ import "strings"
|
||||
|
||||
// MainSite returns homepage address depending on network used.
|
||||
func MainSite(host string) string {
|
||||
if strings.HasSuffix(host, "i2p") {
|
||||
if strings.Contains(host, "i2p") {
|
||||
return "http://arav.i2p"
|
||||
} else if strings.HasSuffix(host, "onion") {
|
||||
} else if strings.Contains(host, "onion") {
|
||||
return "http://.onion"
|
||||
}
|
||||
|
||||
@ -15,12 +15,12 @@ func MainSite(host string) string {
|
||||
|
||||
// NetworkType detects network based on host suffix,
|
||||
// whether client connected from Tor, I2P or Clearnet.
|
||||
func NetworkType(host string) string {
|
||||
if strings.HasSuffix(host, "i2p") {
|
||||
return "i2p"
|
||||
} else if strings.HasSuffix(host, "onion") {
|
||||
return "tor"
|
||||
func NetworkType(host string) (string, string) {
|
||||
if strings.Contains(host, "i2p") {
|
||||
return "i2p", "http"
|
||||
} else if strings.Contains(host, "onion") {
|
||||
return "tor", "http"
|
||||
} else {
|
||||
return "www"
|
||||
return "www", "https"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user