Skip to content

Commit 08e1ca7

Browse files
committed
Review fixes
1 parent a64c39c commit 08e1ca7

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

Diff for: tcpproxy.go

+7-11
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,13 @@ func equals(want string) Matcher {
9595
// config contains the proxying state for one listener.
9696
type config struct {
9797
sync.Mutex // protect w of routes
98-
nextRouteID int
9998
routes map[int]route
99+
nextRouteID int
100+
100101
acmeTargets []Target // accumulates targets that should be probed for acme.
101102
stopACME bool // if true, AddSNIRoute doesn't add targets to acmeTargets.
102103
}
103104

104-
func newConfig() (cfg *config) {
105-
cfg = &config{}
106-
cfg.routes = make(map[int]route)
107-
cfg.nextRouteID = 1
108-
return
109-
}
110-
111105
// A route matches a connection to a target.
112106
type route interface {
113107
// match examines the initial bytes of a connection, looking for a
@@ -132,7 +126,10 @@ func (p *Proxy) configFor(ipPort string) *config {
132126
p.configs = make(map[string]*config)
133127
}
134128
if p.configs[ipPort] == nil {
135-
p.configs[ipPort] = newConfig()
129+
cfg := &config{}
130+
cfg.routes = make(map[int]route)
131+
cfg.nextRouteID = 1
132+
p.configs[ipPort] = cfg
136133
}
137134
return p.configs[ipPort]
138135
}
@@ -173,10 +170,9 @@ func (p *Proxy) AddRoute(ipPort string, dest Target) (routeID int) {
173170
// not found, this is an no-op.
174171
//
175172
// Both AddRoute and RemoveRoute is go-routine safe.
176-
func (p *Proxy) RemoveRoute(ipPort string, routeID int) (err error) {
173+
func (p *Proxy) RemoveRoute(ipPort string, routeID int) {
177174
cfg := p.configFor(ipPort)
178175
cfg.routes[routeID] = nil
179-
return
180176
}
181177

182178
type fixedTarget struct {

0 commit comments

Comments
 (0)