internal

package
v0.0.0-...-11a4688 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2016 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Link(a, b Linkable)

func MakePairedConnections

func MakePairedConnections(k1, k2 PublicKey) (Connection, Connection)

Types

type BloomReachabilityMap

type BloomReachabilityMap struct {
	Filters      []*bloom.BloomFilter
	Conglomerate *bloom.BloomFilter
}

func NewBloomReachabilityMap

func NewBloomReachabilityMap() *BloomReachabilityMap

func (*BloomReachabilityMap) AddEntry

func (m *BloomReachabilityMap) AddEntry(n types.NodeAddress)

func (*BloomReachabilityMap) Copy

func (*BloomReachabilityMap) Equal

func (*BloomReachabilityMap) Increment

func (m *BloomReachabilityMap) Increment()

func (*BloomReachabilityMap) IsReachable

func (m *BloomReachabilityMap) IsReachable(n types.NodeAddress) bool

func (*BloomReachabilityMap) Merge

type Connection

type Connection interface {
	ControlConnection
	DataConnection
	Key() PublicKey
	// My sides metadata
	MetaData() SSHMetaData
	OtherMetaData() SSHMetaData
	io.Closer
}

type ControlConnection

type ControlConnection interface {
	MapConnection
	ReceiptConnection
}

While the two connections use different messages, a working ControlConnection has both interfaces

type DataConnection

type DataConnection interface {
	SendPacket(types.Packet) error
	Packets() <-chan types.Packet
}

The actual data connection. Should be done at the layer two level in order to be able to send congestion signals

type FakeMoney

type FakeMoney struct {
}

func (FakeMoney) GetNewAddress

func (f FakeMoney) GetNewAddress() (string, chan uint64, error)

func (FakeMoney) MakePayment

func (f FakeMoney) MakePayment(amount int64, destination string) (chan bool, error)

type FrameData

type FrameData struct {
	FullNodeAddr types.NodeAddress
	LLAddrStr    string
	Port         uint16
}

type Ledger

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

