bootstrap

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2019 License: Apache-2.0, BSD-3-Clause-Clear Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Accepted = Code(iota + 1)
	Rejected
	Redirected
	ReconnectRequired
)

Variables

View Source
var (
	ErrReconnectRequired = errors.New("Node should connect via consensus bootstrap")
)

Functions

func FindDiscovery

func FindDiscovery(cert core.Certificate, ref core.RecordRef) core.DiscoveryNode

func GenerateShortID

func GenerateShortID(keeper network.NodeKeeper, nodeID core.RecordRef) core.ShortNodeID

GenerateShortID correct ShortID of the node so it does not conflict with existing active node list

func RemoveOrigin

func RemoveOrigin(discoveryNodes []core.DiscoveryNode, origin core.RecordRef) ([]core.DiscoveryNode, error)

func Xor

func Xor(first, second []byte) []byte

Types

type AuthorizationController

type AuthorizationController interface {
	component.Initer

	Authorize(ctx context.Context, discoveryNode *DiscoveryNode, cert core.AuthorizationCertificate) (SessionID, error)
	Register(ctx context.Context, discoveryNode *DiscoveryNode, sessionID SessionID) error
}

func NewAuthorizationController

func NewAuthorizationController(options *common.Options, transport network.InternalTransport) AuthorizationController

type AuthorizationRequest

type AuthorizationRequest struct {
	Certificate []byte
}

AuthorizationRequest

type AuthorizationResponse

type AuthorizationResponse struct {
	Code      OperationCode
	Error     string
	SessionID SessionID
}

AuthorizationResponse

type Bootstrapper

type Bootstrapper interface {
	component.Initer

	Bootstrap(ctx context.Context) (*network.BootstrapResult, *DiscoveryNode, error)
	BootstrapDiscovery(ctx context.Context) (*network.BootstrapResult, error)
	SetLastPulse(number core.PulseNumber)
	GetLastPulse() core.PulseNumber
}

func NewBootstrapper

func NewBootstrapper(
	options *common.Options,

	transport network.InternalTransport) Bootstrapper

type ChallengePayload

type ChallengePayload struct {
	// CurrentPulse  core.Pulse
	// State         core.NetworkState
	AssignShortID core.ShortNodeID
}

type ChallengeRequest

type ChallengeRequest struct {
	SessionID SessionID

	Nonce Nonce
}

type ChallengeResponse

type ChallengeResponse struct {
	Header  ChallengeResponseHeader
	Payload *ChallengePayload
}

type ChallengeResponseController

type ChallengeResponseController interface {
	component.Initer

	Execute(ctx context.Context, discoveryNode *DiscoveryNode, sessionID SessionID) (*ChallengePayload, error)
}

func NewChallengeResponseController

func NewChallengeResponseController(options *common.Options, transport network.InternalTransport) ChallengeResponseController

type ChallengeResponseHeader

type ChallengeResponseHeader struct {
	Success bool
	Error   string
}

type Code

type Code uint8

type DiscoveryNode

type DiscoveryNode struct {
	Host *host.Host
	Node core.DiscoveryNode
}

type GenesisRequest

type GenesisRequest struct {
	LastPulse core.PulseNumber
	Discovery *NodeStruct
}

type GenesisResponse

type GenesisResponse struct {
	Response GenesisRequest
	Error    string
}

type NetworkBootstrapper

type NetworkBootstrapper interface {
	Bootstrap(ctx context.Context) (*network.BootstrapResult, error)
	SetLastPulse(number core.PulseNumber)
	GetLastPulse() core.PulseNumber
}

func NewNetworkBootstrapper

func NewNetworkBootstrapper() NetworkBootstrapper

type NodeBootstrapRequest

type NodeBootstrapRequest struct{}

type NodeBootstrapResponse

type NodeBootstrapResponse struct {
	Code         Code
	RedirectHost string
	RejectReason string
}

type NodeStruct added in v0.7.5

type NodeStruct struct {
	ID      core.RecordRef
	SID     core.ShortNodeID
	Role    core.StaticRole
	PK      []byte
	Address string
	Version string
}

type Nonce

type Nonce []byte

func GenerateNonce

func GenerateNonce() (Nonce, error)

type OperationCode

type OperationCode uint8
const (
	OpConfirmed OperationCode = iota + 1
	OpRejected
)

type RegistrationRequest

type RegistrationRequest struct {
	SessionID SessionID
	JoinClaim *packets.NodeJoinClaim
}

RegistrationRequest

type RegistrationResponse

type RegistrationResponse struct {
	Code  OperationCode
	Error string
}

RegistrationResponse

type Session

type Session struct {
	NodeID core.RecordRef
	Cert   core.AuthorizationCertificate
	State  SessionState

	DiscoveryNonce Nonce

	Time time.Time
	TTL  time.Duration
}

type SessionID

type SessionID uint64

type SessionManager

type SessionManager interface {
	component.Starter
	component.Stopper

	NewSession(ref core.RecordRef, cert core.AuthorizationCertificate, ttl time.Duration) SessionID
	CheckSession(id SessionID, expected SessionState) error
	SetDiscoveryNonce(id SessionID, discoveryNonce Nonce) error
	GetChallengeData(id SessionID) (core.AuthorizationCertificate, Nonce, error)
	ChallengePassed(id SessionID) error
	ReleaseSession(id SessionID) (*Session, error)
}

func NewSessionManager

func NewSessionManager() SessionManager

type SessionState

type SessionState uint8
const (
	Authorized SessionState = iota + 1
	Challenge1
	Challenge2
)

func (SessionState) String

func (i SessionState) String() string

type SignedChallengePayload

type SignedChallengePayload struct {
	SignedNonce       SignedNonce
	XorDiscoveryNonce Nonce
	DiscoveryNonce    Nonce
}

type SignedChallengeRequest

type SignedChallengeRequest struct {
	SessionID SessionID

	SignedDiscoveryNonce SignedNonce
	XorNonce             Nonce
}

type SignedChallengeResponse

type SignedChallengeResponse struct {
	Header  ChallengeResponseHeader
	Payload *SignedChallengePayload
}

type SignedNonce

type SignedNonce []byte

type StartSessionRequest

type StartSessionRequest struct{}

type StartSessionResponse

type StartSessionResponse struct {
	SessionID SessionID
}

Jump to

Keyboard shortcuts

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