2022-06-27 04:38:09 +04:00
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
// 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") {
|
|
|
|
return "http://moq7aejnf4xk5k2bkaltli3ftkhusy2mbrd3pj23nrca343ku2mgk4yd.onion"
|
2022-08-01 01:16:26 +04:00
|
|
|
} else if strings.HasPrefix(host, "[300") {
|
|
|
|
return "http://[300:a98d:d6d0:8a08::f]"
|
2022-06-27 04:38:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return "https://arav.top"
|
|
|
|
}
|
|
|
|
|
|
|
|
// ToClientTimezone converts given time to timezone set in a
|
|
|
|
// X-Client-Timezone header. If this header is not set, then
|
|
|
|
// converts to UTC.
|
|
|
|
func ToClientTimezone(t time.Time, r *http.Request) time.Time {
|
|
|
|
if tz := r.Header.Get("X-Client-Timezone"); tz != "" {
|
|
|
|
loc, err := time.LoadLocation(tz)
|
|
|
|
if err != nil {
|
|
|
|
return t.UTC()
|
|
|
|
}
|
|
|
|
return t.In(loc)
|
|
|
|
}
|
|
|
|
|
|
|
|
return t.UTC()
|
|
|
|
}
|