This keeps track of our outstanding owed payments and provides an interface to send payments. It does not create payments on its own. There are really only a few interesting pieces of data you will want to know about. How much we should pay someone, and how much debt + how long it has been since someone paid us (aka stop relaying to them if they haven't paid recently enough or the outstanding balance is too high).

func (*Ledger) AddAddress

func (p *Ledger) AddAddress(address string, c chan uint64)

func (*Ledger) AddConnection

func (p *Ledger) AddConnection(n types.NodeAddress, c Connection)

func (*Ledger) Close

func (p *Ledger) Close() error

func (*Ledger) IncomingDebt

func (p *Ledger) IncomingDebt(n types.NodeAddress) int64

func (*Ledger) OutgoingDebt

func (p *Ledger) OutgoingDebt(n types.NodeAddress) int64

func (*Ledger) RecordPayment

func (p *Ledger) RecordPayment(destination types.NodeAddress, amount int64, confirmed chan bool)

Waits for the payment to be confirmed and records it in the Ledger.

type Linkable

type Linkable interface {
	GetAddress() PublicKey
	AddConnection(Connection)
}

type Logger

type Logger interface {
	LogBloomFilter(*BloomReachabilityMap) error
	LogRoutingDecision(types.NodeAddress, types.NodeAddress, int, int64, types.PacketHash) error
	LogPacketReceipt(types.PacketHash) error
}

Interface for something that can log routing decisions

type MapConnection

type MapConnection interface {
	SendMap(*BloomReachabilityMap) error
	ReachabilityMaps() <-chan *BloomReachabilityMap
}

Layer three interfaces for network control traffic

type NeighborFinder

type NeighborFinder struct {
	Link_local_address net.IP
	// contains filtered or unexported fields
}

The layer two protocol takes a layer two device and returns the hash of the Public Key of all neighbors it can find.

func NewNeighborFinder

func NewNeighborFinder(pk PublicKey, Link_local_address net.IP, port uint16) NeighborFinder

func (NeighborFinder) Find

func (n NeighborFinder) Find(mac []byte, frw l2.FrameReadWriter) (<-chan *FrameData, error)

type Node

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

A Node includes various functions which are called by Server but shouldn't be publicly exposed.

func NewNode

func NewNode(pk PrivateKey, m types.Money, receipt_ticker <-chan time.Time, payment_ticker <-chan time.Time, route_logger Logger) *Node

func (*Node) AddConnection

func (n *Node) AddConnection(c Connection)

func (*Node) Close

func (n *Node) Close() error

func (*Node) GetAddress

func (n *Node) GetAddress() PublicKey

func (*Node) GetNewAddress

func (n *Node) GetNewAddress() string

func (*Node) GetNodeAddress

func (n *Node) GetNodeAddress() types.NodeAddress

func (*Node) ID

func (n *Node) ID() PrivateKey

func (*Node) IsReachable

func (n *Node) IsReachable(addr types.NodeAddress) bool

func (*Node) Packets

func (n *Node) Packets() <-chan types.Packet

func (*Node) SendPacket

func (n *Node) SendPacket(p types.Packet) error

type PacketReceipt

type PacketReceipt struct {
	Tree      merklenode
	Signature Signature
}

func CreateMerkleReceipt

func CreateMerkleReceipt(key PrivateKey, packets []types.PacketHash) PacketReceipt

func (PacketReceipt) ListPackets

func (m PacketReceipt) ListPackets() []types.PacketHash

func (PacketReceipt) Source

func (m PacketReceipt) Source() types.NodeAddress

func (PacketReceipt) Verify

func (m PacketReceipt) Verify() error

type PrivateKey

type PrivateKey struct {
	K *ecdsa.PrivateKey
}

func NewECDSAKey

func NewECDSAKey() (PrivateKey, error)

func (PrivateKey) MarshalJSON

func (e PrivateKey) MarshalJSON() ([]byte, error)

func (PrivateKey) PublicKey

func (p PrivateKey) PublicKey() PublicKey

func (PrivateKey) Sign

func (p PrivateKey) Sign(m []byte) Signature

func (*PrivateKey) UnmarshalJSON

func (e *PrivateKey) UnmarshalJSON(b []byte) error

type PublicKey

type PublicKey ecdsa.PublicKey

func (PublicKey) Hash

func (e PublicKey) Hash() types.NodeAddress

func (PublicKey) MarshalJSON

func (e PublicKey) MarshalJSON() ([]byte, error)

func (*PublicKey) UnmarshalJSON

func (e *PublicKey) UnmarshalJSON(b []byte) error

type RPCMoney

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

RPCMoney represents a Money system which is backed by a bitcoin daemon over an RPC connection.

func NewRPCMoney

func NewRPCMoney(host, user, pass string) (*RPCMoney, error)

func (*RPCMoney) GetNewAddress

func (r *RPCMoney) GetNewAddress() (string, chan uint64, error)

Returns the address + a channel down which all balance changes will be sent.

func (*RPCMoney) MakePayment

func (r *RPCMoney) MakePayment(amount int64, destination string) (chan bool, error)

Returns a channel which will receive a nil once the payment is confirmed , or an error if it isn't confirmed / errors.

type ReceiptConnection

type ReceiptConnection interface {
	SendReceipt(PacketReceipt) error
	PacketReceipts() <-chan PacketReceipt
}

type Router

type Router struct {
	*Ledger
	// contains filtered or unexported fields
}

A Router handles all routing tasks that don't involve the local machine including connection management, reachability handling, packet receipt relaying, and (outstanding) payment tracking. AKA anything which doesn't need the private key.

func NewRouter

func NewRouter(pk PublicKey, route_logger Logger) *Router

func (*Router) AddConnection

func (r *Router) AddConnection(c Connection)

func (*Router) Close

func (r *Router) Close() error

func (*Router) Connections

func (r *Router) Connections() []Connection

func (Router) FindPossibleDests

func (m Router) FindPossibleDests(id types.NodeAddress,
	src types.NodeAddress) ([]types.NodeAddress, error)

Finds the set of nodes that we could send the packet to. Args:

id: The destination node.
src: The source node. (So we don't send it backwards.)

Returns:

All the nodes that we could possibly send the packet to.

func (*Router) GetAddress

func (r *Router) GetAddress() PublicKey

func (Router) HandleConnection

func (m Router) HandleConnection(id types.NodeAddress, c MapConnection)

func (Router) PacketHashes

func (r Router) PacketHashes() <-chan types.PacketHash

func (Router) Packets

func (r Router) Packets() <-chan types.Packet

func (Router) Routes

func (r Router) Routes() <-chan routingDecision

func (Router) SendPacket

func (r Router) SendPacket(p types.Packet) error

func (Router) SendReceipt

func (r Router) SendReceipt(receipt PacketReceipt)

type SSHChannel

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

Represents a single ssh channel, which is being written to by a Encoder / Decoder.

type SSHConnection

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

Represents an active SSH connection with another host. Contains multiple channels passing various message types. Satisfies the Connection interface.

func EstablishSSH

func EstablishSSH(c net.Conn, address string, key PrivateKey, metadata SSHMetaData) (*SSHConnection, error)

func NewSSHConnection

func NewSSHConnection(conn ssh.Conn, chans <-chan ssh.NewChannel, reqs <-chan *ssh.Request, key PrivateKey, metadata SSHMetaData) *SSHConnection

Constructs a new SSHConnection given the various items returned by the /x/c/ssh library. Does *not* call listen() or connect() on the SSHConnection, which is required to establish the various required channels.

func (*SSHConnection) Close

func (s *SSHConnection) Close() error

func (*SSHConnection) Key

func (s *SSHConnection) Key() PublicKey

func (*SSHConnection) MetaData

func (s *SSHConnection) MetaData() SSHMetaData

func (*SSHConnection) OtherMetaData

func (s *SSHConnection) OtherMetaData() SSHMetaData

func (*SSHConnection) PacketReceipts

func (s *SSHConnection) PacketReceipts() <-chan PacketReceipt

func (*SSHConnection) Packets

func (s *SSHConnection) Packets() <-chan types.Packet

func (*SSHConnection) ReachabilityMaps

func (s *SSHConnection) ReachabilityMaps() <-chan *BloomReachabilityMap

func (*SSHConnection) SendMap

func (s *SSHConnection) SendMap(m *BloomReachabilityMap) error

func (*SSHConnection) SendPacket

func (s *SSHConnection) SendPacket(p types.Packet) error

func (*SSHConnection) SendReceipt

func (s *SSHConnection) SendReceipt(r PacketReceipt) error

type SSHListener

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

func ListenSSH

func ListenSSH(c net.Listener, key PrivateKey, metadata func() SSHMetaData) *SSHListener

func (*SSHListener) Connections

func (l *SSHListener) Connections() <-chan *SSHConnection

func (*SSHListener) Error

func (l *SSHListener) Error() error

type SSHMetaData

type SSHMetaData struct {
	Payment_Address string
	// Will be generated on the fly.
	Sig Signature
}

type Signature

type Signature struct {
	R *big.Int
	S *big.Int
	K PublicKey
	M []byte
}

func (Signature) Key

func (e Signature) Key() PublicKey

func (Signature) Signed

func (e Signature) Signed() []byte

func (Signature) Verify

func (e Signature) Verify() error

type TestDataConnection

type TestDataConnection struct {
	In  chan types.Packet
	Out chan types.Packet
}

func (TestDataConnection) Packets

func (c TestDataConnection) Packets() <-chan types.Packet

func (TestDataConnection) SendPacket

func (c TestDataConnection) SendPacket(m types.Packet) error

Jump to

Keyboard shortcuts

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