Documentation ¶
Index ¶
- Variables
- func ConnectionsEqual(a, b []*HubConnection) bool
- func CreateHubSignet(toolID string, securityLevel int) (private, public *jess.Signet, err error)
- func ImportAnnouncement(data []byte, scope Scope) error
- func ImportStatus(data []byte, scope Scope) error
- func RemoveHub(scope Scope, id string) error
- func SaveRawHubMsg(id string, scope Scope, msgType string, data []byte) error
- func SetHubIPValidationFn(fn func(hub *Hub, ip net.IP) error)
- func SetNavigatorAccess(fn func(id string) *Hub)
- func SignHubMsg(msg []byte, env *jess.Envelope, enableTofu bool) ([]byte, error)
- func SortConnections(c []*HubConnection)
- type Hub
- type HubAnnouncement
- type HubConnection
- type HubKey
- type HubMsg
- type HubStatus
- type Scope
- type SingleTrustStore
- type Transport
Constants ¶
This section is empty.
Variables ¶
var ( // AllHubs is the database scope for saving Hubs AllHubs = "cache:spn/hubs/" // LocalHubs is the database scope for local hubs LocalHubs = AllHubs + "local/" // PublicHubs is the database scope for public hubs PublicHubs = AllHubs + "public/" // RawMsgsScope is for storing raw msgs. The path spec for this scope is cache:spn/rawMsgs/<scope>/<msgType>/<ID> RawMsgsScope = "cache:spn/rawMsgs/" )
var ( // ErrMissingInfo signifies that the hub is missing the HubAnnouncement. ErrMissingInfo = errors.New("hub is missing Announcement") // ErrMissingTransports signifies that the hub announcement did not specify any transports. ErrMissingTransports = errors.New("hub announcement is missing transports") // ErrMissingIPs signifies that the hub announcement did not specify any IPs. ErrMissingIPs = errors.New("hub announcement is missing IPs") // ErrTemporaryValidationError is returned when a validation error might be temporary. ErrTemporaryValidationError = errors.New("temporary validation error") )
Functions ¶
func ConnectionsEqual ¶
func ConnectionsEqual(a, b []*HubConnection) bool
ConnectionsEqual returns whether the given []*HubConnection are equal.
func CreateHubSignet ¶
CreateHubSignet creates a signet with the correct ID for usage as a Hub Identity.
func ImportAnnouncement ¶
ImportAnnouncement imports an announcement if it passes all the checks.
func ImportStatus ¶
ImportStatus imports a status update if it passes all the checks.
func SaveRawHubMsg ¶
SaveRawHubMsg saves a raw (and signed) message received by another Hub.
func SetHubIPValidationFn ¶
SetHubIPValidationFn sets the function that is used to validate the IP of a Hub.
func SetNavigatorAccess ¶
SetNavigatorAccess sets a shortcut function to access hubs from the navigator instead of having go through the database. This also reduces the number of object in RAM and better caches parsed attributes.
func SignHubMsg ¶
SignHubMsg signs the given serialized hub msg with the given configuration.
func SortConnections ¶
func SortConnections(c []*HubConnection)
SortConnections sorts a slice of HubConnections.
Types ¶
type Hub ¶
type Hub struct { sync.Mutex record.Base ID string PublicKey *jess.Signet Scope Scope Info *HubAnnouncement Status *HubStatus FirstSeen time.Time }
Hub represents a network node in the SPN.
func OpenHubMsg ¶
OpenHubMsg opens a signed hub msg and verifies the signature using the local database. If TOFU is enabled, the signature is always accepted, if valid.
func (*Hub) AddConnection ¶
func (h *Hub) AddConnection(newConn *HubConnection) error
AddConnection adds a new Hub Connection to the Hub Status.
func (*Hub) GetSignet ¶
GetSignet returns the public key identified by the given ID from the Hub Status.
func (*Hub) RemoveConnection ¶
RemoveConnection removes a Hub Connection from the Hub Status.
func (*Hub) SelectSignet ¶
SelectSignet selects the public key to use for initiating connections to that Hub.
type HubAnnouncement ¶
type HubAnnouncement struct { // Primary Key // hash of public key // must be checked if it matches the public key ID string // via jess.LabeledHash // PublicKey *jess.Signet // PublicKey // if not part of signature // Signature *jess.Letter Timestamp int64 // Unix timestamp in seconds // Node Information Name string // name of the node Group string // person or organisation, who is in control of the node (should be same for all nodes of this person or organisation) ContactAddress string // contact possibility (recommended, but optional) ContactService string // type of service of the contact address, if not email // currently unused, but collected for later use Hosters []string // hoster supply chain (reseller, hosting provider, datacenter operator, ...) Datacenter string // datacenter will be bullshit checked // Network Location and Access // If node is behind NAT (or similar), IP addresses must be configured IPv4 net.IP // must be global and accessible IPv6 net.IP // must be global and accessible Transports []string // Policies - default permit Entry []string // {"+ ", "- *"} Exit []string }
HubAnnouncement is the main message type to publish Hub Information. This only changes if updated manually.
func (*HubAnnouncement) Equal ¶
func (a *HubAnnouncement) Equal(b *HubAnnouncement) bool
Equal returns whether the given Announcements are equal.
type HubConnection ¶
type HubConnection struct { ID string // ID of peer Capacity int // max available bandwidth in Mbit/s (measure actively!) Latency int // ping in msecs }
HubConnection represents a link to another Hub.
func (*HubConnection) Equal ¶
func (c *HubConnection) Equal(other *HubConnection) bool
Equal returns whether the HubConnection is equal to the given one.
func (*HubConnection) String ¶
func (c *HubConnection) String() string
type HubKey ¶
HubKey represents a semi-ephemeral public key used for 0-RTT connection establishment.
type HubMsg ¶
type HubMsg struct { record.Base sync.Mutex ID string Scope Scope Type string Data []byte Received int64 }
HubMsg stores raw Hub messages.
type HubStatus ¶
type HubStatus struct { Timestamp int64 // Routing Information Keys map[string]*HubKey // public keys (with type) Connections []*HubConnection // Load describes max(CPU, Memory) in percent, averages over the last hour // only update if change is significant in terms of impact on routing // do not update more often than once an hour Load int }
HubStatus is the message type used to update changing Hub Information. Changes are made automatically.
type SingleTrustStore ¶
SingleTrustStore is a simple truststore that always returns the same Signet.
type Transport ¶
Transport represents a "endpoint" that others can connect to. This allows for use of different protocols, ports and infrastructure integration.
func ParseTransport ¶
ParseTransport parses a transport definition.