net

package
v0.37.7 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 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

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

func ConnectServer

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

func ConnectServerByProxy

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

func ConnectServerByProxyWithTLS

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

func ConnectWSSServer added in v0.36.4

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

addr: domain:port

func ConnectWebsocketServer

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

addr: domain:port

func HTTPBasicAuth

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

func MakeHTTPGzipHandler

func MakeHTTPGzipHandler(h http.Handler) http.Handler

func NewContextFromConn

func NewContextFromConn(conn net.Conn) context.Context

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)

func NewLogFromConn

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

func WrapCloseNotifyConn

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

closeFn will be only called once

func WrapReadWriteCloserToConn

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

func WrapTLSClientConn

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

Types

type CloseNotifyConn

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

func (*CloseNotifyConn) Close

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

type ContextConn

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

ContextConn is the connection with context

func NewContextConn

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

func (*ContextConn) Context

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

func (*ContextConn) WithContext

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

type ContextGetter

type ContextGetter interface {
	Context() context.Context
}

type ContextSetter

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

type CustomListener

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

Custom listener

func NewCustomListener

func NewCustomListener() *CustomListener

func (*CustomListener) Accept

func (l *CustomListener) Accept() (net.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 net.Conn) error

type FakeUDPConn

type FakeUDPConn struct {
	// 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 {
	// contains filtered or unexported fields
}

func ListenKcp

func ListenKcp(address string) (l *KCPListener, err error)

func (*KCPListener) Accept

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

func (*KCPListener) Addr

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

func (*KCPListener) Close

func (l *KCPListener) Close() error

type StatsConn

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

func WrapStatsConn

func WrapStatsConn(conn net.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 UDPListener

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

func ListenUDP

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

func (*UDPListener) Accept

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

func (*UDPListener) Addr

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

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 {
	// 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() (net.Conn, error)

func (*WebsocketListener) Addr

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

func (*WebsocketListener) Close

func (p *WebsocketListener) Close() error

type WrapReadWriteCloserConn

type WrapReadWriteCloserConn struct {
	io.ReadWriteCloser
	// 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