Documentation ¶
Index ¶
- func Link(a, b Linkable)
- func MakePairedConnections(k1, k2 PublicKey) (Connection, Connection)
- type BloomReachabilityMap
- func (m *BloomReachabilityMap) AddEntry(n types.NodeAddress)
- func (m *BloomReachabilityMap) Copy() *BloomReachabilityMap
- func (m *BloomReachabilityMap) Equal(b *BloomReachabilityMap) bool
- func (m *BloomReachabilityMap) Increment()
- func (m *BloomReachabilityMap) IsReachable(n types.NodeAddress) bool
- func (m *BloomReachabilityMap) Merge(n *BloomReachabilityMap)
- type Connection
- type ControlConnection
- type DataConnection
- type FakeMoney
- type FrameData
- type Ledger
- func (p *Ledger) AddAddress(address string, c chan uint64)
- func (p *Ledger) AddConnection(n types.NodeAddress, c Connection)
- func (p *Ledger) Close() error
- func (p *Ledger) IncomingDebt(n types.NodeAddress) int64
- func (p *Ledger) OutgoingDebt(n types.NodeAddress) int64
- func (p *Ledger) RecordPayment(destination types.NodeAddress, amount int64, confirmed chan bool)
- type Linkable
- type Logger
- type MapConnection
- type NeighborFinder
- type Node
- func (n *Node) AddConnection(c Connection)
- func (n *Node) Close() error
- func (n *Node) GetAddress() PublicKey
- func (n *Node) GetNewAddress() string
- func (n *Node) GetNodeAddress() types.NodeAddress
- func (n *Node) ID() PrivateKey
- func (n *Node) IsReachable(addr types.NodeAddress) bool
- func (n *Node) Packets() <-chan types.Packet
- func (n *Node) SendPacket(p types.Packet) error
- type PacketReceipt
- type PrivateKey
- type PublicKey
- type RPCMoney
- type ReceiptConnection
- type Router
- func (r *Router) AddConnection(c Connection)
- func (r *Router) Close() error
- func (r *Router) Connections() []Connection
- func (m Router) FindPossibleDests(id types.NodeAddress, src types.NodeAddress) ([]types.NodeAddress, error)
- func (r *Router) GetAddress() PublicKey
- func (m Router) HandleConnection(id types.NodeAddress, c MapConnection)
- func (r Router) PacketHashes() <-chan types.PacketHash
- func (r Router) Packets() <-chan types.Packet
- func (r Router) Routes() <-chan routingDecision
- func (r Router) SendPacket(p types.Packet) error
- func (r Router) SendReceipt(receipt PacketReceipt)
- type SSHChannel
- type SSHConnection
- func (s *SSHConnection) Close() error
- func (s *SSHConnection) Key() PublicKey
- func (s *SSHConnection) MetaData() SSHMetaData
- func (s *SSHConnection) OtherMetaData() SSHMetaData
- func (s *SSHConnection) PacketReceipts() <-chan PacketReceipt
- func (s *SSHConnection) Packets() <-chan types.Packet
- func (s *SSHConnection) ReachabilityMaps() <-chan *BloomReachabilityMap
- func (s *SSHConnection) SendMap(m *BloomReachabilityMap) error
- func (s *SSHConnection) SendPacket(p types.Packet) error
- func (s *SSHConnection) SendReceipt(r PacketReceipt) error
- type SSHListener
- type SSHMetaData
- type Signature
- type TestDataConnection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 (m *BloomReachabilityMap) Copy() *BloomReachabilityMap
func (*BloomReachabilityMap) Equal ¶
func (m *BloomReachabilityMap) Equal(b *BloomReachabilityMap) bool
func (*BloomReachabilityMap) Increment ¶
func (m *BloomReachabilityMap) Increment()
func (*BloomReachabilityMap) IsReachable ¶
func (m *BloomReachabilityMap) IsReachable(n types.NodeAddress) bool
func (*BloomReachabilityMap) Merge ¶
func (m *BloomReachabilityMap) Merge(n *BloomReachabilityMap)
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 ¶
The actual data connection. Should be done at the layer two level in order to be able to send congestion signals
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 (*Ledger) AddConnection ¶
func (p *Ledger) AddConnection(n types.NodeAddress, c Connection)
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 ¶
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 (*Node) AddConnection ¶
func (n *Node) AddConnection(c Connection)
func (*Node) GetAddress ¶
func (*Node) GetNewAddress ¶
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
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 ¶
func (PublicKey) Hash ¶
func (e PublicKey) Hash() types.NodeAddress
func (PublicKey) MarshalJSON ¶
func (*PublicKey) UnmarshalJSON ¶
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 (*RPCMoney) GetNewAddress ¶
Returns the address + a channel down which all balance changes will be sent.
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 (*Router) AddConnection ¶
func (r *Router) AddConnection(c Connection)
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 (Router) HandleConnection ¶
func (m Router) HandleConnection(id types.NodeAddress, c MapConnection)
func (Router) PacketHashes ¶
func (r Router) PacketHashes() <-chan types.PacketHash
func (Router) SendPacket ¶
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 TestDataConnection ¶
func (TestDataConnection) Packets ¶
func (c TestDataConnection) Packets() <-chan types.Packet
func (TestDataConnection) SendPacket ¶
func (c TestDataConnection) SendPacket(m types.Packet) error