Подготовить HY2XS к production-сборке
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hy2xs-admin/controller"
|
||||
)
|
||||
|
||||
func initAccountAdminRouter(accountApi *gin.RouterGroup) {
|
||||
account := accountApi.Group("/account")
|
||||
{
|
||||
account.GET("/pageAccount", controller.PageAccount)
|
||||
account.POST("/saveAccount", controller.SaveAccount)
|
||||
account.POST("/deleteAccount", controller.DeleteAccount)
|
||||
account.POST("/updateAccount", controller.UpdateAccount)
|
||||
account.POST("/resetTraffic", controller.ResetTraffic)
|
||||
account.GET("/getAccountInfo", controller.GetAccountInfo)
|
||||
account.GET("/getAccount", controller.GetAccount)
|
||||
account.POST("/importAccount", controller.ImportAccount)
|
||||
account.POST("/exportAccount", controller.ExportAccount)
|
||||
account.POST("/releaseKickAccount", controller.ReleaseKickAccount)
|
||||
account.GET("/verifyDefaultPass", controller.VerifyDefaultPass)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hy2xs-admin/controller"
|
||||
)
|
||||
|
||||
func initAuthRouter(authApi *gin.RouterGroup) {
|
||||
auth := authApi.Group("/auth")
|
||||
{
|
||||
auth.POST("/login", controller.Login)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hy2xs-admin/controller"
|
||||
)
|
||||
|
||||
func initConfigRouter(configApi *gin.RouterGroup) {
|
||||
config := configApi.Group("/config")
|
||||
{
|
||||
config.POST("/updateConfigs", controller.UpdateConfigs)
|
||||
config.GET("/getConfig", controller.GetConfig)
|
||||
config.POST("/listConfig", controller.ListConfig)
|
||||
config.GET("/getHysteria2Config", controller.GetHysteria2Config)
|
||||
config.POST("/updateHysteria2Config", controller.UpdateHysteria2Config)
|
||||
config.POST("/exportHysteria2Config", controller.ExportHysteria2Config)
|
||||
config.POST("/importHysteria2Config", controller.ImportHysteria2Config)
|
||||
config.POST("/exportConfig", controller.ExportConfig)
|
||||
config.POST("/importConfig", controller.ImportConfig)
|
||||
config.GET("/hysteria2AcmePath", controller.Hysteria2AcmePath)
|
||||
config.POST("/restartServer", controller.RestartServer)
|
||||
config.POST("/uploadCertFile", controller.UploadCertFile)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hy2xs-admin/controller"
|
||||
)
|
||||
|
||||
func initHysteria2AuthRouter(hysteria2Api *gin.RouterGroup) {
|
||||
hysteria2 := hysteria2Api.Group("/hysteria2")
|
||||
{
|
||||
hysteria2.POST("/auth", controller.Hysteria2Auth)
|
||||
|
||||
}
|
||||
hysteria2Api.GET("/:conPass", controller.Hysteria2Subscribe)
|
||||
}
|
||||
|
||||
func initHysteria2Router(hysteria2Api *gin.RouterGroup) {
|
||||
hysteria2 := hysteria2Api.Group("/hysteria2")
|
||||
{
|
||||
hysteria2.POST("/hysteria2Kick", controller.Hysteria2Kick)
|
||||
hysteria2.POST("/hysteria2ChangeVersion", controller.Hysteria2ChangeVersion)
|
||||
hysteria2.GET("/listRelease", controller.ListRelease)
|
||||
hysteria2.GET("/hysteria2SubscribeUrl", controller.Hysteria2SubscribeUrl)
|
||||
hysteria2.GET("/hysteria2Url", controller.Hysteria2Url)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hy2xs-admin/controller"
|
||||
)
|
||||
|
||||
func initLogRouter(accountApi *gin.RouterGroup) {
|
||||
account := accountApi.Group("/log")
|
||||
{
|
||||
account.GET("/logSystem", controller.LogSystem)
|
||||
account.GET("/logHysteria2", controller.LogHysteria2)
|
||||
account.POST("/exportLog", controller.ExportLog)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hy2xs-admin/controller"
|
||||
)
|
||||
|
||||
func initMonitorRouter(accountApi *gin.RouterGroup) {
|
||||
account := accountApi.Group("/monitor")
|
||||
{
|
||||
account.GET("/monitorSystem", controller.MonitorSystem)
|
||||
account.GET("/monitorHysteria2", controller.MonitorHysteria2)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"hy2xs-admin/frontend"
|
||||
"hy2xs-admin/middleware"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Router(router *gin.Engine, huiWebContext *string) {
|
||||
// global context
|
||||
relativePath := "/"
|
||||
if huiWebContext != nil && strings.HasPrefix(*huiWebContext, "/") {
|
||||
relativePath = *huiWebContext
|
||||
}
|
||||
globalGroup := router.Group(relativePath)
|
||||
{
|
||||
globalGroup.Use(middleware.FilterHandler(), middleware.LogHandler(), middleware.RateLimiterHandler())
|
||||
|
||||
frontend.InitFrontend(router, relativePath)
|
||||
|
||||
authApi := globalGroup.Group("/hui")
|
||||
{
|
||||
initAuthRouter(authApi)
|
||||
initHysteria2AuthRouter(authApi)
|
||||
}
|
||||
|
||||
globalGroup.Use(middleware.JWTHandler())
|
||||
|
||||
globalGroup.Use(middleware.AdminHandler())
|
||||
|
||||
huiAdminApi := globalGroup.Group("/hui")
|
||||
{
|
||||
initAccountAdminRouter(huiAdminApi)
|
||||
initConfigRouter(huiAdminApi)
|
||||
initHysteria2Router(huiAdminApi)
|
||||
initLogRouter(huiAdminApi)
|
||||
initMonitorRouter(huiAdminApi)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user