Optimized memory usage and root routing

+ Added unset subdomain custom redirection feature #46
+ Optimized memory usage by space time tradeoff in geoip lookup to fix #52
+ Replaced all stori/go.uuid to google/uuid for security reasons #55
This commit is contained in:
Toby Chui
2023-08-27 10:18:49 +08:00
parent 4f7f60188f
commit 73ab9ca778
22 changed files with 9701 additions and 212 deletions

View File

@@ -335,3 +335,20 @@ func HandleZoraxyInfo(w http.ResponseWriter, r *http.Request) {
js, _ := json.MarshalIndent(info, "", " ")
utils.SendJSONResponse(w, string(js))
}
func HandleGeoIpLookup(w http.ResponseWriter, r *http.Request) {
ip, err := utils.GetPara(r, "ip")
if err != nil {
utils.SendErrorResponse(w, "ip not given")
return
}
cc, err := geodbStore.ResolveCountryCodeFromIP(ip)
if err != nil {
utils.SendErrorResponse(w, err.Error())
return
}
js, _ := json.Marshal(cc)
utils.SendJSONResponse(w, string(js))
}