fix(proxy): add "oldName" && "newName" paras to fix unable to modify proxy name
This commit is contained in:
+12
-4
@@ -10,8 +10,8 @@ import (
|
||||
|
||||
"super-frpc/config"
|
||||
"super-frpc/database"
|
||||
"super-frpc/utils"
|
||||
"super-frpc/postLog"
|
||||
"super-frpc/utils"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
)
|
||||
@@ -149,6 +149,8 @@ func ModifyProxyHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
proxyInfo := config.FrpcProxyInfo{
|
||||
OldName: getStringFromMap(proxyInfoMap, "oldName"),
|
||||
NewName: getStringFromMap(proxyInfoMap, "newName"),
|
||||
Name: getStringFromMap(proxyInfoMap, "name"),
|
||||
Type: getStringFromMap(proxyInfoMap, "type"),
|
||||
LocalIP: getStringFromMap(proxyInfoMap, "localIP"),
|
||||
@@ -156,7 +158,13 @@ func ModifyProxyHandler(w http.ResponseWriter, r *http.Request) {
|
||||
RemotePort: getNumFromMap(proxyInfoMap, "remotePort"),
|
||||
}
|
||||
|
||||
if proxyInfo.Name == "" || proxyInfo.Type == "" || proxyInfo.LocalIP == "" ||
|
||||
if proxyInfo.OldName == "" {
|
||||
postLog.Error("[ModifyProxyHandler] oldName is required")
|
||||
utils.SendErrorResponse(w, http.StatusBadRequest, "oldName is required")
|
||||
return
|
||||
}
|
||||
|
||||
if proxyInfo.NewName == "" || proxyInfo.Type == "" || proxyInfo.LocalIP == "" ||
|
||||
proxyInfo.LocalPort == 0 || proxyInfo.RemotePort == 0 {
|
||||
postLog.Error("[ModifyProxyHandler] Missing required fields in proxyInfo")
|
||||
utils.SendErrorResponse(w, http.StatusBadRequest, "Missing required fields in proxyInfo")
|
||||
@@ -201,9 +209,9 @@ func ModifyProxyHandler(w http.ResponseWriter, r *http.Request) {
|
||||
utils.SendSuccessResponse(w, "Proxy modified successfully", map[string]interface{}{
|
||||
"instanceID": instance.ID,
|
||||
"configPath": instance.ConfigPath,
|
||||
"proxyName": proxyInfo.Name,
|
||||
"proxyName": proxyInfo.NewName,
|
||||
})
|
||||
postLog.Info(fmt.Sprintf("[ModifyProxyHandler] Proxy %s modified successfully for instance %d", proxyInfo.Name, instance.ID))
|
||||
postLog.Info(fmt.Sprintf("[ModifyProxyHandler] Proxy %s modified successfully for instance %d", proxyInfo.NewName, instance.ID))
|
||||
}
|
||||
|
||||
func DeleteProxyHandler(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
Reference in New Issue
Block a user