net

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2018 License: MIT Imports: 18 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

func NewGrpcClientWithTimeout added in v0.3.6

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

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

func (*CertManager) Add added in v0.3.7

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

func (*CertManager) Pool added in v0.3.7

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

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

func (*DefaultService) Private added in v0.3.7

func (*DefaultService) Public added in v0.3.7

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

func NewRestClientFromCertManager added in v0.3.7

func NewRestClientFromCertManager(c *CertManager) ExternalClient

type Gateway

type Gateway struct {
	Listener
	InternalClient
}

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 NewGrpcGateway

func NewGrpcGateway(listen string, certPath, keyPath string, s Service, opts ...grpc.DialOption) Gateway

func NewGrpcGatewayFromCertManager added in v0.3.7

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

func NewGrpcGatewayInsecure added in v0.3.7

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

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

InternalClient represents all methods callable on drand nodes which are internal to the system. See the folder api/ to get more info on the external API drand nodes offer.

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)

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