Prefix replaced by Suffix. Added NetworkType().
This commit is contained in:
parent
c5e9b48de7
commit
db361bb509
@ -4,11 +4,23 @@ import "strings"
|
|||||||
|
|
||||||
// MainSite returns homepage address depending on network used.
|
// MainSite returns homepage address depending on network used.
|
||||||
func MainSite(host string) string {
|
func MainSite(host string) string {
|
||||||
if strings.HasPrefix(host, "i2p") {
|
if strings.HasSuffix(host, "i2p") {
|
||||||
return "http://arav.i2p"
|
return "http://arav.i2p"
|
||||||
} else if strings.HasPrefix(host, "onion") {
|
} else if strings.HasSuffix(host, "onion") {
|
||||||
return "http://.onion"
|
return "http://.onion"
|
||||||
}
|
}
|
||||||
|
|
||||||
return "https://arav.top"
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user