refactor(frpc): replace ini with toml for config handling and improve proxy management
- Replace ini package with toml for more reliable config parsing - Refactor proxy management to use structured config instead of string manipulation - Add proper error handling for config operations - Clean up unused imports and improve code organization - Update go.mod dependencies accordingly
This commit is contained in:
84
router.go
84
router.go
@@ -1,42 +1,42 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"super-frpc/postLog"
|
||||
)
|
||||
|
||||
func setupRoutes() {
|
||||
postLog.Info("Setting up routes...")
|
||||
http.HandleFunc("/system/getStatus", GetStatusHandler)
|
||||
http.HandleFunc("/system/getSoftwareInfo", GetSoftwareInfoHandler)
|
||||
logHandler := postLog.NewLogSocketHandler(postLog.GetLogBroadcaster())
|
||||
http.HandleFunc("/system/getLogs", logHandler.Handle)
|
||||
|
||||
http.HandleFunc("/register", RegisterHandler)
|
||||
http.HandleFunc("/login", LoginHandler)
|
||||
http.HandleFunc("/logout", LogoutHandler)
|
||||
|
||||
http.HandleFunc("/userMgr/create", CreateUserHandler)
|
||||
http.HandleFunc("/userMgr/remove", RemoveUserHandler)
|
||||
http.HandleFunc("/userMgr/list", ListUserHandler)
|
||||
// http.HandleFunc("/userMgr/modify", ModifyUserHandler)
|
||||
|
||||
http.HandleFunc("/sessionMgr/list", ListActiveSessionsHandler)
|
||||
http.HandleFunc("/sessionMgr/remove", RemoveSessionHandler)
|
||||
|
||||
http.HandleFunc("/frpcAct/instanceMgr/create", CreateInstanceHandler)
|
||||
http.HandleFunc("/frpcAct/instanceMgr/delete", DeleteInstanceHandler)
|
||||
http.HandleFunc("/frpcAct/instanceMgr/modify", ModifyInstanceHandler)
|
||||
http.HandleFunc("/frpcAct/instanceMgr/list", ListInstancesHandler)
|
||||
http.HandleFunc("/frpcAct/proxyMgr/create", CreateProxyHandler)
|
||||
http.HandleFunc("/frpcAct/proxyMgr/delete", DeleteProxyHandler)
|
||||
|
||||
http.HandleFunc("/", NotFoundHandler)
|
||||
|
||||
}
|
||||
|
||||
func NotFoundHandler(w http.ResponseWriter, r *http.Request) {
|
||||
postLog.Error(fmt.Sprintf("Route not found: %s %s", r.Method, r.URL.Path))
|
||||
SendErrorResponse(w, http.StatusNotFound, "Invalid request path")
|
||||
}
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"super-frpc/postLog"
|
||||
)
|
||||
|
||||
func setupRoutes() {
|
||||
postLog.Info("Setting up routes...")
|
||||
http.HandleFunc("/system/getStatus", GetStatusHandler)
|
||||
http.HandleFunc("/system/getSoftwareInfo", GetSoftwareInfoHandler)
|
||||
logHandler := postLog.NewLogSocketHandler(postLog.GetLogBroadcaster())
|
||||
http.HandleFunc("/system/getLogs", logHandler.Handle)
|
||||
|
||||
http.HandleFunc("/register", RegisterHandler)
|
||||
http.HandleFunc("/login", LoginHandler)
|
||||
http.HandleFunc("/logout", LogoutHandler)
|
||||
|
||||
http.HandleFunc("/userMgr/create", CreateUserHandler)
|
||||
http.HandleFunc("/userMgr/remove", RemoveUserHandler)
|
||||
http.HandleFunc("/userMgr/list", ListUserHandler)
|
||||
// http.HandleFunc("/userMgr/modify", ModifyUserHandler)
|
||||
|
||||
http.HandleFunc("/sessionMgr/list", ListActiveSessionsHandler)
|
||||
http.HandleFunc("/sessionMgr/remove", RemoveSessionHandler)
|
||||
|
||||
http.HandleFunc("/frpcAct/instanceMgr/create", CreateInstanceHandler)
|
||||
http.HandleFunc("/frpcAct/instanceMgr/delete", DeleteInstanceHandler)
|
||||
http.HandleFunc("/frpcAct/instanceMgr/modify", ModifyInstanceHandler)
|
||||
http.HandleFunc("/frpcAct/instanceMgr/list", ListInstancesHandler)
|
||||
http.HandleFunc("/frpcAct/proxyMgr/create", CreateProxyHandler)
|
||||
http.HandleFunc("/frpcAct/proxyMgr/delete", DeleteProxyHandler)
|
||||
|
||||
http.HandleFunc("/", NotFoundHandler)
|
||||
|
||||
}
|
||||
|
||||
func NotFoundHandler(w http.ResponseWriter, r *http.Request) {
|
||||
postLog.Error(fmt.Sprintf("Route not found: %s %s", r.Method, r.URL.Path))
|
||||
SendErrorResponse(w, http.StatusNotFound, "Invalid request path")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user