diff --git a/conn.go b/proxy_protocol.go similarity index 73% rename from conn.go rename to proxy_protocol.go index 8c74764..6536fed 100644 --- a/conn.go +++ b/proxy_protocol.go @@ -7,26 +7,26 @@ import ( proxyproto "github.com/pires/go-proxyproto" ) -type listener struct { +type protoListener struct { net.Listener } -type conn struct { +type protoConn struct { net.Conn headerDone bool r *bufio.Reader proxy *proxyproto.Header } -func (l *listener) Accept() (net.Conn, error) { +func (l *protoListener) Accept() (net.Conn, error) { c, err := l.Listener.Accept() if err != nil { return nil, err } - return &conn{Conn: c}, err + return &protoConn{Conn: c}, err } -func (c *conn) Read(buf []byte) (int, error) { +func (c *protoConn) Read(buf []byte) (int, error) { var err error if !c.headerDone { c.r = bufio.NewReader(c.Conn) @@ -40,7 +40,7 @@ func (c *conn) Read(buf []byte) (int, error) { return c.r.Read(buf) } -func (c *conn) RemoteAddr() net.Addr { +func (c *protoConn) RemoteAddr() net.Addr { if c.proxy == nil { return c.Conn.RemoteAddr() } diff --git a/server.go b/server.go index 2697be6..816c452 100644 --- a/server.go +++ b/server.go @@ -69,7 +69,7 @@ func initServer(c *conf) error { return err } - l = &listener{Listener: l} + l = &protoListener{Listener: l} if len(certs) > 0 { tlsconfig.Certificates = certs