net

package
v0.27.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FrpWebsocketPath = "/~!frp"
)

Variables

View Source
var (
	ErrWebsocketListenerClosed = errors.New("websocket listener closed")
)
View Source
var (
	FRP_TLS_HEAD_BYTE = 0x17
)

Functions

func HttpBasicAuth

func HttpBasicAuth(h http.HandlerFunc, user, passwd string) http.HandlerFunc

func MakeHttpGzipHandler

func MakeHttpGzipHandler(h http.Handler) http.Handler

func NewHttpBasicAuthWraper

func NewHttpBasicAuthWraper(h http.Handler, user, passwd string) http.Handler

func NewKcpConnFromUdp

func NewKcpConnFromUdp(conn *net.UDPConn, connected bool, raddr string) (net.Conn, error)

Types

type CloseNotifyConn

type CloseNotifyConn struct {
	net.Conn
	log.Logger
	// contains filtered or unexported fields
}

func (*CloseNotifyConn) Close

func (cc *CloseNotifyConn) Close() (err error)

type Conn

type Conn interface {
	net.Conn
	log.Logger
}

Conn is the interface of connections used in frp.

func CheckAndEnableTLSServerConnWithTimeout

func CheckAndEnableTLSServerConnWithTimeout(c net.Conn, tlsConfig *tls.Config, timeout time.Duration) (out Conn, err error)

func ConnectServer

func ConnectServer(protocol string, addr string) (c Conn, err error)

func ConnectServerByProxy

func ConnectServerByProxy(proxyUrl string, protocol string, addr string) (c Conn, err error)

func ConnectServerByProxyWithTLS

func ConnectServerByProxyWithTLS(proxyUrl string, protocol string, addr string, tlsConfig *tls.Config) (c Conn, err error)

func ConnectTcpServer

func ConnectTcpServer(addr string) (c Conn, err error)

func ConnectWebsocketServer

func ConnectWebsocketServer(addr string) (Conn, error)

addr: domain:port

func WrapCloseNotifyConn

func WrapCloseNotifyConn(c net.Conn, closeFn func()) Conn

closeFn will be only called once

func WrapConn

func WrapConn(c net.Conn) Conn

func WrapReadWriteCloserToConn

func WrapReadWriteCloserToConn(rwc io.ReadWriteCloser, underConn net.Conn) Conn

func WrapTLSClientConn

func WrapTLSClientConn(c net.Conn, tlsConfig *tls.Config) (out Conn)

type CustomListener

type CustomListener struct {
	log.Logger
	// contains filtered or unexported fields
}

Custom listener

func NewCustomListener

func NewCustomListener() *CustomListener

func (*CustomListener) Accept

func (l *CustomListener) Accept() (Conn, error)

func (*CustomListener) Addr

func (l *CustomListener) Addr() net.Addr

func (*CustomListener) Close

func (l *CustomListener) Close() error

func (*CustomListener) PutConn

func (l *CustomListener) PutConn(conn Conn) error

type FakeUdpConn

type FakeUdpConn struct {
	log.Logger
	// contains filtered or unexported fields
}

func NewFakeUdpConn

func NewFakeUdpConn(l *UdpListener, laddr, raddr net.Addr) *FakeUdpConn

func (*FakeUdpConn) Close

func (c *FakeUdpConn) Close() error

func (*FakeUdpConn) IsClosed

func (c *FakeUdpConn) IsClosed() bool

func (*FakeUdpConn) LocalAddr

func (c *FakeUdpConn) LocalAddr() net.Addr

func (*FakeUdpConn) Read

func (c *FakeUdpConn) Read(b []byte) (n int, err error)

func (*FakeUdpConn) RemoteAddr

func (c *FakeUdpConn) RemoteAddr() net.Addr

func (*FakeUdpConn) SetDeadline

func (c *FakeUdpConn) SetDeadline(t time.Time) error

func (*FakeUdpConn) SetReadDeadline

func (c *FakeUdpConn) SetReadDeadline(t time.Time) error

func (*FakeUdpConn) SetWriteDeadline

func (c *FakeUdpConn) SetWriteDeadline(t time.Time) error

func (*FakeUdpConn) Write

func (c *FakeUdpConn) Write(b []byte) (n int, err error)

type HttpAuthMiddleware

type HttpAuthMiddleware struct {
	// contains filtered or unexported fields
}

func NewHttpAuthMiddleware

func NewHttpAuthMiddleware(user, passwd string) *HttpAuthMiddleware

func (*HttpAuthMiddleware) Middleware

func (authMid *HttpAuthMiddleware) Middleware(next http.Handler) http.Handler

type HttpAuthWraper

type HttpAuthWraper struct {
	// contains filtered or unexported fields
}

