diff --git a/internal/api/v1/route/route.go b/internal/api/v1/route/route.go index d3171896..38d5a0e1 100644 --- a/internal/api/v1/route/route.go +++ b/internal/api/v1/route/route.go @@ -5,6 +5,7 @@ import ( "github.com/gin-gonic/gin" apitypes "github.com/yusing/go-proxy/internal/api/types" + config "github.com/yusing/go-proxy/internal/config/types" "github.com/yusing/go-proxy/internal/route/routes" ) @@ -35,7 +36,14 @@ func Route(c *gin.Context) { route, ok := routes.Get(request.Which) if ok { c.JSON(http.StatusOK, route) - } else { - c.JSON(http.StatusNotFound, nil) + return } + + // also search for excluded routes + route = config.GetInstance().SearchRoute(request.Which) + if route != nil { + c.JSON(http.StatusOK, route) + return + } + c.JSON(http.StatusNotFound, nil) } diff --git a/internal/config/query.go b/internal/config/query.go index e940df94..1851304e 100644 --- a/internal/config/query.go +++ b/internal/config/query.go @@ -25,6 +25,15 @@ func (cfg *Config) RouteProviderList() []config.RouteProviderListResponse { return list } +func (cfg *Config) SearchRoute(alias string) types.Route { + for _, p := range cfg.providers.Range { + if r, ok := p.GetRoute(alias); ok { + return r + } + } + return nil +} + func (cfg *Config) Statistics() map[string]any { var rps, streams types.RouteStats var total uint16 diff --git a/internal/config/types/config.go b/internal/config/types/config.go index 9b142799..0396bf69 100644 --- a/internal/config/types/config.go +++ b/internal/config/types/config.go @@ -15,6 +15,7 @@ import ( "github.com/yusing/go-proxy/internal/notif" "github.com/yusing/go-proxy/internal/proxmox" "github.com/yusing/go-proxy/internal/serialization" + "github.com/yusing/go-proxy/internal/types" ) type ( @@ -51,6 +52,7 @@ type ( Reload() gperr.Error Statistics() map[string]any RouteProviderList() []RouteProviderListResponse + SearchRoute(alias string) types.Route Context() context.Context VerifyNewAgent(host string, ca agent.PEMPair, client agent.PEMPair, containerRuntime agent.ContainerRuntime) (int, gperr.Error) AutoCertProvider() *autocert.Provider