- Implement TCP client for watchdog service communication - Add watchdog configuration in config.json - Update main.go to initialize and connect to watchdog - Add watchdog related functions (connect, command handling) - Update README.md with new watchdog feature - Improve route setup logging in router.go
54 lines
2.2 KiB
Go
54 lines
2.2 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
"super-frpc/frpLogger"
|
|
"super-frpc/postLog"
|
|
)
|
|
|
|
func setupRoutes() {
|
|
http.HandleFunc("/system/getStatus", GetStatusHandler)
|
|
http.HandleFunc("/system/getSoftwareInfo", GetSoftwareInfoHandler)
|
|
systemLogHandler := postLog.NewLogSocketHandler(postLog.GetLogBroadcaster())
|
|
http.HandleFunc("/system/getLogs", systemLogHandler.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("/userMgr/modifyType", ModifyUserTypeHandler)
|
|
|
|
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/instanceMgr/start", StartInstanceHandler)
|
|
http.HandleFunc("/frpcAct/instanceMgr/stop", StopInstanceHandler)
|
|
http.HandleFunc("/frpcAct/instanceMgr/restart", RestartInstanceHandler)
|
|
http.HandleFunc("/frpcAct/instanceMgr/status", GetInstanceStatusHandler)
|
|
http.HandleFunc("/frpcAct/instanceMgr/getInfo", GetInstanceInfoHandler)
|
|
http.HandleFunc("/frpcAct/instanceMgr/logs", frpLogger.NewInstanceLogHandler(ValidateTokenFromMap).ServeHTTP)
|
|
http.HandleFunc("/frpcAct/proxyMgr/create", CreateProxyHandler)
|
|
http.HandleFunc("/frpcAct/proxyMgr/modify", ModifyProxyHandler)
|
|
http.HandleFunc("/frpcAct/proxyMgr/delete", DeleteProxyHandler)
|
|
http.HandleFunc("/frpcAct/proxyMgr/list", ListProxiesHandler)
|
|
|
|
http.HandleFunc("/", NotFoundHandler)
|
|
|
|
postLog.Info("Routes setup successfully")
|
|
|
|
}
|
|
|
|
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")
|
|
}
|