Skip to content

Commit

Permalink
net: add WrapReadWriteCloserConn
Browse files Browse the repository at this point in the history
  • Loading branch information
fatedier committed May 26, 2017
1 parent 67bfae5 commit 716ec28
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion utils/net/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
package net

import (
"io"
"net"
"time"

"github.com/fatedier/frp/utils/log"
)
Expand All @@ -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
Expand Down

0 comments on commit 716ec28

Please sign in to comment.