1
0

Prefix replaced by Suffix. Added NetworkType().

This commit is contained in:
Alexander Andreev 2022-02-07 04:48:00 +04:00
parent c5e9b48de7
commit db361bb509
Signed by: Arav
GPG Key ID: 1327FE8A374CC86F

View File

@ -4,11 +4,23 @@ import "strings"
// MainSite returns homepage address depending on network used.
func MainSite(host string) string {
if strings.HasPrefix(host, "i2p") {
if strings.HasSuffix(host, "i2p") {
return "http://arav.i2p"
} else if strings.HasPrefix(host, "onion") {
} else if strings.HasSuffix(host, "onion") {
return "http://.onion"
}
return "https://arav.top"
}
// 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"
} else {
return "www"
}
}