net

package
v0.58.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 23 Imported by: 19

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, isTLS bool, custom bool, err error)

func DialHookCustomTLSHeadByte added in v0.39.0

func DialHookCustomTLSHeadByte(enableTLS bool, disableCustomTLSHeadByte bool) libnet.AfterHookFunc

func DialHookWebsocket added in v0.39.0

func DialHookWebsocket(protocol string, host string) libnet.AfterHookFunc

func MakeHTTPGzipHandler

func MakeHTTPGzipHandler(h http.Handler) http.Handler

func NewContextFromConn

func NewContextFromConn(conn net.Conn) context.Context

func NewCryptoReadWriter added in v0.53.0

func NewCryptoReadWriter(rw io.ReadWriter, key []byte) (io.ReadWriter, error)

func NewKCPConnFromUDP

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

func NewLogFromConn

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

func QuicStreamToNetConn added in v0.46.0

func QuicStreamToNetConn(s quic.Stream, c quic.Connection) net.Conn

func SetDefaultDNSAddress added in v0.53.0

func SetDefaultDNSAddress(dnsAddress string)

func WrapCloseNotifyConn

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

closeFn will be only called once

Types

type CloseNotifyConn

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

func (*CloseNotifyConn) Close

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

type ConnectedUDPConn added in v0.49.0

type ConnectedUDPConn struct{ *net.UDPConn }

ConnectedUDPConn is a wrapper for net.UDPConn which converts WriteTo syscalls to Write syscalls that are 4 times faster on some OS'es. This should only be used for connections that were produced by a net.Dial* call.

func (*ConnectedUDPConn) WriteTo added in v0.49.0

func (c *ConnectedUDPConn) WriteTo(b []byte, _ net.Addr) (int, error)

WriteTo redirects all writes to the Write syscall, which is 4 times faster.

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 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(_ time.Time) error

func (*FakeUDPConn) SetReadDeadline

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

func (*FakeUDPConn) SetWriteDeadline

func (c *FakeUDPConn) SetWriteDeadline(_ 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

func (*HTTPAuthMiddleware) SetAuthFailDelay added in v0.49.0

func (authMid *HTTPAuthMiddleware) SetAuthFailDelay(delay time.Duration) *HTTPAuthMiddleware

type HTTPGzipWrapper added in v0.53.0

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

func (*HTTPGzipWrapper) ServeHTTP added in v0.53.0

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

type InternalAddr added in v0.50.0

type InternalAddr struct{}

func (*InternalAddr) Network added in v0.50.0

func (ia *InternalAddr) Network() string

func (*InternalAddr) String added in v0.50.0

func (ia *InternalAddr) String() string

type InternalListener added in v0.50.0

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

InternalListener is a listener that can be used to accept connections from other goroutines.

func NewInternalListener added in v0.50.0

func NewInternalListener() *InternalListener

func (*InternalListener) Accept added in v0.50.0

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

func (*InternalListener) Addr added in v0.50.0

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

func (*InternalListener) Close added in v0.50.0

func (l *InternalListener) Close() error

func (*InternalListener) PutConn added in v0.50.0

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

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 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 WrapReadWriteCloserToConn

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

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) SetRemoteAddr added in v0.57.0

func (conn *WrapReadWriteCloserConn) SetRemoteAddr(addr net.Addr)

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