connectivity

package module
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: MIT Imports: 4 Imported by: 13

README

connectivity

A library providing an ACN (Anonymous Communication Network ) networking abstraction

Supported ACNs

  • Tor v3 Onion Services

Environment Variables

  • TOR_LD_LIBRARY_PATH - override the library path given to the Tor process as different from the one given to the parent process.
  • CWTCH_RESTRICT_PORTS - forces connectivity to bind to a subset of ports 15000-15378
  • CWTCH_BIND_EXTERNAL_WHONIX - forces connectivity to bind to external interfaces (only supported/recommended on certain Whonix-based setups. Please open an issue if you think this should be expanded.)

Requirements for ACN Support

  • Reference an EndPoint via a string / hostname
  • Maintain an endpoint via a PublicKey (the underlying crypto is the responsibility of the implementation)

Using

Each ACN implementation provides a specific start function that takes in the required parameters to e.g. find a specific binary on the system, attempt to talk to a specific system service or launch an in-memory networking manager:

    acn, err := NewTorACN(".", "", 9051, HashedPasswordAuthenticator{"examplehasedpassword"})
    if err != nil {
        t.Error(err)
        return
    }

At this point the ACN is responsible for setting up the networking interface, the result of which can be checked via the Status callback:

    acn.SetStatusCallback(getStatusCallback(progChan))

    progress := 0
    for progress < 100 {
        progress = <-progChan
    }

Once initialized the ACN can be used to open new connections:

    conn,err := acn.Open(hostname);

Or host a service on the ACN:

    ls,err := acn.Listen(identity, port) ;

We also provide closing and restart functionality for managing the networking service:

    acn.Restart()

and

    acn.Close()

Documentation

Index

Constants

