connection

package
v0.0.0-...-0375c8d Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package connection provides utilities for the connection used when bridging TCP over websocket.

Index

Constants

View Source
const StreamingPath = "/tcp-over-websocket-bridge/35218cb7-1201-4940-89e8-48d8f03fed96"

StreamingPath is the path used for websocket channels that implement the bridge.

The last component of the path is a randomly generated UUID used to reduce the risk of accidental conflicts.

Variables

This section is empty.

Functions

func DialWebsocket

func DialWebsocket(ctx context.Context, backendURL *url.URL, h http.Header) (net.Conn, error)

DialWebsocket establishes a connection with the given server using websocket as the underlying transport layer.

func Handler

func Handler(backendPort int, passthroughHandler http.Handler) http.Handler

Handler returns an HTTP handler that forwards bridged TCP connections to the given port.

The passthroughHandler is used to forward any requests that are not part of the TCP-Over-WS bridge.

Types

type WebsocketNetConn

type WebsocketNetConn struct {
	*websocket.Conn
	// contains filtered or unexported fields
}

WebsocketNetConnection wraps the websocket.Conn type and adds extends it to implement the net.Conn interface

func (*WebsocketNetConn) Read

func (c *WebsocketNetConn) Read(bs []byte) (count int, err error)

Read implements the io.Reader interface.

func (*WebsocketNetConn) SetDeadline

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

SetDeadline implements the net.Conn interface.

func (*WebsocketNetConn) Write

func (c *WebsocketNetConn) Write(bs []byte) (count int, err error)

Write implements the io.Writer interface.

Jump to

Keyboard shortcuts

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