e3x

package
v0.0.0-...-c0ffc74 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2015 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrListenerClosed          = errors.New("listener closed")
	ErrListenerBacklogTooLarge = errors.New("listener backlog too large")
	ErrListenerInvalidType     = errors.New("listener inavlid channel type")
)
View Source
var ErrInvalidHandshake = errors.New("e3x: invalid handshake")
View Source
var ErrNoAddress = errors.New("e3x: no addresses")
View Source
var ErrNoKeys = errors.New("e3x: no keys")
View Source
var ErrStopPropagation = errors.New("observer: stop propagation")
View Source
var ErrTimeout = errors.New("e3x: deadline reached")
View Source
var ErrUnidentifiable = errors.New("unidentifiable identity")

Functions

This section is empty.

Types

type BrokenChannelError

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

func (*BrokenChannelError) Error

func (err *BrokenChannelError) Error() string

type BrokenExchangeError

type BrokenExchangeError hashname.H

func (BrokenExchangeError) Error

func (err BrokenExchangeError) Error() string

type Channel

type Channel struct {
	TID tracer.ID
	// contains filtered or unexported fields
}

func (*Channel) Close

func (c *Channel) Close() error

func (*Channel) Error

func (c *Channel) Error(err error) error

func (*Channel) Errorf

func (c *Channel) Errorf(format string, args ...interface{}) error

func (*Channel) Exchange

func (c *Channel) Exchange() *Exchange

func (*Channel) Kill

func (c *Channel) Kill()

func (*Channel) LocalAddr

func (c *Channel) LocalAddr() net.Addr

LocalAddr returns the local network address.

func (*Channel) Read

func (c *Channel) Read(b []byte) (int, error)

Read implements the net.Conn Read method.

func (*Channel) ReadPacket

func (c *Channel) ReadPacket() (*lob.Packet, error)

func (*Channel) RemoteAddr

func (c *Channel) RemoteAddr() net.Addr

RemoteAddr returns the remote network address.

func (*Channel) RemoteHashname

func (c *Channel) RemoteHashname() hashname.H

func (*Channel) RemoteIdentity

func (c *Channel) RemoteIdentity() *Identity

func (*Channel) SetDeadline

func (c *Channel) SetDeadline(d time.Time) error

SetDeadline implements the net.Conn SetDeadline method.

func (*Channel) SetReadDeadline

func (c *Channel) SetReadDeadline(d time.Time) error

SetReadDeadline implements the net.Conn SetReadDeadline method.

func (*Channel) SetWriteDeadline

func (c *Channel) SetWriteDeadline(d time.Time) error

SetWriteDeadline implements the net.Conn SetWriteDeadline method.

func (*Channel) Write

func (c *Channel) Write(b []byte) (int, error)

Write implements the net.Conn Write method.

func (*Channel) WritePacket

func (c *Channel) WritePacket(pkt *lob.Packet) error

func (*Channel) WritePacketTo

func (c *Channel) WritePacketTo(pkt *lob.Packet, p *Pipe) error

type ChannelHook

type ChannelHook struct {
	OnOpened func(*Endpoint, *Exchange, *Channel) error
	OnClosed func(*Endpoint, *Exchange, *Channel) error
}

type ChannelHooks

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

func (*ChannelHooks) Closed

func (s *ChannelHooks) Closed() error

func (*ChannelHooks) Opened

func (s *ChannelHooks) Opened() error

func (*ChannelHooks) Register

func (h *ChannelHooks) Register(hook ChannelHook)

type ChannelOption

type ChannelOption func(*Channel) error

type Endpoint

type Endpoint struct {
	TID tracer.ID // tracer id
	// contains filtered or unexported fields
}

Endpoint represents a Telehash endpoint.

func Open

func Open(options ...EndpointOption) (*Endpoint, error)

func (*Endpoint) Close

func (e *Endpoint) Close() error

func (*Endpoint) CreateExchange

func (e *Endpoint) CreateExchange(identity *Identity) (*Exchange, error)

CreateExchange returns the exchange for identity. If the exchange already exists it is simply returned otherwise a new exchange is created and registered. Note that CreateExchange does not Dial.

func (*Endpoint) DefaultChannelHooks

func (e *Endpoint) DefaultChannelHooks() *ChannelHooks

func (*Endpoint) DefaultExchangeHooks

func (e *Endpoint) DefaultExchangeHooks() *ExchangeHooks

func (*Endpoint) Dial

func (e *Endpoint) Dial(identifier Identifier) (*Exchange, error)

Dial will lookup the identity of identifier, get the exchange for the identity and dial the exchange.

func (*Endpoint) GetExchange

func (e *Endpoint) GetExchange(hashname hashname.H) *Exchange

func (*Endpoint) GetExchanges

