From 716ec281f6fec1d0e6004b9dfd84c70e03c845f3 Mon Sep 17 00:00:00 2001 From: fatedier Date: Fri, 26 May 2017 14:17:46 +0800 Subject: [PATCH] net: add WrapReadWriteCloserConn --- utils/net/conn.go | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/utils/net/conn.go b/utils/net/conn.go index ed995c87..c085fe71 100644 --- a/utils/net/conn.go +++ b/utils/net/conn.go @@ -15,7 +15,9 @@ package net import ( + "io" "net" + "time" "github.com/fatedier/frp/utils/log" ) @@ -32,12 +34,44 @@ type WrapLogConn struct { } func WrapConn(c net.Conn) Conn { - return WrapLogConn{ + return &WrapLogConn{ Conn: c, Logger: log.NewPrefixLogger(""), } } +type WrapReadWriteCloserConn struct { + io.ReadWriteCloser + log.Logger +} + +func (conn *WrapReadWriteCloserConn) LocalAddr() net.Addr { + return nil +} + +func (conn *WrapReadWriteCloserConn) RemoteAddr() net.Addr { + return nil +} + +func (conn *WrapReadWriteCloserConn) SetDeadline(t time.Time) error { + return nil +} + +func (conn *WrapReadWriteCloserConn) SetReadDeadline(t time.Time) error { + return nil +} + +func (conn *WrapReadWriteCloserConn) SetWriteDeadline(t time.Time) error { + return nil +} + +func WrapReadWriteCloserToConn(rwc io.ReadWriteCloser) Conn { + return &WrapReadWriteCloserConn{ + ReadWriteCloser: rwc, + Logger: log.NewPrefixLogger(""), + } +} + type Listener interface { Accept() (Conn, error) Close() error