servers

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2018 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package servers contains the logic for creating and managing SCIOND API servers. It currently supports listening on ReliableSocket and UNIX Domain socket (in unixgram mode).

Index

Constants

View Source
const (
	// DefaultReplyTimeout is allocated to SCIOND handlers to reply back to the client.
	DefaultReplyTimeout = 2 * time.Second
	// DefaultWorkTimeout is allocated to SCIOND handlers work (e.g., network
	// traffic and crypto operations)
	DefaultWorkTimeout = 10 * time.Second
	DefaultEarlyReply  = 200 * time.Millisecond
	// DefaultServiceTTL is the TTL value for ServiceInfoReply objects,
	// expressed in seconds.
	DefaultServiceTTL uint32 = 300
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ASInfoRequestHandler

type ASInfoRequestHandler struct {
	TrustStore infra.TrustStore
}

ASInfoRequestHandler represents the shared global state for the handling of all ASInfoRequest queries. The SCIOND API spawns a goroutine with method Handle for each ASInfoRequest it receives.

func (*ASInfoRequestHandler) Handle

func (h *ASInfoRequestHandler) Handle(transport infra.Transport, src net.Addr, pld *sciond.Pld,
	logger log.Logger)

type Handler

type Handler interface {
	Handle(transport infra.Transport, src net.Addr, pld *sciond.Pld, logger log.Logger)
}

type HandlerMap

type HandlerMap map[proto.SCIONDMsg_Which]Handler

type IFInfoRequestHandler

type IFInfoRequestHandler struct{}

IFInfoRequestHandler represents the shared global state for the handling of all IFInfoRequest queries. The SCIOND API spawns a goroutine with method Handle for each IFInfoRequest it receives.

func (*IFInfoRequestHandler) Handle

func (h *IFInfoRequestHandler) Handle(transport infra.Transport, src net.Addr, pld *sciond.Pld,
	logger log.Logger)

type PathRequestHandler

type PathRequestHandler struct {
	Fetcher *fetcher.Fetcher
}

PathRequestHandler represents the shared global state for the handling of all PathRequest queries. The SCIOND API spawns a goroutine with method Handle for each PathRequest it receives.

func (*PathRequestHandler) Handle

func (h *PathRequestHandler) Handle(transport infra.Transport, src net.Addr, pld *sciond.Pld,
	logger log.Logger)

type RevNotificationHandler

type RevNotificationHandler struct {
	RevCache   revcache.RevCache
	TrustStore infra.TrustStore
}

RevNotificationHandler represents the shared global state for the handling of all RevNotification announcements. The SCIOND API spawns a goroutine with method Handle for each RevNotification it receives.

func (*RevNotificationHandler) Handle

func (h *RevNotificationHandler) Handle(transport infra.Transport, src net.Addr, pld *sciond.Pld,
	logger log.Logger)

type SVCInfoRequestHandler

type SVCInfoRequestHandler struct{}

SVCInfoRequestHandler represents the shared global state for the handling of all SVCInfoRequest queries. The SCIOND API spawns a goroutine with method Handle for each SVCInfoRequest it receives.

func (*SVCInfoRequestHandler) Handle

func (h *SVCInfoRequestHandler) Handle(transport infra.Transport, src net.Addr, pld *sciond.Pld,
	logger log.Logger)

type Server

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

Server listens for new connections on a "unixpacket" or "rsock" network. Whenever a new connection is accepted, a SCIOND API server is created to handle the connection.

func NewServer

func NewServer(network string, address string, handlers HandlerMap, logger log.Logger) *Server

NewServer initializes a new server at address on the specified network. The server will route requests to their correct handlers based on the HandlerMap. To start listening on the address, call ListenAndServe.

Network must be "unixpacket" or "rsock".

func (*Server) Close

func (srv *Server) Close() error

Close makes the Server stop listening for new connections, and immediately closes all running SCIONDMsg servers that have been launched by this server.

func (*Server) ListenAndServe

func (srv *Server) ListenAndServe() error

ListenAndServe starts listening on srv's address, and repeatedly accepts connections from clients. For each accepted connection, a SCIONDMsg server is started as a separate goroutine; the server will manage the connection until it is closed by the client.

func (*Server) Shutdown

func (srv *Server) Shutdown(ctx context.Context) error

Shutdown makes the Server stop listening for new connections, and cleanly shuts down all running SCIONDMsg servers that have been launched by this server.

type TransportHandler

type TransportHandler struct {
	Transport infra.Transport
	// State for request Handlers
	Handlers map[proto.SCIONDMsg_Which]Handler
	Logger   log.Logger
}

TransportHandler is a SCIOND API server running on top of a Transport. It reads messages from the transport, and passes them to the relevant request handler.

func NewTransportHandler

func NewTransportHandler(transport infra.Transport,
	handlers HandlerMap, logger log.Logger) *TransportHandler

func (*TransportHandler) Close

func (srv *TransportHandler) Close() error

func (*TransportHandler) Handle

func (srv *TransportHandler) Handle(b common.RawBytes, address net.Addr)

func (*TransportHandler) Serve

func (srv *TransportHandler) Serve() error

func (*TransportHandler) Shutdown

func (srv *TransportHandler) Shutdown() error

Shutdown cleanly stops the server from handling future requests, while allowing pending requests to finish.

Jump to

Keyboard shortcuts

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