net

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2020 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CallOption added in v0.3.7

type CallOption = grpc.CallOption

CallOption is simply a wrapper around the grpc options

type CertManager added in v0.3.7

type CertManager struct {
	// contains filtered or unexported fields
}

CertManager is used to managed certificates. It is most commonly used for testing with self signed certificate. By default, it returns the bundled set of certificates coming with the OS (Go's implementation).

func NewCertManager added in v0.3.7

func NewCertManager() *CertManager

NewCertManager returns a cert manager filled with the trusted certificates of the running system

func (*CertManager) Add added in v0.3.7

func (p *CertManager) Add(certPath string) error

Add tries to add the certificate at the given path to the pool and returns an error otherwise

func (*CertManager) Pool added in v0.3.7

func (p *CertManager) Pool() *x509.CertPool

Pool returns the pool of trusted certificates

type Client

type Client interface {
	ProtocolClient
	PublicClient
}

Client implements methods to call on the protocol API and the public API of a drand node

func NewGrpcClient

func NewGrpcClient(opts ...grpc.DialOption) Client

NewGrpcClient returns an implementation of an InternalClient and ExternalClient using gRPC connections

func NewGrpcClientFromCertManager added in v0.3.7

func NewGrpcClientFromCertManager(c *CertManager, opts ...grpc.DialOption) Client

NewGrpcClientFromCertManager returns a Client using gRPC with the given trust store of certificates.

func NewGrpcClientWithTimeout added in v0.3.6

func NewGrpcClientWithTimeout(timeout time.Duration, opts ...grpc.DialOption) Client

NewGrpcClientWithTimeout returns a Client using gRPC using fixed timeout for method calls.

type ControlClient added in v0.4.0

type ControlClient struct {
	// contains filtered or unexported fields
}

ControlClient is a struct that implement control.ControlClient and is used to request a Share to a ControlListener on a specific port

func NewControlClient added in v0.4.0

func NewControlClient(port string) (*ControlClient, error)

NewControlClient creates a client capable of issuing control commands to a localhost running drand node.

func (ControlClient) CollectiveKey added in v0.4.0

func (c ControlClient) CollectiveKey() (*control.CokeyResponse, error)

CollectiveKey returns the collective key of the remote node

func (ControlClient) GroupFile added in v0.5.0

func (c ControlClient) GroupFile() (*control.GroupTOMLResponse, error)

GroupFile returns the TOML-encoded group file

func (*ControlClient) InitDKG added in v0.4.0

func (c *ControlClient) InitDKG(groupPath string, leader bool, timeout string) (*control.Empty, error)

InitDKG sets up the node to be ready for a first DKG protocol. groupPart NOTE: only group referral via filesystem path is supported at the moment. XXX Might be best to move to core/

func (*ControlClient) InitReshare added in v0.4.0

func (c *ControlClient) InitReshare(oldPath, newPath string, leader bool, timeout string) (*control.Empty, error)

InitReshare sets up the node to be ready for a resharing protocol. oldPath and newPath represents the paths in the filesystems of the old group and the new group respectively. Leader is true if the destination node should start the protocol. NOTE: only group referral via filesystem path is supported at the moment. XXX Might be best to move to core/

func (*ControlClient) Ping added in v0.4.0

func (c *ControlClient) Ping() error

Ping the drand daemon to check if it's up and running

func (ControlClient) PrivateKey added in v0.4.0

func (c ControlClient) PrivateKey() (*control.PrivateKeyResponse, error)

PrivateKey returns the private key of the remote node

func (ControlClient) PublicKey added in v0.4.0

func (c ControlClient) PublicKey() (*control.PublicKeyResponse, error)

PublicKey returns the public key of the remote node

func (ControlClient) Share added in v0.4.0

func (c ControlClient) Share() (*control.ShareResponse, error)

Share returns the share of the remote node

type ControlListener added in v0.4.0

type ControlListener struct {
	// contains filtered or unexported fields
}

ControlListener is used to keep state of the connections of our drand instance

func NewTCPGrpcControlListener added in v0.4.0

func NewTCPGrpcControlListener(s control.ControlServer, port string) ControlListener

NewTCPGrpcControlListener registers the pairing between a ControlServer and a grpx server

func (*ControlListener) Start added in v0.4.0

func (g *ControlListener) Start()

Start the listener for the control commands

func (*ControlListener) Stop added in v0.4.0

func (g *ControlListener) Stop()

Stop the listener and connections

type DefaultControlServer added in v0.4.0

type DefaultControlServer struct {
	C control.ControlServer
}

DefaultControlServer implements the functionalities of Control Service, and just as Default Service, it is used for testing.

func (*DefaultControlServer) CollectiveKey added in v0.4.0

CollectiveKey ...

func (*DefaultControlServer) PingPong added in v0.4.0

PingPong ...

func (*DefaultControlServer) PrivateKey added in v0.4.0

PrivateKey ...

func (*DefaultControlServer) PublicKey added in v0.4.0

PublicKey ...

func (*DefaultControlServer) Share added in v0.4.0

Share ...

type EmptyServer added in v0.5.1

type EmptyServer struct{}

EmptyServer is an PublicServer + ProtocolServer that does nothing

func (*EmptyServer) CollectiveKey added in v0.5.1

CollectiveKey ...

func (*EmptyServer) DistKey added in v0.5.1

DistKey ...

func (*EmptyServer) Group added in v0.5.1

Group ...

func (*EmptyServer) GroupFile added in v0.5.1

GroupFile ...

func (*EmptyServer) Home added in v0.5.1

Home ...

func (*EmptyServer) InitDKG added in v0.5.1

InitDKG ...

func (*EmptyServer) InitReshare added in v0.5.1

InitReshare ...

func (*EmptyServer) NewBeacon added in v0.5.1

NewBeacon ...

func (*EmptyServer) PingPong added in v0.5.1

func (s *EmptyServer) PingPong(context.Context, *drand.Ping) (*drand.Pong, error)

PingPong ...

func (*EmptyServer) PrivateKey added in v0.5.1

PrivateKey ...

func (*EmptyServer) PrivateRand added in v0.5.1

PrivateRand ...

func (*EmptyServer) PublicKey added in v0.5.1

PublicKey ...

func (*EmptyServer) PublicRand added in v0.5.1

PublicRand ...

func (*EmptyServer) Reshare added in v0.5.1

Reshare ...

func (*EmptyServer) Setup added in v0.5.1

Setup ...

func (*EmptyServer) Share added in v0.5.1

Share ...

type Gateway

type Gateway struct {
	Listener
	ProtocolClient
}

Gateway is the main interface to communicate to other drand nodes. It acts as a listener to receive incoming requests and acts a client connecting to drand particpants. The gateway fixes all drand functionalities offered by drand.

func NewGrpcGatewayFromCertManager added in v0.3.7

func NewGrpcGatewayFromCertManager(listen string, certPath, keyPath string, certs *CertManager, s Service, opts ...grpc.DialOption) Gateway

NewGrpcGatewayFromCertManager returns a grpc gateway using the TLS certificate manager

func NewGrpcGatewayInsecure added in v0.3.7

func NewGrpcGatewayInsecure(listen string, s Service, opts ...grpc.DialOption) Gateway

NewGrpcGatewayInsecure returns a grpc Gateway listening on "listen" for the public methods, listening on "port" for the control methods, using the given Service s with the given options.

func (Gateway) StartAll added in v0.4.0

func (g Gateway) StartAll()

StartAll starts the control and public functionalities of the node

func (Gateway) StopAll added in v0.4.0

func (g Gateway) StopAll()

StopAll stops the control and public functionalities of the node

type HexJSON added in v0.4.0

type HexJSON struct{}

HexJSON transforms json into hex string instead of b64

func (*HexJSON) ContentType added in v0.4.0

func (*HexJSON) ContentType() string

ContentType always Returns "application/json".

func (*HexJSON) Delimiter added in v0.4.0

func (j *HexJSON) Delimiter() []byte

Delimiter for newline encoded JSON streams.

func (*HexJSON) Marshal added in v0.4.0

func (j *HexJSON) Marshal(v interface{}) ([]byte, error)

Marshal marshals "v" into JSON

func (*HexJSON) NewDecoder added in v0.4.0

func (j *HexJSON) NewDecoder(r io.Reader) runtime.Decoder

NewDecoder returns a Decoder which reads JSON stream from "r".

func (*HexJSON) NewEncoder added in v0.4.0

func (j *HexJSON) NewEncoder(w io.Writer) runtime.Encoder

NewEncoder returns an Encoder which writes JSON stream into "w".

func (*HexJSON) Unmarshal added in v0.4.0

func (j *HexJSON) Unmarshal(data []byte, v interface{}) error

Unmarshal unmarshals JSON data into "v".

type Listener

type Listener interface {
	Service
	Start()
	Stop()
}

Listener is the active listener for incoming requests.

func NewTCPGrpcListener

func NewTCPGrpcListener(addr string, s Service, opts ...grpc.ServerOption) Listener

NewTCPGrpcListener returns a gRPC listener using plain TCP connections without TLS. The listener will bind to the given address:port tuple.

func NewTLSGrpcListener added in v0.3.7

func NewTLSGrpcListener(bindingAddr string, certPath, keyPath string, s Service, opts ...grpc.ServerOption) (Listener, error)

NewTLSGrpcListener brings...

type Peer

type Peer interface {
	Address() string
	IsTLS() bool
}

Peer is a simple interface that allows retrieving the address of a destination. It might further e enhanced with certificates properties and all.

type ProtocolClient added in v0.5.1

type ProtocolClient interface {
	NewBeacon(p Peer, in *drand.BeaconRequest, opts ...CallOption) (*drand.BeaconResponse, error)
	Setup(p Peer, in *drand.SetupPacket, opts ...CallOption) (*drand.Empty, error)
	Reshare(p Peer, in *drand.ResharePacket, opts ...CallOption) (*drand.Empty, error)
	SetTimeout(time.Duration)
}

ProtocolClient holds all the methods of the protocol API that drand protocols use. See protobuf/drand/protocol.proto for more information.

type PublicClient added in v0.5.1

type PublicClient interface {
	PublicRand(p Peer, in *drand.PublicRandRequest) (*drand.PublicRandResponse, error)
	PrivateRand(p Peer, in *drand.PrivateRandRequest) (*drand.PrivateRandResponse, error)
	DistKey(p Peer, in *drand.DistKeyRequest) (*drand.DistKeyResponse, error)
	Group(p Peer, in *drand.GroupRequest) (*drand.GroupResponse, error)
	Home(p Peer, in *drand.HomeRequest) (*drand.HomeResponse, error)
}

PublicClient holds all the methods of the public API . See `protobuf/drand/public.proto` for more information.

func NewRestClient added in v0.3.7

func NewRestClient() PublicClient

NewRestClient returns a client capable of calling external public method on drand nodes using the RESP API

func NewRestClientFromCertManager added in v0.3.7

func NewRestClientFromCertManager(c *CertManager) PublicClient

NewRestClientFromCertManager returns a Rest Client with the given cert manager

type Service

Service holds all functionalities that a drand node should implement

Jump to

Keyboard shortcuts

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