mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-08-07 13:48:29 +02:00
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:
@@ -814,3 +814,34 @@ func HandleIncomingPortSet(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
utils.SendOK(w)
|
||||
}
|
||||
|
||||
// Handle list of root route options
|
||||
func HandleRootRouteOptionList(w http.ResponseWriter, r *http.Request) {
|
||||
js, _ := json.Marshal(dynamicProxyRouter.RootRoutingOptions)
|
||||
utils.SendJSONResponse(w, string(js))
|
||||
}
|
||||
|
||||
// Handle update of the root route edge case options. See dynamicproxy/rootRoute.go
|
||||
func HandleRootRouteOptionsUpdate(w http.ResponseWriter, r *http.Request) {
|
||||
enableUnsetSubdomainRedirect, err := utils.PostBool(r, "unsetRedirect")
|
||||
if err != nil {
|
||||
utils.SendErrorResponse(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
unsetRedirectTarget, _ := utils.PostPara(r, "unsetRedirectTarget")
|
||||
|
||||
newRootOption := dynamicproxy.RootRoutingOptions{
|
||||
EnableRedirectForUnsetRules: enableUnsetSubdomainRedirect,
|
||||
UnsetRuleRedirectTarget: unsetRedirectTarget,
|
||||
}
|
||||
|
||||
dynamicProxyRouter.RootRoutingOptions = &newRootOption
|
||||
err = newRootOption.SaveToFile()
|
||||
if err != nil {
|
||||
utils.SendErrorResponse(w, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
utils.SendOK(w)
|
||||
}
|
||||
|
Reference in New Issue
Block a user