e7

package module
v0.0.0-...-4c6b7b1 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2017 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Hostname

func Hostname() string

Types

type Block

type Block struct {
	// specified by node
	// server should prevent collisions
	NodeID    string    `json:"node_id"`
	Signature string    `json:"signature"`
	Timestamp time.Time `json:"timestamp"`

	// array of services the node is hosting
	Services []string `json:"services"`

	// ip address of the author of block
	// filled in by the receiving server
	// json tag for serving the ledger
	IP string `json:"ip"`
}

sent by a node, specifies which services it has this is the data structure for internode communications

type Ledger

type Ledger struct {
	// this defaults to the machine's host name
	// it is used to identify local nodes within the Ledger
	NodeId string `json:"node_id"`

	RootIP string `json:"root_ip"`

	SelfIP string `json:"self_ip"`

	// keeps track of the number of changes
	// since the creation of ledger
	Mutations int `json:"mutations"`

	// node hostnames and ip addresses
	// A and AAAA records
	ActiveRecords map[string][]Record `json:"active_records"`

	// notice that timeout is an attribute of the Ledger
	// and therefore an attribute of the whole network
	Timeout time.Duration `json:"timeout"`
	// contains filtered or unexported fields
}

active ledger, stores the history and provides methods for quick access of active records

func NewLedger

func NewLedger(pass string) (l *Ledger)

func ParseLedger

func ParseLedger(pass, selfIP string, byt []byte) *Ledger

func (*Ledger) AddBlock

func (l *Ledger) AddBlock(b Block) (ok bool)

adds the block to the history and SRV to the map silently ignores ill-formatted addresses

func (*Ledger) Bytes

func (l *Ledger) Bytes() (byt []byte)

func (*Ledger) Clean

func (l *Ledger) Clean()

func (*Ledger) Nodes

func (l *Ledger) Nodes() (nodes map[string]string)

returns a map of names to ip addresses

func (*Ledger) Query

func (l *Ledger) Query(name string) (rr []dns.RR, ok bool)

this returns all the resource records matching the query

func (*Ledger) SignBlock

func (l *Ledger) SignBlock(b *Block)

Signs the block as originated from the instance of the ledger the only preserved field is the services field

type Record

type Record struct {
	Name   string    `json:"name"`
	Target string    `json:"target"`
	IsNode bool      `json:"is_node"`
	Ts     time.Time `json:"ts"`
}

This is the structure for an active record

func (Record) TTL

func (r Record) TTL(to time.Duration) (ret time.Duration)

Directories

Path Synopsis
this server keeps track of the connection in the local machine This file contains all client facing serving A reverse proxy for requests to local services A an index endpoint which replies with all services registered locally
this server keeps track of the connection in the local machine This file contains all client facing serving A reverse proxy for requests to local services A an index endpoint which replies with all services registered locally

Jump to

Keyboard shortcuts

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