func (e *Endpoint) GetExchanges() []*Exchange

func (*Endpoint) Hooks

func (e *Endpoint) Hooks() *EndpointHooks

func (*Endpoint) Identify

func (e *Endpoint) Identify(i Identifier) (*Identity, error)

func (*Endpoint) Listen

func (e *Endpoint) Listen(typ string, reliable bool) *Listener

Listen makes a new channel listener.

func (*Endpoint) LocalHashname

func (e *Endpoint) LocalHashname() hashname.H

func (*Endpoint) LocalIdentity

func (e *Endpoint) LocalIdentity() (*Identity, error)

func (*Endpoint) Log

func (e *Endpoint) Log() *logs.Logger

func (*Endpoint) Module

func (e *Endpoint) Module(key interface{}) Module

func (*Endpoint) Open

func (e *Endpoint) Open(i Identifier, typ string, reliable bool) (*Channel, error)

type EndpointHook

type EndpointHook struct {
	OnNetChanged func(e *Endpoint, up, down []net.Addr) error
	OnDropPacket func(e *Endpoint, msg []byte, conn net.Conn, reason error) error
}

type EndpointHooks

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

func (*EndpointHooks) DropPacket

func (s *EndpointHooks) DropPacket(msg []byte, conn net.Conn, reason error) error

func (*EndpointHooks) NetChanged

func (s *EndpointHooks) NetChanged(up, down []net.Addr) error

func (*EndpointHooks) Register

func (h *EndpointHooks) Register(hook EndpointHook)

type EndpointOption

type EndpointOption func(e *Endpoint) error

func DisableLog

func DisableLog() EndpointOption

func Keys

func Keys(keys cipherset.Keys) EndpointOption

func Log

func Log(w io.Writer) EndpointOption

func RegisterModule

func RegisterModule(key interface{}, mod Module) EndpointOption

func Transport

func Transport(config transports.Config) EndpointOption

type Exchange

type Exchange struct {
	TID tracer.ID
	// contains filtered or unexported fields
}

func (*Exchange) ActivePath

func (x *Exchange) ActivePath() net.Addr

ActivePath returns the path that is currently used for channel packets.

func (*Exchange) ActivePipe

func (x *Exchange) ActivePipe() *Pipe

ActivePipe returns the pipe that is currently used for channel packets.

func (*Exchange) AddPathCandidate

func (x *Exchange) AddPathCandidate(addr net.Addr)

AddPathCandidate adds a new path tto the exchange. The path is only used when it performs better than any other paths.

func (*Exchange) AddPipeConnection

func (x *Exchange) AddPipeConnection(conn net.Conn, addr net.Addr) (p *Pipe, added bool)

func (*Exchange) ApplyHandshake

func (x *Exchange) ApplyHandshake(handshake cipherset.Handshake, pipe *Pipe) (response *bufpool.Buffer, ok bool)

ApplyHandshake applies a (out-of-band) handshake to the exchange. When the handshake is accepted err is nil. When the handshake is a request-handshake and it is accepted response will contain a response-handshake packet.

func (*Exchange) Dial

func (x *Exchange) Dial() error

Dial exchanges the initial handshakes. It will timeout after 2 minutes.

func (*Exchange) GenerateHandshake

func (x *Exchange) GenerateHandshake() (*bufpool.Buffer, error)

GenerateHandshake can be used to generate a new handshake packet. This is useful when the exchange doesn't know where to send the handshakes yet.

func (*Exchange) KnownPaths

func (x *Exchange) KnownPaths() []net.Addr

KnownPaths returns all the know addresses of the remote endpoint.

func (*Exchange) KnownPipes

func (x *Exchange) KnownPipes() []*Pipe

KnownPipes returns all the know pipes of the remote endpoint.

func (*Exchange) LocalToken

func (x *Exchange) LocalToken() cipherset.Token

LocalToken returns the token identifying the local side of the exchange.

func (*Exchange) Open

func (x *Exchange) Open(typ string, reliable bool) (*Channel, error)

Open a channel.

func (*Exchange) RemoteHashname

func (x *Exchange) RemoteHashname() hashname.H

RemoteHashname returns the hashname of the remote peer.

func (*Exchange) RemoteIdentity

func (x *Exchange) RemoteIdentity() *Identity

RemoteIdentity returns the Identity of the remote peer.

func (*Exchange) RemoteToken

func (x *Exchange) RemoteToken() cipherset.Token

RemoteToken returns the token identifying the remote side of the exchange.

func (*Exchange) State

func (x *Exchange) State() ExchangeState

func (*Exchange) String

func (x *Exchange) String() string

type ExchangeHook

type ExchangeHook struct {
	OnOpened     func(*Endpoint, *Exchange) error
	OnClosed     func(*Endpoint, *Exchange, error) error
	OnDropPacket func(e *Endpoint, x *Exchange, msg []byte, pipe *Pipe, reason error) error
}

