net

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2018 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTimeout = time.Duration(30) * time.Second

Functions

func NewGrpcClient

func NewGrpcClient(opts ...grpc.DialOption) *grpcClient

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) *grpcClient

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) *grpcClient

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

Types

type CallOption added in v0.3.7

type CallOption = grpc.CallOption

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 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)

func (*ControlClient) Group added in v0.4.0

func (c *ControlClient) Group() (*control.GroupResponse, error)

func (*ControlClient) InitDKG added in v0.4.0

func (c *ControlClient) InitDKG(groupPath string, leader bool) (*control.DKGResponse, 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) (*control.ReshareResponse, 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

func (ControlClient) PrivateKey added in v0.4.0

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

func (ControlClient) PublicKey added in v0.4.0

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

func (ControlClient) Share added in v0.4.0

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

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()

func (*ControlListener) Stop added in v0.4.0

func (g *ControlListener) Stop()

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

func (*DefaultControlServer) Group added in v0.4.0

func (*DefaultControlServer) PingPong added in v0.4.0

func (*DefaultControlServer) PrivateKey added in v0.4.0

func (*DefaultControlServer) PublicKey added in v0.4.0

func (*DefaultControlServer) Share added in v0.4.0

type DefaultService added in v0.3.7

type DefaultService struct {
	B drand.BeaconServer
	R drand.RandomnessServer
	I drand.InfoServer
	D dkg.DkgServer
}

Default service implements the Service interface with methods that returns empty messages. Default service is useful mainly for testing, where you want to implement only a specific functionality of a Service. To use : depending on which server you want to test, define a struct that implemants BeaconServer, RandomnessServer or DkgServer and instanciate defaultService with &DefaultService{<your struct>}.

func (*DefaultService) DistKey added in v0.3.7

func (*DefaultService) Home added in v0.4.1

func (*DefaultService) NewBeacon added in v0.3.7

func (*DefaultService) Private added in v0.3.7

func (*DefaultService) Public added in v0.3.7

func (*DefaultService) Reshare added in v0.4.0

func (*DefaultService) Setup added in v0.3.7

type ExternalClient added in v0.3.7

type ExternalClient interface {
	Public(p Peer, in *drand.PublicRandRequest) (*drand.PublicRandResponse, error)
	Private(p Peer, in *drand.PrivateRandRequest) (*drand.PrivateRandResponse, error)
	DistKey(p Peer, in *drand.DistKeyRequest) (*drand.DistKeyResponse, error)
}

func NewRestClient added in v0.3.7

func NewRestClient() ExternalClient

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) ExternalClient

NewRestClientFromCertManager returns a Rest Client with the given cert manager

type Gateway

type Gateway struct {
	Listener
	InternalClient
	ControlListener
}

Gateway is the main interface to communicate to the drand world. 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, port string, certPath, keyPath string, certs *CertManager, s Service, cs control.ControlServer, opts ...grpc.DialOption) Gateway

func NewGrpcGatewayInsecure added in v0.3.7

func NewGrpcGatewayInsecure(listen string, port string, s Service, cs control.ControlServer, opts ...grpc.DialOption) Gateway

func (Gateway) StartAll added in v0.4.0

func (g Gateway) StartAll()

func (Gateway) StopAll added in v0.4.0

func (g Gateway) StopAll()

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 InternalClient added in v0.3.7

type InternalClient interface {
	NewBeacon(p Peer, in *drand.BeaconRequest, opts ...CallOption) (*drand.BeaconResponse, error)
	Setup(p Peer, in *dkg.DKGPacket, opts ...CallOption) (*dkg.DKGResponse, error)
	Reshare(p Peer, in *dkg.ResharePacket, opts ...CallOption) (*dkg.ReshareResponse, error)
}

InternalClient represents all methods callable on drand nodes which are internal to the system. See relevant protobuf files in `/protobuf` for more informations.

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 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