1
0
dwelling-upload/pkg/utils/dwelling.go

32 lines
888 B
Go
Raw Normal View History

package utils
import "strings"
// MainSite returns homepage address depending on network used.
func MainSite(host string) string {
if strings.Contains(host, "i2p") {
return "http://arav.i2p"
} else if strings.Contains(host, "onion") {
2022-02-11 03:03:31 +04:00
return "http://moq7aejnf4xk5k2bkaltli3ftkhusy2mbrd3pj23nrca343ku2mgk4yd.onion"
} else if strings.HasPrefix(host, "[300") {
return "http://[300:a98d:d6d0:8a08::f]"
}
return "https://arav.top"
}
// NetworkType detects network based on host suffix,
// whether client connected from Tor, I2P or Clearnet.
// Holy shit, net/http/Response doesn't actually save
// a URL.Scheme and just spit out an empty string.
// What a shame.
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", "https"
}
}