net

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2020 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

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

Variables

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

Functions

func CheckAndEnableTLSServerConnWithTimeout added in v0.27.1

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

func ConnectServer added in v0.12.0

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

func ConnectServerByProxy added in v0.19.0

func ConnectServerByProxy(proxyURL string, protocol string, addr string) (c net.Conn, err error)

func ConnectServerByProxyWithTLS added in v0.25.0

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

func ConnectWebsocketServer added in v0.21.0

func ConnectWebsocketServer(addr string) (net.Conn, error)

addr: domain:port

func HTTPBasicAuth added in v0.34.0

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

func MakeHTTPGzipHandler added in v0.34.0

func MakeHTTPGzipHandler(h http.Handler) http.Handler

func NewContextFromConn added in v0.29.1

func NewContextFromConn(conn net.Conn) context.Context

func NewHTTPBasicAuthWraper added in v0.34.0

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

func NewKCPConnFromUDP added in v0.34.0

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

func NewLogFromConn added in v0.29.1

func NewLogFromConn(conn net.Conn) *xlog.Logger

func WrapCloseNotifyConn added in v0.21.0

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

closeFn will be only called once

func WrapReadWriteCloserToConn added in v0.11.0

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

func WrapTLSClientConn added in v0.25.0

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

Types

type CloseNotifyConn added in v0.21.0

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

func (*CloseNotifyConn) Close added in v0.21.0

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

type ContextConn added in v0.29.1

type ContextConn struct {
	net.Conn
	// contains filtered or unexported fields
}

ContextConn is the connection with context

func NewContextConn added in v0.29.1

func NewContextConn(ctx context.Context, c net.Conn) *ContextConn

func (*ContextConn) Context added in v0.29.1

func (c *ContextConn) Context() context.Context

func (*ContextConn) WithContext added in v0.29.1

func (c *ContextConn) WithContext(ctx context.Context)

type ContextGetter added in v0.29.1

type ContextGetter interface {
	Context() context.Context
}

type ContextSetter added in v0.29.1

type ContextSetter interface {
	WithContext(ctx context.Context)
}

type CustomListener added in v0.13.0

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

Custom listener

func NewCustomListener added in v0.13.0

func NewCustomListener() *CustomListener

func (*CustomListener) Accept added in v0.13.0

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

func (*CustomListener) Addr added in v0.13.0

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

func (*CustomListener) Close added in v0.13.0

func (l *CustomListener) Close() error

func (*CustomListener) PutConn added in v0.13.0

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

type FakeUDPConn added in v0.34.0

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

func NewFakeUDPConn added in v0.34.0

func NewFakeUDPConn(l *UDPListener, laddr, raddr net.Addr) *FakeUDPConn

func (*FakeUDPConn) Close added in v0.34.0

func (c *FakeUDPConn) Close() error

func (*FakeUDPConn) IsClosed added in v0.34.0

func (c *FakeUDPConn) IsClosed() bool

func (*FakeUDPConn) LocalAddr added in v0.34.0

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

func (*FakeUDPConn) Read added in v0.34.0

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

func (*FakeUDPConn) RemoteAddr added in v0.34.0

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

func (*FakeUDPConn) SetDeadline added in v0.34.0

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

func (*FakeUDPConn) SetReadDeadline added in v0.34.0

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

func (*FakeUDPConn) SetWriteDeadline added in v0.34.0

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

func (*FakeUDPConn) Write added in v0.34.0

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

type HTTPAuthMiddleware added in v0.34.0

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

func NewHTTPAuthMiddleware added in v0.34.0

func NewHTTPAuthMiddleware(user, passwd string) *HTTPAuthMiddleware

func (*HTTPAuthMiddleware) Middleware added in v0.34.0

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

type HTTPAuthWraper added in v0.34.0

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

func (*HTTPAuthWraper) ServeHTTP added in v0.34.0

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

type HTTPGzipWraper added in v0.34.0

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

func (*HTTPGzipWraper) ServeHTTP added in v0.34.0

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

type KCPListener added in v0.34.0

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

func ListenKcp added in v0.12.0

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

func (*KCPListener) Accept added in v0.34.0

func (l *KCPListener) Accept() (net.Conn, error)

func (*KCPListener) Addr added in v0.34.0

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

func (*KCPListener) Close added in v0.34.0

func (l *KCPListener) Close() error

type StatsConn added in v0.15.0

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

func WrapStatsConn added in v0.15.0

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

func (*StatsConn) Close added in v0.15.0

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

func (*StatsConn) Read added in v0.15.0

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

func (*StatsConn) Write added in v0.15.0

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

type UDPListener added in v0.34.0

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

func ListenUDP

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

func (*UDPListener) Accept added in v0.34.0

func (l *UDPListener) Accept() (net.Conn, error)

func (*UDPListener) Addr added in v0.34.0

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

func (*UDPListener) Close added in v0.34.0

func (l *UDPListener) Close() error

func (*UDPListener) WriteMsg added in v0.34.0

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

type UDPPacket added in v0.34.0

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

type WebsocketListener added in v0.21.0

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

func ListenWebsocket added in v0.21.0

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

func NewWebsocketListener added in v0.21.0

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

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

func (*WebsocketListener) Accept added in v0.21.0

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

func (*WebsocketListener) Addr added in v0.29.1

func (p *WebsocketListener) Addr() net.Addr

func (*WebsocketListener) Close added in v0.21.0

func (p *WebsocketListener) Close() error

type WrapReadWriteCloserConn added in v0.11.0

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

func (*WrapReadWriteCloserConn) LocalAddr added in v0.11.0

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

func (*WrapReadWriteCloserConn) RemoteAddr added in v0.11.0

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

func (*WrapReadWriteCloserConn) SetDeadline added in v0.11.0

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

func (*WrapReadWriteCloserConn) SetReadDeadline added in v0.11.0

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

func (*WrapReadWriteCloserConn) SetWriteDeadline added in v0.11.0

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