mirror of
https://github.com/yusing/godoxy.git
synced 2026-03-21 00:29:03 +01:00
small fix
This commit is contained in:
@@ -136,7 +136,7 @@ func (p *Provider) getDockerProxyConfigs() ([]*ProxyConfig, error) {
|
||||
}
|
||||
clientHost = url.Host
|
||||
opts = []client.Opt{
|
||||
client.WithHost(clientHost),
|
||||
client.WithHost(p.Value),
|
||||
client.WithAPIVersionNegotiation(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,14 +56,14 @@ func (p *Provider) BuildStartRoutes() {
|
||||
|
||||
cfgs, err := p.GetProxyConfigs()
|
||||
if err != nil {
|
||||
p.Logf("Build", "unable to get proxy configs: %v", p.name, err)
|
||||
p.Logf("Build", "unable to get proxy configs: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
for _, cfg := range cfgs {
|
||||
r, err := NewRoute(cfg)
|
||||
if err != nil {
|
||||
p.Logf("Build", "error creating route %q: %v", p.name, cfg.Alias, err)
|
||||
p.Logf("Build", "error creating route %q: %v", cfg.Alias, err)
|
||||
continue
|
||||
}
|
||||
r.SetupListen()
|
||||
|
||||
@@ -19,12 +19,12 @@ import (
|
||||
)
|
||||
|
||||
type Utils struct {
|
||||
PortsInUse map[int]bool
|
||||
portsInUse map[int]bool
|
||||
portsInUseMutex sync.Mutex
|
||||
}
|
||||
|
||||
var utils = &Utils{
|
||||
PortsInUse: make(map[int]bool),
|
||||
portsInUse: make(map[int]bool),
|
||||
portsInUseMutex: sync.Mutex{},
|
||||
}
|
||||
|
||||
@@ -32,13 +32,13 @@ func (u *Utils) findUseFreePort(startingPort int) (int, error) {
|
||||
u.portsInUseMutex.Lock()
|
||||
defer u.portsInUseMutex.Unlock()
|
||||
for port := startingPort; port <= startingPort+100 && port <= 65535; port++ {
|
||||
if u.PortsInUse[port] {
|
||||
if u.portsInUse[port] {
|
||||
continue
|
||||
}
|
||||
addr := fmt.Sprintf(":%d", port)
|
||||
l, err := net.Listen("tcp", addr)
|
||||
if err == nil {
|
||||
u.PortsInUse[port] = true
|
||||
u.portsInUse[port] = true
|
||||
l.Close()
|
||||
return port, nil
|
||||
}
|
||||
@@ -47,7 +47,7 @@ func (u *Utils) findUseFreePort(startingPort int) (int, error) {
|
||||
if err == nil {
|
||||
// NOTE: may not be after 20000
|
||||
port := l.Addr().(*net.TCPAddr).Port
|
||||
u.PortsInUse[port] = true
|
||||
u.portsInUse[port] = true
|
||||
l.Close()
|
||||
return port, nil
|
||||
}
|
||||
@@ -56,13 +56,13 @@ func (u *Utils) findUseFreePort(startingPort int) (int, error) {
|
||||
|
||||
func (u *Utils) markPortInUse(port int) {
|
||||
u.portsInUseMutex.Lock()
|
||||
u.PortsInUse[port] = true
|
||||
u.portsInUse[port] = true
|
||||
u.portsInUseMutex.Unlock()
|
||||
}
|
||||
|
||||
func (u *Utils) unmarkPortInUse(port int) {
|
||||
u.portsInUseMutex.Lock()
|
||||
delete(u.PortsInUse, port)
|
||||
delete(u.portsInUse, port)
|
||||
u.portsInUseMutex.Unlock()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user