mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-27 19:41:11 +01:00
refactor: introduce Pool interface, move agent_pool to agent module
This commit is contained in:
16
agent/pkg/agent/agents.go
Normal file
16
agent/pkg/agent/agents.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"github.com/yusing/go-proxy/internal/utils/pool"
|
||||
)
|
||||
|
||||
type agents struct{ pool.Pool[*AgentConfig] }
|
||||
|
||||
var Agents = agents{pool.New[*AgentConfig]()}
|
||||
|
||||
func (agents agents) Get(agentAddrOrDockerHost string) (*AgentConfig, bool) {
|
||||
if !IsDockerHostAgent(agentAddrOrDockerHost) {
|
||||
return agents.Base().Load(agentAddrOrDockerHost)
|
||||
}
|
||||
return agents.Base().Load(GetAgentAddrFromDockerHost(agentAddrOrDockerHost))
|
||||
}
|
||||
@@ -4,9 +4,9 @@ import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"encoding/json"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -16,7 +16,6 @@ import (
|
||||
"github.com/yusing/go-proxy/internal/gperr"
|
||||
"github.com/yusing/go-proxy/internal/logging"
|
||||
"github.com/yusing/go-proxy/internal/net/gphttp"
|
||||
"github.com/yusing/go-proxy/internal/net/types"
|
||||
"github.com/yusing/go-proxy/pkg"
|
||||
)
|
||||
|
||||
@@ -49,8 +48,8 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
AgentURL = types.MustParseURL(APIBaseURL)
|
||||
HTTPProxyURL = types.MustParseURL(APIBaseURL + EndpointProxyHTTP)
|
||||
AgentURL, _ = url.Parse(APIBaseURL)
|
||||
HTTPProxyURL, _ = url.Parse(APIBaseURL + EndpointProxyHTTP)
|
||||
HTTPProxyURLPrefixLen = len(APIEndpointBase + EndpointProxyHTTP)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user