mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-02-18 20:30:51 +08:00
fix(api): Enable management routes based on secret key presence
This commit is contained in:
@@ -394,10 +394,14 @@ func (s *Server) setupRoutes() {
|
|||||||
|
|
||||||
func (s *Server) managementAvailabilityMiddleware() gin.HandlerFunc {
|
func (s *Server) managementAvailabilityMiddleware() gin.HandlerFunc {
|
||||||
return func(c *gin.Context) {
|
return func(c *gin.Context) {
|
||||||
if !s.managementRoutesEnabled.Load() {
|
cfg := s.cfg
|
||||||
|
if cfg == nil || cfg.RemoteManagement.SecretKey == "" {
|
||||||
|
s.managementRoutesEnabled.Store(false)
|
||||||
c.AbortWithStatus(http.StatusNotFound)
|
c.AbortWithStatus(http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.managementRoutesEnabled.Store(true)
|
||||||
c.Next()
|
c.Next()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user