wstunnel

package
v14.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TunnelWebSocketProtocol is a subprotocol that allows client and server recognize each other.
	// See https://tools.ietf.org/html/rfc6455#section-11.3.4.
	TunnelWebSocketProtocol = "ws-tunnel"
)

Variables

This section is empty.

Functions

func DialerForGRPC

func DialerForGRPC(readLimit int64, dialOpts *websocket.DialOptions) func(context.Context, string) (net.Conn, error)

DialerForGRPC can be used as an adapter between "ws"/"wss" URL scheme that the websocket library wants and gRPC target naming scheme.

Types

type HttpHandler

type HttpHandler struct {
	Ctx           context.Context
	ServerName    string
	AcceptOptions websocket.AcceptOptions
	Sink          chan<- net.Conn
	// ReadLimit. Optional. See websocket.Conn.SetReadLimit().
	ReadLimit int64
}

func (*HttpHandler) ServeHTTP

func (h *HttpHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Listener

type Listener interface {
	net.Listener
	// Shutdown gracefully shuts down the server without interrupting any
	// active connections. See http.Server.Shutdown().
	Shutdown(context.Context) error
}

type ListenerWrapper

type ListenerWrapper struct {
	AcceptOptions websocket.AcceptOptions
	// ReadLimit. Optional. See websocket.Conn.SetReadLimit().
	ReadLimit  int64
	ServerName string

	ReadTimeout       time.Duration
	ReadHeaderTimeout time.Duration
	WriteTimeout      time.Duration
	IdleTimeout       time.Duration
	MaxHeaderBytes    int
	ConnState         func(net.Conn, http.ConnState)
	ErrorLog          *log.Logger
	BaseContext       func(net.Listener) context.Context
	ConnContext       func(ctx context.Context, c net.Conn) context.Context
}

func (*ListenerWrapper) Wrap

func (w *ListenerWrapper) Wrap(source net.Listener) Listener

Wrap accepts WebSocket connections and turns them into TCP connections.

Jump to

Keyboard shortcuts

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