feat(routes): enhance route retrieval with search functionality

- Added SearchRoute method to Config for searching routes by alias.
- Updated Route function to check for excluded routes if the initial lookup fails, returning the found route or a 404 status accordingly.
This commit is contained in:
yusing
2025-09-13 23:58:38 +08:00
parent 1e9303b1ef
commit ef65481394
3 changed files with 21 additions and 2 deletions

View File

@@ -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

View File

@@ -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