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-08 19:00:37 +04:00
|
|
|
if strings.Contains(host, "i2p") {
|
2022-02-06 15:23:32 +04:00
|
|
|
return "http://arav.i2p"
|
2022-02-08 19:00:37 +04:00
|
|
|
} else if strings.Contains(host, "onion") {
|
2022-02-11 03:03:31 +04:00
|
|
|
return "http://moq7aejnf4xk5k2bkaltli3ftkhusy2mbrd3pj23nrca343ku2mgk4yd.onion"
|
2022-08-01 01:09:43 +04:00
|
|
|
} else if strings.HasPrefix(host, "[300") {
|
|
|
|
return "http://[300:a98d:d6d0:8a08::f]"
|
2022-02-06 15:23:32 +04:00
|
|
|
}
|
|
|
|
|
2023-02-23 18:16:06 +04:00
|
|
|
return "https://arav.su"
|
2022-02-06 15:23:32 +04:00
|
|
|
}
|
2022-02-07 04:48:00 +04:00
|
|
|
|
|
|
|
// NetworkType detects network based on host suffix,
|
|
|
|
// whether client connected from Tor, I2P or Clearnet.
|
2022-02-11 03:06:40 +04:00
|
|
|
// Holy shit, net/http/Response doesn't actually save
|
|
|
|
// a URL.Scheme and just spit out an empty string.
|
|
|
|
// What a shame.
|
2022-02-08 19:00:37 +04:00
|
|
|
func NetworkType(host string) (string, string) {
|
|
|
|
if strings.Contains(host, "i2p") {
|
|
|
|
return "i2p", "http"
|
|
|
|
} else if strings.Contains(host, "onion") {
|
|
|
|
return "tor", "http"
|
2023-08-06 01:59:25 +04:00
|
|
|
} else if strings.Contains(host, "[300:") {
|
|
|
|
return "ygg", "http"
|
2022-02-07 04:48:00 +04:00
|
|
|
} else {
|
2022-02-08 19:00:37 +04:00
|
|
|
return "www", "https"
|
2022-02-07 04:48:00 +04:00
|
|
|
}
|
|
|
|
}
|