2022-02-06 15:23:32 +04:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import "strings"
|
|
|
|
|
|
|
|
// MainSite returns homepage address depending on network used.
|
|
|
|
func MainSite(host string) string {
|
2022-02-07 04:48:00 +04:00
|
|
|
if strings.HasSuffix(host, "i2p") {
|
2022-02-06 15:23:32 +04:00
|
|
|
return "http://arav.i2p"
|
2022-02-07 04:48:00 +04:00
|
|
|
} else if strings.HasSuffix(host, "onion") {
|
2022-02-06 15:23:32 +04:00
|
|
|
return "http://.onion"
|
|
|
|
}
|
|
|
|
|
|
|
|
return "https://arav.top"
|
|
|
|
}
|
2022-02-07 04:48:00 +04:00
|
|
|
|
|
|
|
// 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"
|
|
|
|
}
|
|
|
|
}
|