func (*HttpAuthWraper) ServeHTTP

func (aw *HttpAuthWraper) ServeHTTP(w http.ResponseWriter, r *http.Request)

type HttpGzipWraper

type HttpGzipWraper struct {
	// contains filtered or unexported fields
}

func (*HttpGzipWraper) ServeHTTP

func (gw *HttpGzipWraper) ServeHTTP(w http.ResponseWriter, r *http.Request)

type KcpListener

type KcpListener struct {
	net.Addr

	log.Logger
	// contains filtered or unexported fields
}

func ListenKcp

func ListenKcp(bindAddr string, bindPort int) (l *KcpListener, err error)

func (*KcpListener) Accept

func (l *KcpListener) Accept() (Conn, error)

func (*KcpListener) Close

func (l *KcpListener) Close() error

type Listener

type Listener interface {
	Accept() (Conn, error)
	Close() error
	log.Logger
}

func WrapLogListener

func WrapLogListener(l net.Listener) Listener

type LogListener

type LogListener struct {
	net.Listener
	log.Logger
	// contains filtered or unexported fields
}

func (*LogListener) Accept

func (logL *LogListener) Accept() (Conn, error)

func (*LogListener) Close

func (logL *LogListener) Close() error

Close 关闭listener

type StatsConn

type StatsConn struct {
	Conn
	// contains filtered or unexported fields
}

func WrapStatsConn

func WrapStatsConn(conn Conn, statsFunc func(total, totalWrite int64)) *StatsConn

func (*StatsConn) Close

func (statsConn *StatsConn) Close() (err error)

func (*StatsConn) Read

func (statsConn *StatsConn) Read(p []byte) (n int, err error)

func (*StatsConn) Write

func (statsConn *StatsConn) Write(p []byte) (n int, err error)

type TcpConn

type TcpConn struct {
	net.Conn
	log.Logger
}

Wrap for TCPConn.

func NewTcpConn

func NewTcpConn(conn net.Conn) (c *TcpConn)

type TcpListener

type TcpListener struct {
	net.Addr

	log.Logger
	// contains filtered or unexported fields
}

func ListenTcp

func ListenTcp(bindAddr string, bindPort int) (l *TcpListener, err error)

func (*TcpListener) Accept

func (l *TcpListener) Accept() (Conn, error)

Wait util get one new connection or listener is closed if listener is closed, err returned.

func (*TcpListener) Close

func (l *TcpListener) Close() error

type UdpListener

type UdpListener struct {
	net.Addr

	log.Logger
	// contains filtered or unexported fields
}

func ListenUDP

func ListenUDP(bindAddr string, bindPort int) (l *UdpListener, err error)

func (*UdpListener) Accept

func (l *UdpListener) Accept() (Conn, error)

func (*UdpListener) Close

func (l *UdpListener) Close() error

func (*UdpListener) WriteMsg

func (l *UdpListener) WriteMsg(buf []byte, remoteAddr *net.UDPAddr) (err error)

type UdpPacket

type UdpPacket struct {
	Buf        []byte
	LocalAddr  net.Addr
	RemoteAddr net.Addr
}

type WebsocketListener

type WebsocketListener struct {
	net.Addr

	log.Logger
	// contains filtered or unexported fields
}

func ListenWebsocket

func ListenWebsocket(bindAddr string, bindPort int) (*WebsocketListener, error)

func NewWebsocketListener

func NewWebsocketListener(ln net.Listener) (wl *WebsocketListener)

NewWebsocketListener to handle websocket connections ln: tcp listener for websocket connections

func (*WebsocketListener) Accept

func (p *WebsocketListener) Accept() (Conn, error)

func (*WebsocketListener) Close

func (p *WebsocketListener) Close() error

type WrapLogConn

type WrapLogConn struct {
	net.Conn
	log.Logger
}

type WrapReadWriteCloserConn

type WrapReadWriteCloserConn struct {
	io.ReadWriteCloser
	log.Logger
	// contains filtered or unexported fields
}

func (*WrapReadWriteCloserConn) LocalAddr

func (conn *WrapReadWriteCloserConn) LocalAddr() net.Addr

func (*WrapReadWriteCloserConn) RemoteAddr

func (conn *WrapReadWriteCloserConn) RemoteAddr() net.Addr

func (*WrapReadWriteCloserConn) SetDeadline

func (conn *WrapReadWriteCloserConn) SetDeadline(t time.Time) error

func (*WrapReadWriteCloserConn) SetReadDeadline

func (conn *WrapReadWriteCloserConn) SetReadDeadline(t time.Time) error

func (*WrapReadWriteCloserConn) SetWriteDeadline

func (conn *WrapReadWriteCloserConn) SetWriteDeadline(t time.Time) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL