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
- type ClientMapAddr
- type SnowflakeClientConn
- func (conn *SnowflakeClientConn) Close() error
- func (conn *SnowflakeClientConn) LocalAddr() net.Addr
- func (conn *SnowflakeClientConn) Read(b []byte) (int, error)
- func (conn *SnowflakeClientConn) RemoteAddr() net.Addr
- func (conn *SnowflakeClientConn) SetDeadline(t time.Time) error
- func (conn *SnowflakeClientConn) SetReadDeadline(t time.Time) error
- func (conn *SnowflakeClientConn) SetWriteDeadline(t time.Time) error
- func (conn *SnowflakeClientConn) Write(b []byte) (int, error)
- func (conn *SnowflakeClientConn) WriteTo(w io.Writer) (int64, error)
- type SnowflakeListener
- type Transport
Constants ¶
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 {
// contains filtered or unexported fields
}
SnowflakeClientConn is a wrapper for the underlying turbotunnel conn (smux.Stream). It implements the net.Conn and io.WriterTo interfaces. The RemoteAddr method is overridden to refer to a real IP address, looked up from the client address map, rather than an abstract client ID.
func (*SnowflakeClientConn) Close ¶ added in v2.4.2
func (conn *SnowflakeClientConn) Close() error
func (*SnowflakeClientConn) LocalAddr ¶ added in v2.4.2
func (conn *SnowflakeClientConn) LocalAddr() net.Addr
func (*SnowflakeClientConn) Read ¶ added in v2.4.2
func (conn *SnowflakeClientConn) Read(b []byte) (int, error)
Forward net.Conn methods, other than RemoteAddr, to the inner stream.
func (*SnowflakeClientConn) RemoteAddr ¶
func (conn *SnowflakeClientConn) RemoteAddr() net.Addr
RemoteAddr returns the mapped client address of the Snowflake connection.
func (*SnowflakeClientConn) SetDeadline ¶ added in v2.4.2
func (conn *SnowflakeClientConn) SetDeadline(t time.Time) error
func (*SnowflakeClientConn) SetReadDeadline ¶ added in v2.4.2
func (conn *SnowflakeClientConn) SetReadDeadline(t time.Time) error
func (*SnowflakeClientConn) SetWriteDeadline ¶ added in v2.4.2
func (conn *SnowflakeClientConn) SetWriteDeadline(t time.Time) error
func (*SnowflakeClientConn) Write ¶ added in v2.4.2
func (conn *SnowflakeClientConn) Write(b []byte) (int, error)
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.