2022-03-08 01:17:24 +04:00
|
|
|
package utils
|
|
|
|
|
2022-03-31 02:54:04 +04:00
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
)
|
2022-03-08 01:17:24 +04:00
|
|
|
|
|
|
|
// 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"
|
|
|
|
}
|
|
|
|
|
|
|
|
return "https://arav.top"
|
|
|
|
}
|
2022-03-31 02:54:04 +04:00
|
|
|
|
|
|
|
// 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 != "" {
|
2022-04-02 04:30:46 +04:00
|
|
|
if loc, err := time.LoadLocation(tz); err == nil {
|
|
|
|
return t.In(loc)
|
2022-03-31 02:54:04 +04:00
|
|
|
}
|
|
|
|
}
|
2022-03-31 18:22:20 +04:00
|
|
|
return t.UTC()
|
2022-03-31 02:54:04 +04:00
|
|
|
}
|