snowflake_proxy

package
v0.0.0-...-98e4769 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: BSD-3-Clause Imports: 28 Imported by: 0

Documentation

Overview

Package snowflake_proxy provides functionality for creating, starting, and stopping a snowflake proxy.

To run a proxy, you must first create a proxy configuration. Unconfigured fields will be set to the defined defaults.

proxy := snowflake_proxy.SnowflakeProxy{
	BrokerURL: "https://snowflake-broker.example.com",
	STUNURL: "stun:stun.tgragnato.it:3478",
	// ...
}

You may then start and stop the proxy. Stopping the proxy will close existing connections and the proxy will not poll for more clients.

go func() {
	err := proxy.Start()
	// handle error
}

// ...

proxy.Stop()

Index

Constants

View Source
const (
	DefaultBrokerURL   = "https://snowflake-broker.torproject.net/"
	DefaultNATProbeURL = "https://snowflake-broker.torproject.net:8443/probe"
	DefaultRelayURL    = "wss://snowflake.torproject.net/"
	DefaultSTUNURL     = "stun:stun.tgragnato.it:3478"
	DefaultProxyType   = "standalone"

	NATUnknown      = "unknown"
	NATRestricted   = "restricted"
	NATUnrestricted = "unrestricted"
)

Variables

This section is empty.

Functions

func NewProxyEventLogger

func NewProxyEventLogger(output io.Writer, disableStats bool) event.SnowflakeEventReceiver

Types

type EventCollector

type EventCollector interface {
	TrackInBoundTraffic(value int64)
	TrackOutBoundTraffic(value int64)
	TrackNewConnection()
}

type EventMetrics

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

func NewEventMetrics

func NewEventMetrics(collector EventCollector) *EventMetrics

func (*EventMetrics) OnNewSnowflakeEvent

func (em *EventMetrics) OnNewSnowflakeEvent(e event.SnowflakeEvent)

type Metrics

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

func NewMetrics

func NewMetrics() *Metrics

func (*Metrics) Collect

func (m *Metrics) Collect(ch chan<- prometheus.Metric)

func (*Metrics) Describe

func (m *Metrics) Describe(descs chan<- *prometheus.Desc)

func (*Metrics) Start

func (m *Metrics) Start(addr string) error

Start register the metrics server and serve them on the given address

func (*Metrics) TrackInBoundTraffic

func (m *Metrics) TrackInBoundTraffic(value int64)

TrackInBoundTraffic counts the received traffic by the snowflake proxy

func (*Metrics) TrackNewConnection

func (m *Metrics) TrackNewConnection()

TrackNewConnection counts the new connections

func (*Metrics) TrackOutBoundTraffic

func (m *Metrics) TrackOutBoundTraffic(value int64)

TrackOutBoundTraffic counts the transmitted traffic by the snowflake proxy

type SignalingServer

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

SignalingServer keeps track of the SignalingServer in use by the Snowflake

func (*SignalingServer) Post

func (s *SignalingServer) Post(path string, payload io.Reader) ([]byte, error)

Post sends a POST request to the SignalingServer

type SnowflakeProxy

type SnowflakeProxy struct {
	// STUNURL is the URL of the STUN server the proxy will use
	STUNURL string
	// BrokerURL is the URL of the Snowflake broker
	BrokerURL string
	// KeepLocalAddresses indicates whether local SDP candidates will be sent to the broker
	KeepLocalAddresses bool
	// RelayURL is the URL of the Snowflake server that all traffic will be relayed to
	RelayURL string
	// OutboundAddress specify an IP address to use as SDP host candidate
	OutboundAddress string
	// Ephemeral*Port limits the pool of ports that ICE UDP connections can allocate from
	EphemeralMinPort uint16
	EphemeralMaxPort uint16
	// RelayDomainNamePattern is the pattern specify allowed domain name for relay
	// If the pattern starts with ^ then an exact match is required.
	// The rest of pattern is the suffix of domain name.
	// There is no look ahead assertion when matching domain name suffix,
	// thus the string prepend the suffix does not need to be empty or ends with a dot.
	RelayDomainNamePattern string
	AllowNonTLSRelay       bool
	// NATTypeForceUnrestricted is an option used to force the NAT type as unrestricted
	// It's useful in cases where the probe does not work reliably
	NATTypeForceUnrestricted bool
	// NATProbeURL is the URL of the probe service we use for NAT checks
	NATProbeURL string
	// NATTypeMeasurementInterval is time before NAT type is retested
	NATTypeMeasurementInterval time.Duration
	// ProxyType is the type reported to the broker, if not provided it "standalone" will be used
	ProxyType       string
	EventDispatcher event.SnowflakeEventDispatcher

	// SummaryInterval is the time interval at which proxy stats will be logged
	SummaryInterval time.Duration
	// contains filtered or unexported fields
}

SnowflakeProxy is used to configure an embedded Snowflake in another Go application.

func (*SnowflakeProxy) Start

func (sf *SnowflakeProxy) Start() error

Start configures and starts a Snowflake, fully formed and special. Configuration values that are unset will default to their corresponding default values.

func (*SnowflakeProxy) Stop

func (sf *SnowflakeProxy) Stop()

Stop closes all existing connections and shuts down the Snowflake.

Jump to

Keyboard shortcuts

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