From a64c39caa18719b71fb0acff3920f9b8350ea9cc Mon Sep 17 00:00:00 2001 From: Steven Yang Date: Sat, 7 Apr 2018 18:52:45 -0700 Subject: [PATCH] Correct linter warnings --- http.go | 2 +- sni.go | 4 ++-- tcpproxy.go | 24 ++++++++++++------------ tcpproxy_test.go | 4 ++-- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/http.go b/http.go index 1d3e422..5fb1b5b 100644 --- a/http.go +++ b/http.go @@ -37,7 +37,7 @@ func (p *Proxy) AddHTTPHostRoute(ipPort, httpHost string, dest Target) { // for any additional routes on ipPort. // // The ipPort is any valid net.Listen TCP address. -func (p *Proxy) AddHTTPHostMatchRoute(ipPort string, match Matcher, dest Target) (routeId int) { +func (p *Proxy) AddHTTPHostMatchRoute(ipPort string, match Matcher, dest Target) (routeID int) { return p.addRoute(ipPort, httpHostMatch{match, dest}) } diff --git a/sni.go b/sni.go index bb0a446..b49865c 100644 --- a/sni.go +++ b/sni.go @@ -34,7 +34,7 @@ import ( // with AddStopACMESearch. // // The ipPort is any valid net.Listen TCP address. -func (p *Proxy) AddSNIRoute(ipPort, sni string, dest Target) (routeId int) { +func (p *Proxy) AddSNIRoute(ipPort, sni string, dest Target) (routeID int) { return p.AddSNIMatchRoute(ipPort, equals(sni), dest) } @@ -48,7 +48,7 @@ func (p *Proxy) AddSNIRoute(ipPort, sni string, dest Target) (routeId int) { // with AddStopACMESearch. // // The ipPort is any valid net.Listen TCP address. -func (p *Proxy) AddSNIMatchRoute(ipPort string, matcher Matcher, dest Target) (routeId int) { +func (p *Proxy) AddSNIMatchRoute(ipPort string, matcher Matcher, dest Target) (routeID int) { cfg := p.configFor(ipPort) if !cfg.stopACME { if len(cfg.acmeTargets) == 0 { diff --git a/tcpproxy.go b/tcpproxy.go index fcc4b5d..b4aa767 100644 --- a/tcpproxy.go +++ b/tcpproxy.go @@ -95,16 +95,16 @@ func equals(want string) Matcher { // config contains the proxying state for one listener. type config struct { sync.Mutex // protect w of routes - nextRouteId int + nextRouteID int routes map[int]route acmeTargets []Target // accumulates targets that should be probed for acme. stopACME bool // if true, AddSNIRoute doesn't add targets to acmeTargets. } -func NewConfig() (cfg *config) { +func newConfig() (cfg *config) { cfg = &config{} cfg.routes = make(map[int]route) - cfg.nextRouteId = 1 + cfg.nextRouteID = 1 return } @@ -132,12 +132,12 @@ func (p *Proxy) configFor(ipPort string) *config { p.configs = make(map[string]*config) } if p.configs[ipPort] == nil { - p.configs[ipPort] = NewConfig() + p.configs[ipPort] = newConfig() } return p.configs[ipPort] } -func (p *Proxy) addRoute(ipPort string, r route) (routeId int) { +func (p *Proxy) addRoute(ipPort string, r route) (routeID int) { var cfg *config if p.donec != nil { // NOTE: Do not create config file if the server is listening. @@ -149,9 +149,9 @@ func (p *Proxy) addRoute(ipPort string, r route) (routeId int) { } if cfg != nil { cfg.Lock() - routeId = cfg.nextRouteId - cfg.nextRouteId++ - cfg.routes[routeId] = r + routeID = cfg.nextRouteID + cfg.nextRouteID++ + cfg.routes[routeID] = r cfg.Unlock() } return @@ -159,13 +159,13 @@ func (p *Proxy) addRoute(ipPort string, r route) (routeId int) { // AddRoute appends an always-matching route to the ipPort listener, // directing any connection to dest. The added route's id is returned -// for future removal. If routeId is zero, the route is not registered. +// for future removal. If routeID is zero, the route is not registered. // // This is generally used as either the only rule (for simple TCP // proxies), or as the final fallback rule for an ipPort. // // The ipPort is any valid net.Listen TCP address. -func (p *Proxy) AddRoute(ipPort string, dest Target) (routeId int) { +func (p *Proxy) AddRoute(ipPort string, dest Target) (routeID int) { return p.addRoute(ipPort, fixedTarget{dest}) } @@ -173,9 +173,9 @@ func (p *Proxy) AddRoute(ipPort string, dest Target) (routeId int) { // not found, this is an no-op. // // Both AddRoute and RemoveRoute is go-routine safe. -func (p *Proxy) RemoveRoute(ipPort string, routeId int) (err error) { +func (p *Proxy) RemoveRoute(ipPort string, routeID int) (err error) { cfg := p.configFor(ipPort) - cfg.routes[routeId] = nil + cfg.routes[routeID] = nil return } diff --git a/tcpproxy_test.go b/tcpproxy_test.go index e98a241..dd88253 100644 --- a/tcpproxy_test.go +++ b/tcpproxy_test.go @@ -311,12 +311,12 @@ func TestProxyRemoveRoute(t *testing.T) { backBar := newLocalListener(t) defer backBar.Close() - routeId := p.AddSNIRoute(testFrontAddr, "bar.com", To(backBar.Addr().String())) + routeID := p.AddSNIRoute(testFrontAddr, "bar.com", To(backBar.Addr().String())) msg := clientHelloRecord(t, "bar.com") testRouteToBackend(t, front, backBar, msg) - p.RemoveRoute(testFrontAddr, routeId) + p.RemoveRoute(testFrontAddr, routeID) <-testNotRouteToBackend(t, front, backBar, msg) }