Jelajahi Sumber

utils/vhost: update TcpConn with bufio.Reader

fatedier 8 tahun lalu
induk
melakukan
926d0b74a9
2 mengubah file dengan 6 tambahan dan 1 penghapusan
  1. 5 0
      src/frp/utils/conn/conn.go
  2. 1 1
      src/frp/utils/vhost/vhost.go

+ 5 - 0
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()
 }

+ 1 - 1
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
 }