type ExchangeHooks

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

func (*ExchangeHooks) Closed

func (s *ExchangeHooks) Closed(reason error) error

func (*ExchangeHooks) DropPacket

func (s *ExchangeHooks) DropPacket(msg []byte, pipe *Pipe, reason error) error

func (*ExchangeHooks) Opened

func (s *ExchangeHooks) Opened() error

func (*ExchangeHooks) Register

func (h *ExchangeHooks) Register(hook ExchangeHook)

type ExchangeOption

type ExchangeOption func(e *Exchange) error

type ExchangeState

type ExchangeState uint8
const (
	ExchangeInitialising ExchangeState = 0

	ExchangeDialing ExchangeState = 1 << iota
	ExchangeIdle
	ExchangeActive
	ExchangeExpired
	ExchangeBroken
)

func (ExchangeState) IsClosed

func (s ExchangeState) IsClosed() bool

func (ExchangeState) IsOpen

func (s ExchangeState) IsOpen() bool

func (ExchangeState) String

func (s ExchangeState) String() string

type Identifier

type Identifier interface {
	String() string

	Identify(endpoint *Endpoint) (*Identity, error)
}

Identifier represents an identifing set of information which can be resolved into a full Identity.

func HashnameIdentifier

func HashnameIdentifier(hn hashname.H) Identifier

HashnameIdentifier returns an identifer which identifies an Identity using only information internal to an endpoint. In other words it will return the Identity associated with a hashname if that information is available within the endpoint.

type Identity

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

func NewIdentity

func NewIdentity(keys cipherset.Keys, parts cipherset.Parts, addrs []net.Addr) (*Identity, error)

func (*Identity) AddPathCandiate

func (i *Identity) AddPathCandiate(addr net.Addr) *Identity

func (*Identity) Addresses

func (i *Identity) Addresses() []net.Addr

func (*Identity) Hashname

func (i *Identity) Hashname() hashname.H

func (*Identity) Identify

func (i *Identity) Identify(e *Endpoint) (*Identity, error)

func (*Identity) Keys

func (i *Identity) Keys() cipherset.Keys

func (*Identity) MarshalJSON

func (i *Identity) MarshalJSON() ([]byte, error)

func (*Identity) String

func (i *Identity) String() string

func (*Identity) UnmarshalJSON

func (i *Identity) UnmarshalJSON(p []byte) error

type Listener

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

func (*Listener) Accept

func (l *Listener) Accept() (net.Conn, error)

func (*Listener) AcceptChannel

func (l *Listener) AcceptChannel() (*Channel, error)

func (*Listener) Addr

func (l *Listener) Addr() net.Addr

func (*Listener) Close

func (l *Listener) Close() error

type Module

type Module interface {
	// Init is called after the creating the endpoint and before openeing the endpoint transport.
	Init() error

	// Start is called after opening the endpoint transport.
	Start() error

	// Stop is called before closing the endpoint transport.
	Stop() error
}

Module must be implemented by endpoint modules.

type Pipe

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

func (*Pipe) Close

func (p *Pipe) Close() error

func (*Pipe) RemoteAddr

func (p *Pipe) RemoteAddr() net.Addr

func (*Pipe) Write

func (p *Pipe) Write(b *bufpool.Buffer) (int, error)

type Transports

type Transports interface {
	// Wrap must be called durring a Module.Init call. The existing endpoint
	// transport will be passed to and a valid transport must be returned.
	// Only use this module when you know what you are doeing.
	Wrap(f func(transports.Config) transports.Config)

	// LocalAddresses returns the list of discovered local addresses
	LocalAddresses() []net.Addr
}

Transports exposes the Wrap method

func TransportsFromEndpoint

func TransportsFromEndpoint(e *Endpoint) Transports

TransportsFromEndpoint returns the Transports module for Endpoint.

type UnreachableEndpointError

type UnreachableEndpointError hashname.H

func (UnreachableEndpointError) Error

func (err UnreachableEndpointError) Error() string

Directories

Path Synopsis
cs1a
Package cs1a implements Cipher Set 1a.
Package cs1a implements Cipher Set 1a.
cs1a/eccp
Elliptic Curve Compressed Point marshaler
Elliptic Curve Compressed Point marshaler
cs1a/ecdh
Elliptic curve Diffie–Hellman key sharing
Elliptic curve Diffie–Hellman key sharing
cs1a/secp160r1
Parameters for the secp160r1 Elliptic curve
Parameters for the secp160r1 Elliptic curve
cs3a
Package cs3a implements Cipher Set 3a.
Package cs3a implements Cipher Set 3a.

Jump to

Keyboard shortcuts

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