snowflake_server

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package snowflake_server implements the functionality necessary to accept Snowflake connections from Snowflake clients.

Included in the package is a Transport type that implements the Pluggable Transports v2.1 Go API specification. To start a TLS Snowflake server using the golang.org/x/crypto/acme/autocert library, configure a certificate manager for the server's domain name and then create a new Transport as follows:

// The snowflake server runs a websocket server. To run this securely, you will
// need a valid certificate.
certManager := &autocert.Manager{
	Prompt:     autocert.AcceptTOS,
	HostPolicy: autocert.HostWhitelist("snowflake.yourdomain.com"),
	Email:      "you@yourdomain.com",
}

transport := snowflake_server.NewSnowflakeServer(certManager.GetCertificate)

The Listen function starts a new listener, and Accept will return incoming Snowflake connections:

ln, err := transport.Listen(addr)
if err != nil {
	// handle error
}
for {
	conn, err := ln.Accept()
	if err != nil {
		// handle error
	}
	// handle conn
}

Index

Constants

View Source
const (
	// WindowSize is the number of packets in the send and receive window of a KCP connection.
	WindowSize = 65535
	// StreamSize controls the maximum amount of in flight data between a client and server.
	StreamSize = 1048576 //1MB
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientMapAddr

type ClientMapAddr string

ClientMapAddr is a string that represents a connecting client.

func (ClientMapAddr) Network

func (addr ClientMapAddr) Network() string

func (ClientMapAddr) String

func (addr ClientMapAddr) String() string

type SnowflakeClientConn

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

SnowflakeClientConn is a wrapper for the underlying turbotunnel conn. We need to reference our client address map to determine the remote address

func (*SnowflakeClientConn) RemoteAddr

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

RemoteAddr returns the mapped client address of the Snowflake connection

type SnowflakeListener

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

func (*SnowflakeListener) Accept

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

Accept allows the caller to accept incoming Snowflake connections. We accept connections from a queue to accommodate both incoming smux Streams and legacy non-turbotunnel connections.

func (*SnowflakeListener) Addr

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

Addr returns the address of the SnowflakeListener

func (*SnowflakeListener) Close

func (l *SnowflakeListener) Close() error

Close closes the Snowflake connection.

type Transport

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

Transport is a structure with methods that conform to the Go PT v2.1 API https://github.com/Pluggable-Transports/Pluggable-Transports-spec/blob/master/releases/PTSpecV2.1/Pluggable%20Transport%20Specification%20v2.1%20-%20Go%20Transport%20API.pdf

func NewSnowflakeServer

func NewSnowflakeServer(getCertificate func(*tls.ClientHelloInfo) (*tls.Certificate, error)) *Transport

NewSnowflakeServer returns a new server-side Transport for Snowflake.

func (*Transport) Listen

func (t *Transport) Listen(addr net.Addr) (*SnowflakeListener, error)

Listen starts a listener on addr that will accept both turbotunnel and legacy Snowflake connections.

Jump to

Keyboard shortcuts

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