1
0

Made full use of Service* constants in util.

This commit is contained in:
Alexander Andreev 2024-04-20 05:06:28 +04:00
parent f9dabbc6f9
commit 2667ec93ce
Signed by: Arav
GPG Key ID: 25969B23DCB5CA34
3 changed files with 21 additions and 21 deletions

View File

@ -42,9 +42,9 @@ func (h *Handlers) Index(w http.ResponseWriter, r *http.Request) {
func (h *Handlers) Privacy(w http.ResponseWriter, r *http.Request) { func (h *Handlers) Privacy(w http.ResponseWriter, r *http.Request) {
web.Privacy("/ Privacy statements", web.Privacy("/ Privacy statements",
util.GetServiceByHost(r.Host, "radio"), util.GetServiceByHost(r.Host, util.ServiceRadio),
util.GetServiceByHost(r.Host, "files"), util.GetServiceByHost(r.Host, util.ServiceRadio),
util.GetServiceByHost(r.Host, "upload"), w) util.GetServiceByHost(r.Host, util.ServiceUpload), w)
} }
func (h *Handlers) Stuff(w http.ResponseWriter, r *http.Request) { func (h *Handlers) Stuff(w http.ResponseWriter, r *http.Request) {

View File

@ -56,10 +56,10 @@ func (p *Post) PostURL(host string, rss bool) string {
return strings.Replace(p.URL, p.URL[:lastColon+2], return strings.Replace(p.URL, p.URL[:lastColon+2],
util.GetServiceByHost(host, service), 1) util.GetServiceByHost(host, service), 1)
} else if rss && p.URL[0] == '/' { } else if rss && p.URL[0] == '/' {
return util.GetServiceByHost(host, "") + p.URL return util.GetServiceByHost(host, util.ServiceHome) + p.URL
} }
} else if p.URL == "" && rss { } else if p.URL == "" && rss {
return util.GetServiceByHost(host, "") + "/mindflow#" + p.PostID() return util.GetServiceByHost(host, util.ServiceHome) + "/mindflow#" + p.PostID()
} }
return p.URL return p.URL
} }

View File

@ -19,52 +19,52 @@ const (
func GetServiceByHost(host, service string) string { func GetServiceByHost(host, service string) string {
if strings.HasSuffix(host, "i2p") { if strings.HasSuffix(host, "i2p") {
switch service { switch service {
case "radio": case ServiceRadio:
return "http://radio.arav.i2p" return "http://radio.arav.i2p"
case "files": case ServiceFiles:
return "http://files.arav.i2p" return "http://files.arav.i2p"
case "upload": case ServiceUpload:
return "http://upload.arav.i2p" return "http://upload.arav.i2p"
case "git": case ServiceGit:
return "http://git.arav.i2p" return "http://git.arav.i2p"
default: default:
return "http://arav.i2p" return "http://arav.i2p"
} }
} else if strings.HasPrefix(host, "[300") { } else if strings.HasPrefix(host, "[300") {
switch service { switch service {
case "radio": case ServiceRadio:
return "http://[300:a98d:d6d0:8a08::e]" return "http://[300:a98d:d6d0:8a08::e]"
case "files": case ServiceFiles:
return "http://[300:a98d:d6d0:8a08::d]" return "http://[300:a98d:d6d0:8a08::d]"
case "upload": case ServiceUpload:
return "http://[300:a98d:d6d0:8a08::c]" return "http://[300:a98d:d6d0:8a08::c]"
case "git": case ServiceGit:
return "http://[300:a98d:d6d0:8a08::b]" return "http://[300:a98d:d6d0:8a08::b]"
default: default:
return "http://[300:a98d:d6d0:8a08::f]" return "http://[300:a98d:d6d0:8a08::f]"
} }
} else if strings.HasSuffix(host, "onion") { } else if strings.HasSuffix(host, "onion") {
switch service { switch service {
case "radio": case ServiceRadio:
return "http://wsmkgnmhmzqm7kyzv7jnzzafvgm7xlmlfvzhgorpapd5or2arnhuktqd.onion" return "http://wsmkgnmhmzqm7kyzv7jnzzafvgm7xlmlfvzhgorpapd5or2arnhuktqd.onion"
case "files": case ServiceFiles:
return "http://qf5e43nlhvnrutmikuvbdfj3cmtthokpbaxtkm6mjlslttzvtgm4fxid.onion" return "http://qf5e43nlhvnrutmikuvbdfj3cmtthokpbaxtkm6mjlslttzvtgm4fxid.onion"
case "upload": case ServiceUpload:
return "http://4usftbmjpfexkr2x5xbp5ukmygpmg4fgrnx2wbifsexqctooz5hmviyd.onion" return "http://4usftbmjpfexkr2x5xbp5ukmygpmg4fgrnx2wbifsexqctooz5hmviyd.onion"
case "git": case ServiceGit:
return "http://qqitm7qlsbbubwmjos4cqzmvkqidg34rfnbyhuydhalep33fbvh22xyd.onion" return "http://qqitm7qlsbbubwmjos4cqzmvkqidg34rfnbyhuydhalep33fbvh22xyd.onion"
default: default:
return "http://moq7aejnf4xk5k2bkaltli3ftkhusy2mbrd3pj23nrca343ku2mgk4yd.onion" return "http://moq7aejnf4xk5k2bkaltli3ftkhusy2mbrd3pj23nrca343ku2mgk4yd.onion"
} }
} else { } else {
switch service { switch service {
case "radio": case ServiceRadio:
return "https://radio.arav.su" return "https://radio.arav.su"
case "files": case ServiceFiles:
return "https://files.arav.su" return "https://files.arav.su"
case "upload": case ServiceUpload:
return "https://upload.arav.su" return "https://upload.arav.su"
case "git": case ServiceGit:
return "https://git.arav.su" return "https://git.arav.su"
default: default:
return "https://arav.su" return "https://arav.su"