types

package
v0.0.0-...-26ee366 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const FrameHeaderLength = 10

4 magic bytes, 1 byte version, 1 byte type, 2 bytes extra, 2 bytes frame length

View Source
const MaxFrameSize = 65535*3 + 16

MaxFrameSize is the maximum size that a single frame can be, including all headers.

View Source
const MaxPayloadSize = 65535

MaxPayloadSize is the maximum size that a single frame can contain as a payload, not including headers.

View Source
const SignatureWithHopMinSize = ed25519.PublicKeySize + ed25519.SignatureSize + 1

Variables

View Source
var FrameMagicBytes = []byte{0x70, 0x69, 0x6e, 0x65}
View Source
var FullMask = PublicKey{
	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
}

Functions

This section is empty.

Types

type Coordinates

type Coordinates []SwitchPortID

func (*Coordinates) Copy

func (a *Coordinates) Copy() Coordinates

func (Coordinates) DistanceTo

func (a Coordinates) DistanceTo(b Coordinates) int

func (Coordinates) EqualTo

func (p Coordinates) EqualTo(o Coordinates) bool

func (Coordinates) Len

func (s Coordinates) Len() int

func (Coordinates) Less

func (s Coordinates) Less(i, j int) bool

func (Coordinates) MarshalBinary

func (p Coordinates) MarshalBinary(buf []byte) (int, error)

func (Coordinates) MarshalJSON

func (p Coordinates) MarshalJSON() ([]byte, error)

func (Coordinates) Network

func (s Coordinates) Network() string

func (Coordinates) String

func (s Coordinates) String() string

func (Coordinates) Swap

func (s Coordinates) Swap(i, j int)

func (*Coordinates) UnmarshalBinary

func (p *Coordinates) UnmarshalBinary(b []byte) (int, error)

type Frame

type Frame struct {
	Version        FrameVersion
	Type           FrameType
	Extra          [2]byte
	Destination    Coordinates
	DestinationKey PublicKey
	Source         Coordinates
	SourceKey      PublicKey
	Watermark      VirtualSnakeWatermark
	Payload        []byte
}

func (*Frame) MarshalBinary

func (f *Frame) MarshalBinary(buffer []byte) (int, error)

func (*Frame) Reset

func (f *Frame) Reset()

func (*Frame) UnmarshalBinary

func (f *Frame) UnmarshalBinary(data []byte) (int, error)

type FrameType

type FrameType uint8
const (
	TypeKeepalive             FrameType = iota // protocol frame, direct to peers only
	TypeTreeAnnouncement                       // protocol frame, bypasses queues
	TypeTreeRouted                             // traffic frame, forwarded using tree routing
	TypeVirtualSnakeBootstrap                  // protocol frame, forwarded using SNEK
	TypeVirtualSnakeRouted                     // traffic frame, forwarded using SNEK
)

func (FrameType) String

func (t FrameType) String() string

type FrameVersion

type FrameVersion uint8
const (
	Version0 FrameVersion = iota
)

func (FrameVersion) String

func (v FrameVersion) String() string

type Logger

type Logger interface {
	Println(...interface{})
	Printf(string, ...interface{})
}

type PrivateKey

type PrivateKey [ed25519.PrivateKeySize]byte

func (PrivateKey) Public

func (a PrivateKey) Public() PublicKey

type PublicKey

type PublicKey [ed25519.PublicKeySize]byte

func (PublicKey) CompareTo

func (a PublicKey) CompareTo(b PublicKey) int

func (PublicKey) EqualMaskTo

func (a PublicKey) EqualMaskTo(b, m PublicKey) bool

func (PublicKey) IsEmpty

func (a PublicKey) IsEmpty() bool

func (PublicKey) MarshalJSON

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

func (PublicKey) Network

func (a PublicKey) Network() string

func (PublicKey) String

func (a PublicKey) String() string

type Root

type Root struct {
	RootPublicKey PublicKey `json:"root_public_key"`
	RootSequence  Varu64    `json:"root_sequence"`
}

func (*Root) EqualTo

func (a *Root) EqualTo(b *Root) bool

func (*Root) Length

func (r *Root) Length() int

func (*Root) MinLength

func (r *Root) MinLength() int

type Signature

type Signature [ed25519.SignatureSize]byte

type SignatureWithHop

type SignatureWithHop struct {
	Hop       Varu64
	PublicKey PublicKey
	Signature Signature
}

func (*SignatureWithHop) MarshalBinary

func (a *SignatureWithHop) MarshalBinary(data []byte) (int, error)

func (*SignatureWithHop) UnmarshalBinary

func (a *SignatureWithHop) UnmarshalBinary(data []byte) (int, error)

type SwitchAnnouncement

type SwitchAnnouncement struct {
	Root
	Signatures []SignatureWithHop
}

func (*SwitchAnnouncement) AncestorParent

func (a *SwitchAnnouncement) AncestorParent() PublicKey

func (*SwitchAnnouncement) Coords

func (a *SwitchAnnouncement) Coords() Coordinates

func (*SwitchAnnouncement) IsLoopOrChildOf

func (a *SwitchAnnouncement) IsLoopOrChildOf(pk PublicKey) bool

func (*SwitchAnnouncement) MarshalBinary

func (a *SwitchAnnouncement) MarshalBinary(buffer []byte) (int, error)

func (*SwitchAnnouncement) PeerCoords

func (a *SwitchAnnouncement) PeerCoords() Coordinates

func (*SwitchAnnouncement) SanityCheck

func (a *SwitchAnnouncement) SanityCheck(from PublicKey) error

func (*SwitchAnnouncement) Sign

func (a *SwitchAnnouncement) Sign(privKey ed25519.PrivateKey, forPort SwitchPortID) error

func (*SwitchAnnouncement) UnmarshalBinary

func (a *SwitchAnnouncement) UnmarshalBinary(data []byte) (int, error)

type SwitchPortID

type SwitchPortID Varu64

type Varu64

type Varu64 uint64

func (Varu64) Length

func (n Varu64) Length() int

func (Varu64) MarshalBinary

func (n Varu64) MarshalBinary(b []byte) (int, error)

func (Varu64) MinLength

func (n Varu64) MinLength() int

func (*Varu64) UnmarshalBinary

func (n *Varu64) UnmarshalBinary(buf []byte) (int, error)

type VirtualSnakeBootstrap

type VirtualSnakeBootstrap struct {
	Sequence Varu64
	Root
	Signature [ed25519.SignatureSize]byte
}

func (*VirtualSnakeBootstrap) MarshalBinary

func (v *VirtualSnakeBootstrap) MarshalBinary(buf []byte) (int, error)

func (*VirtualSnakeBootstrap) ProtectedPayload

func (v *VirtualSnakeBootstrap) ProtectedPayload() ([]byte, error)

func (*VirtualSnakeBootstrap) UnmarshalBinary

func (v *VirtualSnakeBootstrap) UnmarshalBinary(buf []byte) (int, error)

type VirtualSnakeWatermark

type VirtualSnakeWatermark struct {
	PublicKey PublicKey `json:"public_key"`
	Sequence  Varu64    `json:"sequence"`
}

func (VirtualSnakeWatermark) WorseThan

Jump to

Keyboard shortcuts

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