From 926d0b74a9a99bed17bf0deaa7e7eb2cc1059acf Mon Sep 17 00:00:00 2001 From: fatedier Date: Wed, 20 Jul 2016 16:33:42 +0800 Subject: [PATCH] utils/vhost: update TcpConn with bufio.Reader --- src/frp/utils/conn/conn.go | 5 +++++ src/frp/utils/vhost/vhost.go | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/frp/utils/conn/conn.go b/src/frp/utils/conn/conn.go index a3981104..a5a7a335 100644 --- a/src/frp/utils/conn/conn.go +++ b/src/frp/utils/conn/conn.go @@ -117,6 +117,11 @@ func ConnectServer(host string, port int64) (c *Conn, err error) { return c, nil } +func (c *Conn) SetTcpConn(tcpConn net.Conn) { + c.TcpConn = tcpConn + c.Reader = bufio.NewReader(c.TcpConn) +} + func (c *Conn) GetRemoteAddr() (addr string) { return c.TcpConn.RemoteAddr().String() } diff --git a/src/frp/utils/vhost/vhost.go b/src/frp/utils/vhost/vhost.go index ecf080d1..ae672097 100644 --- a/src/frp/utils/vhost/vhost.go +++ b/src/frp/utils/vhost/vhost.go @@ -105,7 +105,7 @@ func (v *VhostMuxer) handle(c *conn.Conn) { if err = sConn.SetDeadline(time.Time{}); err != nil { return } - c.TcpConn = sConn + c.SetTcpConn(sConn) l.accept <- c }