diff --git a/pkg/utils/dwelling.go b/pkg/utils/dwelling.go index 3547f93..5a9f6f6 100644 --- a/pkg/utils/dwelling.go +++ b/pkg/utils/dwelling.go @@ -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" + } +}