clientlib

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2018 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTimeout = errors.New("clientlib: tunnel connection timeout")

ErrTimeout is returned when the tunnel connection attempt fails due to timeout

Functions

This section is empty.

Types

type ClientParametersDelta

type ClientParametersDelta map[string]interface{}

ClientParametersDelta allows for fine-grained modification of parameters.ClientParameters. NOTE: Ordinary users of this library should never need this.

type NoticeEvent

type NoticeEvent struct {
	Data map[string]interface{} `json:"data"`
	Type string                 `json:"noticeType"`
}

NoticeEvent represents the notices emitted by tunnel core. It will be passed to noticeReceiver, if supplied. NOTE: Ordinary users of this library should never need this.

type Parameters

type Parameters struct {
	// Used as the directory for the datastore, remote server list, and obfuscasted
	// server list.
	// Empty string means the default will be used (current working directory).
	// nil means the values in the config file will be used.
	// Optional, but strongly recommended.
	DataRootDirectory *string

	// Overrides config.ClientPlatform. See config.go for details.
	// nil means the value in the config file will be used.
	// Optional, but strongly recommended.
	ClientPlatform *string

	// Overrides config.NetworkID. For details see:
	// https://godoc.org/github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon#NetworkIDGetter
	// nil means the value in the config file will be used. (If not set in the config,
	// an error will result.)
	// Empty string will produce an error.
	// Optional, but strongly recommended.
	NetworkID *string

	// Overrides config.EstablishTunnelTimeoutSeconds. See config.go for details.
	// nil means the EstablishTunnelTimeoutSeconds value in the config file will be used.
	// If there's no such value in the config file, the default will be used.
	// Zero means there will be no timeout.
	// Optional.
	EstablishTunnelTimeoutSeconds *int
}

Parameters provide an easier way to modify the tunnel config at runtime.

type PsiphonTunnel

type PsiphonTunnel struct {

	// The port on which the HTTP proxy is running
	HTTPProxyPort int
	// The port on which the SOCKS proxy is running
	SOCKSProxyPort int
	// contains filtered or unexported fields
}

PsiphonTunnel is the tunnel object. It can be used for stopping the tunnel and retrieving proxy ports.

func StartTunnel

func StartTunnel(ctx context.Context,
	configJSON []byte, embeddedServerEntryList string,
	params Parameters, paramsDelta ClientParametersDelta,
	noticeReceiver func(NoticeEvent)) (tunnel *PsiphonTunnel, err error)

StartTunnel makes a Psiphon tunnel connection. It returns an error if the connection was not successful. If the returned error is nil, the returned tunnel can be used to find out the proxy ports and subsequently stop the tunnel. ctx may be cancelable, if the caller wants to be able to interrupt the connection attempt, or context.Background(). configJSON will be passed to psiphon.LoadConfig to configure the tunnel. Required. embeddedServerEntryList is the encoded embedded server entry list. It is optional. params are config values that typically need to be overridden at runtime. paramsDelta contains changes that will be applied to the ClientParameters. NOTE: Ordinary users of this library should never need this and should pass nil. noticeReceiver, if non-nil, will be called for each notice emitted by tunnel core. NOTE: Ordinary users of this library should never need this and should pass nil.

func (*PsiphonTunnel) Stop

func (tunnel *PsiphonTunnel) Stop()

Stop stops/disconnects/shuts down the tunnel. It is safe to call when not connected.

Jump to

Keyboard shortcuts

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