View Source
const (
	// CannotResolveLocalTCPAddressError is thrown when a local ricochet connection has the wrong format.
	CannotResolveLocalTCPAddressError = Error("CannotResolveLocalTCPAddressError")
	// CannotDialLocalTCPAddressError is thrown when a connection to a local ricochet address fails.
	CannotDialLocalTCPAddressError = Error("CannotDialLocalTCPAddressError")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ACN

type ACN interface {
	// GetBootstrapStatus returns an int 0-100 on the percent the bootstrapping of the underlying network is at and an optional string message
	//  On Network down it returns -1
	//  On ACN error state it returns -2
	GetBootstrapStatus() (int, string)
	// WaitTillBootstrapped Blocks until underlying network is bootstrapped
	WaitTillBootstrapped() error
	// Sets the callback function to be called when ACN status changes
	SetStatusCallback(callback func(int, string))

	GetStatusCallback() func(int, string)

	// Sets the callback function to be called when ACN reboots to emit the version
	SetVersionCallback(callback func(string))

	GetVersionCallback() func(string)

	// Restarts the underlying connection
	Restart()

	// Open takes a hostname and returns a net.conn to the derived endpoint
	// Open allows a client to resolve various hostnames to connections
	Open(hostname string) (net.Conn, string, error)

	// Listen takes a private key and a port and returns a ListenService for it
	Listen(identity PrivateKey, port int) (ListenService, error)

	// Get PID
	GetPID() (int, error)

	// GetVersion returns a string of what the ACN returns when asked for a version
	GetVersion() string

	GetInfo(onion string) (map[string]string, error)

	Close()
}

ACN is Anonymous Communication Network implementation wrapper that supports Open for new connections and Listen to accept connections

func NewLocalACN added in v1.1.0

func NewLocalACN() ACN

NewLocalACN returns a for testing use only local clearnet implementation of a ACN interface

type Error

type Error string

Error captures various common ricochet errors

func (Error) Error

func (e Error) Error() string

type ErrorACN added in v1.6.0

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

ErrorACN - a status-callback safe errored ACN. Use this when ACN construction goes wrong and you need a safe substitute that can later be replaced with a working ACN without impacting calling clients.

func NewErrorACN added in v1.10.0

func NewErrorACN(err error) ErrorACN

func (*ErrorACN) Close added in v1.6.0

func (e *ErrorACN) Close()

func (*ErrorACN) GetBootstrapStatus added in v1.6.0

func (e *ErrorACN) GetBootstrapStatus() (int, string)

func (*ErrorACN) GetInfo added in v1.7.0

func (e *ErrorACN) GetInfo(addr string) (map[string]string, error)

func (*ErrorACN) GetPID added in v1.6.0

func (e *ErrorACN) GetPID() (int, error)

func (*ErrorACN) GetStatusCallback added in v1.8.5

func (e *ErrorACN) GetStatusCallback() func(int, string)

func (*ErrorACN) GetVersion added in v1.6.0

func (e *ErrorACN) GetVersion() string

func (*ErrorACN) GetVersionCallback added in v1.8.5

func (e *ErrorACN) GetVersionCallback() func(string)

func (*ErrorACN) Listen added in v1.6.0

func (e *ErrorACN) Listen(identity PrivateKey, port int) (ListenService, error)

func (*ErrorACN) Open added in v1.6.0

func (e *ErrorACN) Open(hostname string) (net.Conn, string, error)

func (*ErrorACN) Restart added in v1.6.0

func (e *ErrorACN) Restart()

func (*ErrorACN) SetStatusCallback added in v1.6.0

func (e *ErrorACN) SetStatusCallback(callback func(int, string))

func (*ErrorACN) SetVersionCallback added in v1.8.4

func (e *ErrorACN) SetVersionCallback(callback func(string))

func (*ErrorACN) WaitTillBootstrapped added in v1.6.0

func (e *ErrorACN) WaitTillBootstrapped() error

type ListenService

type ListenService interface {
	// AddressFull is the full network address, ex: rsjeuxzlexy4fvo75vrdtj37nrvlmvbw57n5mhypcjpzv3xkka3l4yyd.onion:9878
	AddressFull() string

	Accept() (net.Conn, error)
	Close()
}

ListenService is an address that was opened with Listen() and can Accept() new connections

type PrivateKey

type PrivateKey interface{}

PrivateKey represents a private key using an unspecified algorithm.

type ProxyACN added in v1.6.0

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

ProxyACN because there is rarely a problem that can't be solved by another layer of indirection. ACN is a core resource that many parts of a system may need access too e.g. all clients and servers need an instance and a UI may also need status information and a configuration interface. We want to allow configuration and replacement of an ACN without impacting the API of all downstream systems - introducing ProxyACN - a wrapper around an ACN that allows safe replacement of a running ACN that is transparent to callers.

func NewProxyACN added in v1.6.0

func NewProxyACN(acn ACN) ProxyACN

func (*ProxyACN) Close added in v1.6.0

func (p *ProxyACN) Close()

func (*ProxyACN) GetBootstrapStatus added in v1.6.0

func (p *ProxyACN) GetBootstrapStatus() (int, string)

func (*ProxyACN) GetInfo added in v1.7.0

func (p *ProxyACN) GetInfo(addr string) (map[string]string, error)

func (*ProxyACN) GetPID added in v1.6.0

func (p *ProxyACN) GetPID() (int, error)

func (*ProxyACN) GetStatusCallback added in v1.8.5

func (p *ProxyACN) GetStatusCallback() func(int, string)

func (*ProxyACN) GetVersion added in v1.6.0

func (p *ProxyACN) GetVersion() string

func (*ProxyACN) GetVersionCallback added in v1.8.5

func (p *ProxyACN) GetVersionCallback() func(string)

func (*ProxyACN) Listen added in v1.6.0

func (p *ProxyACN) Listen(identity PrivateKey, port int) (ListenService, error)

func (*ProxyACN) Open added in v1.6.0

func (p *ProxyACN) Open(hostname string) (net.Conn, string, error)

func (*ProxyACN) ReplaceACN added in v1.6.0

func (p *ProxyACN) ReplaceACN(acn ACN)

ReplaceACN closes down the current ACN and replaces it with a new ACN.

func (*ProxyACN) Restart added in v1.6.0

func (p *ProxyACN) Restart()

func (*ProxyACN) SetStatusCallback added in v1.6.0

func (p *ProxyACN) SetStatusCallback(callback func(int, string))

func (*ProxyACN) SetVersionCallback added in v1.8.4

func (p *ProxyACN) SetVersionCallback(callback func(string))

func (*ProxyACN) WaitTillBootstrapped added in v1.6.0

func (p *ProxyACN) WaitTillBootstrapped() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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