discovery

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package discovery implements the Psiphon discovery algorithms.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClassicDiscovery

func NewClassicDiscovery(discoveryValueHMACKey string) (*classicDiscovery, error)

func NewConsistentHashingDiscovery

func NewConsistentHashingDiscovery() (*consistentHashingDiscovery, error)

Types

type Discovery

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

Discovery is the combination of a discovery strategy with a set of discovery servers. It's safe for concurrent usage.

func MakeDiscovery

func MakeDiscovery(
	servers []*psinet.DiscoveryServer,
	strategy DiscoveryStrategy) *Discovery

MakeDiscovery creates a new Discovery instance, which uses the specified strategy with the given discovery servers.

func (*Discovery) SelectServers

func (d *Discovery) SelectServers(clientIP net.IP) []*psinet.DiscoveryServer

SelectServers selects new server entries to be "discovered" by the client, using the client's IP address as the input into the configured discovery algorithm.

func (*Discovery) Start

func (d *Discovery) Start()

Start starts discovery. Servers are discoverable when the current time falls within their discovery date range, i.e. DiscoveryDateRange[0] <= clk.Now() < DiscoveryDateRange[1].

func (*Discovery) Stop

func (d *Discovery) Stop()

Stop stops discovery and cleans up underlying resources. Stop should be invoked as soon as Discovery is no longer needed. Discovery should not be used after this because the set of discoverable servers will no longer be updated, so it may contain servers that are no longer discoverable and exclude servers that are.

type DiscoveryStrategy

type DiscoveryStrategy interface {
	// contains filtered or unexported methods
}

DiscoveryStrategy represents a discovery algorithm that selects server entries to be "discovered" by a client. Implementations must be safe for concurrent usage.

Jump to

Keyboard shortcuts

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