Documentation ¶
Index ¶
- Constants
- Variables
- type Interface
- func (f *Interface) AddPeer(p *Peer) error
- func (f *Interface) Close() error
- func (f *Interface) GetPeers() []*Peer
- func (f *Interface) RemovePeer(pubkey []byte) error
- func (f *Interface) Run() error
- func (f *Interface) SetPeers(peers []*Peer) error
- func (f *Interface) SetPresharedKey(k []byte) error
- func (f *Interface) SetPrivateKey(k []byte) error
- type InterfaceConfig
- type PacketQueue
- type Peer
- type RouteTable
- func (rt RouteTable) Clear()
- func (rt RouteTable) Insert(r *net.IPNet, p *peer) error
- func (rt RouteTable) Lookup(ip net.IP) (p *peer, err error)
- func (rt RouteTable) LookupFromPacket(packet []byte) (p *peer, err error)
- func (rt RouteTable) Remove(r *net.IPNet) error
- func (rt RouteTable) RemoveByPeer(p *peer) error
- type UDPConn
Constants ¶
const ( CounterBitsTotal = 2048 BitsPerInt = strconv.IntSize CounterRedundantBits = BitsPerInt CounterWindowSize = CounterBitsTotal - BitsPerInt )
const ( RekeyAfterMessages = ^uint64(0) - 0xffff RejectAfterMessages = ^uint64(0) - CounterWindowSize - 1 RekeyTimeout = time.Duration(5) * time.Second RekeyAfterTime = time.Duration(120) * time.Second RejectAfterTime = time.Duration(180) * time.Second InitiationsPerSecond = time.Second / 50 MaxPeersPerDevice = ^uint16(0) )
Variables ¶
var ErrHostUnreachable = errors.New("Host unreachable")
var ErrNoKey = errors.New("No Key")
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface struct {
// contains filtered or unexported fields
}
An Interface communicates encrypted packets with peers.
func NewInterface ¶
func NewInterface(c InterfaceConfig) (*Interface, error)
func (*Interface) AddPeer ¶
AddPeer adds a peer to the interface configuration. If the peer, identified by its public key, already exists, then all configuration will be replaced with the new fields.
func (*Interface) RemovePeer ¶
RemovePeer removes the peer identified with the public key pubkey from the interface configuration.
func (*Interface) SetPeers ¶
SetPeers replaces all of the peers that the interface is configured for with a new list.
func (*Interface) SetPresharedKey ¶
SetPresharedKey changes the pre-shared key for the interface.
func (*Interface) SetPrivateKey ¶
SetPrivateKey changes the private key for the interface. It is safe to call while the interface is running.
type InterfaceConfig ¶
type InterfaceConfig struct { // Outside is the connection that will be used to send and receive encrypted // packets with peers. It will be closed if Close is called on the Interface. Outside UDPConn // Inside is the interface that will be used to read plaintext packets // destined for peers and write decrypted packets received from peers. Each // Read must return a single IP packet to send to a peer, and each Write // will provide a single received IP packet. Inside io.ReadWriter // PrivateKey holds the static Curve25519 private key for the interface. If // set, it must be exactly 32 random bytes. PrivateKey []byte // If set, it must be exactly 32 random bytes. PresharedKey []byte // Peers is the initial set of peers that the interface will communicate // with. Peers []*Peer }
An InterfaceConfig is the configuration used to create an interface.
type PacketQueue ¶
func (*PacketQueue) Append ¶
func (pq *PacketQueue) Append(v []byte)
func (*PacketQueue) BoundedAppend ¶
func (pq *PacketQueue) BoundedAppend(v []byte, maxSize int)
func (*PacketQueue) Len ¶
func (pq *PacketQueue) Len() int
func (*PacketQueue) Peek ¶
func (pq *PacketQueue) Peek() []byte
func (*PacketQueue) Pop ¶
func (pq *PacketQueue) Pop() (v []byte)
func (*PacketQueue) Steal ¶
func (pq *PacketQueue) Steal() *PacketQueue
type Peer ¶
type Peer struct { // PublicKey is the static Curve25519 public key of the peer. It must be // exactly 32 bytes. PublicKey []byte // AllowedIPs is the list of IP networks that will be routed to and accepted // from the peer. AllowedIPs []*net.IPNet // Endpoint is the network address that packets destined for the peer will // be sent to. If it is nil, packets destined for this peer will not be // routable until an incoming handshake is received. Endpoint *net.UDPAddr // PersistentKeepaliveInterval, if non-zero, is the number of seconds // between keep-alive packets sent to the peer. PersistentKeepaliveInterval int // LastHandshake is the timestamp of the last successful handshake with the // peer. This field is read-only. LastHandshake time.Time // RxBytes is the number of bytes received from the peer. This field is // read-only. RxBytes int64 // TxBytes is the number of bytes transmitted to the peer. This field is // read-only. TxBytes int64 }
A Peer is a remote endpoint that can be communicated with via an Interface.
type RouteTable ¶
func NewRouteTable ¶
func NewRouteTable() RouteTable
NewRouteTable creates a new routing table that handles both IPv4/IPv6 routes.
func (RouteTable) Insert ¶
func (rt RouteTable) Insert(r *net.IPNet, p *peer) error
Insert inserts the entry into the routing table. If a previous entry exists, it is replaced.
func (RouteTable) Lookup ¶
func (rt RouteTable) Lookup(ip net.IP) (p *peer, err error)
Lookup returns the peer matching the longest prefix match for the given ip.
func (RouteTable) LookupFromPacket ¶
func (rt RouteTable) LookupFromPacket(packet []byte) (p *peer, err error)
func (RouteTable) Remove ¶
func (rt RouteTable) Remove(r *net.IPNet) error
Remove deletes the entry from the routing table.
func (RouteTable) RemoveByPeer ¶
func (rt RouteTable) RemoveByPeer(p *peer) error
RemoveByPeer deletes all entries associated with the given peer.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
internal
|
|
skip32
Package skip32 implements the Skip32 blockcipher SKIP32 is a 32-bit block cipher based on SKIPJACK, written by Greg Rose of QUALCOMM Australia.
|
Package skip32 implements the Skip32 blockcipher SKIP32 is a 32-bit block cipher based on SKIPJACK, written by Greg Rose of QUALCOMM Australia. |