gateway

package
v0.0.0-...-1959fcc Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Credential

func Credential(secretKey string, peerID int64, ip net.IP, lease time.Duration) ([]byte, error)

Credential returns a credential to identity the Peer, which contains the expiration time and the reclaimed IP address. All requests relevant to IP address, the credential is required. We will verify the triple: -> (PeerID, IP, Expiration). The schema of credential: | PeerID | IP | Expiration | | 8 bytes | 4 bytes | 8 bytes | The credential delivered to the client will be encrypted by secret key. The secret key is a private key only hold by the gateway.

func Serve

func Serve(opt Options) error

Serve serves the gateway service

func VerifyCredential

func VerifyCredential(secretKey string, credential []byte) (int64, net.IP, bool)

VerifyCredential verifies the expiration of the credential, returns the peerID and IP

Types

type Error

type Error struct {
	Code message.StatusCode
	Err  error
}

Error represent a dedicated error type, which contain the API status code

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface

type Options

type Options struct {
	AuthOptions *security.AuthOptions

	Host        string
	Port        int
	Concurrency int
	TLSCert     string
	TLSKey      string
	CIDR        string
}

Options represents the CLI arguments of Zetamesh gateway node

type PeerInfo

type PeerInfo struct {
	ID           int64
	NetworkID    string
	VirtAddress  string
	UDPAddress   string
	HeartbeatAt  time.Time
	ExpirationAt time.Time
}

PeerInfo represents the peer of the Zetamesh system. The following fields should be immutable: ID, NetworkID, VirtAddress.

type PeerStore

type PeerStore interface {
	// Find tries to find the peer information from peer store.
	Find(networkID, addr string) (*PeerInfo, error)
	// Get gets the information of the peer by ID.
	Get(id int64) (*PeerInfo, error)
	// Put stores the Peer into the store and the latest ID of the
	// peer will be assigned to the peer.
	Put(peer *PeerInfo) error
	// Delete deletes the peer by peer ID from peer store.
	Delete(id int64) error
	// Subnet returns all peers included in the subnet
	Subnet(networkID string) ([]*PeerInfo, error)
}

PeerStore represents the store that is used to store peers information.

Jump to

Keyboard shortcuts

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