fix various endpoints

This commit is contained in:
yusing
2025-02-13 15:05:16 +08:00
parent 02d1c9ce98
commit decd2c2ded
9 changed files with 39 additions and 51 deletions

View File

@@ -1,8 +1,6 @@
package config
import (
"errors"
"github.com/yusing/go-proxy/agent/pkg/agent"
"github.com/yusing/go-proxy/internal/utils/functional"
)
@@ -22,11 +20,11 @@ func GetAgent(addr string) (agent *agent.AgentConfig, ok bool) {
return
}
func (cfg *Config) GetAgent(agentDockerHost string) (*agent.AgentConfig, bool) {
if !agent.IsDockerHostAgent(agentDockerHost) {
panic(errors.New("invalid use of GetAgent with docker host: " + agentDockerHost))
func (cfg *Config) GetAgent(agentAddrOrDockerHost string) (*agent.AgentConfig, bool) {
if !agent.IsDockerHostAgent(agentAddrOrDockerHost) {
return GetAgent(agentAddrOrDockerHost)
}
return GetAgent(agent.GetAgentAddrFromDockerHost(agentDockerHost))
return GetAgent(agent.GetAgentAddrFromDockerHost(agentAddrOrDockerHost))
}
func (cfg *Config) ListAgents() []*agent.AgentConfig {

View File

@@ -41,7 +41,7 @@ type (
Statistics() map[string]any
RouteProviderList() []string
Context() context.Context
GetAgent(agentDockerHost string) (*agent.AgentConfig, bool)
GetAgent(agentAddrOrDockerHost string) (*agent.AgentConfig, bool)
ListAgents() []*agent.AgentConfig
}
)