change struct name

new
dingjun 6 years ago
parent 764434b372
commit 61fbd7ab0a

@ -7,26 +7,26 @@ import (
proxyproto "github.com/pires/go-proxyproto" proxyproto "github.com/pires/go-proxyproto"
) )
type listener struct { type protoListener struct {
net.Listener net.Listener
} }
type conn struct { type protoConn struct {
net.Conn net.Conn
headerDone bool headerDone bool
r *bufio.Reader r *bufio.Reader
proxy *proxyproto.Header proxy *proxyproto.Header
} }
func (l *listener) Accept() (net.Conn, error) { func (l *protoListener) Accept() (net.Conn, error) {
c, err := l.Listener.Accept() c, err := l.Listener.Accept()
if err != nil { if err != nil {
return nil, err 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 var err error
if !c.headerDone { if !c.headerDone {
c.r = bufio.NewReader(c.Conn) c.r = bufio.NewReader(c.Conn)
@ -40,7 +40,7 @@ func (c *conn) Read(buf []byte) (int, error) {
return c.r.Read(buf) return c.r.Read(buf)
} }
func (c *conn) RemoteAddr() net.Addr { func (c *protoConn) RemoteAddr() net.Addr {
if c.proxy == nil { if c.proxy == nil {
return c.Conn.RemoteAddr() return c.Conn.RemoteAddr()
} }

@ -69,7 +69,7 @@ func initServer(c *conf) error {
return err return err
} }
l = &listener{Listener: l} l = &protoListener{Listener: l}
if len(certs) > 0 { if len(certs) > 0 {
tlsconfig.Certificates = certs tlsconfig.Certificates = certs

Loading…
Cancel
Save