servers

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 25 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 {
	ASInspector infra.ASInspector
}

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(ctx context.Context, conn net.PacketConn, src net.Addr,
	pld *sciond.Pld)

type ConnHandler added in v0.4.0

type ConnHandler struct {
	Conn net.PacketConn
	// State for request Handlers
	Handlers map[proto.SCIONDMsg_Which]Handler
	Logger   log.Logger
}

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

func NewConnHandler added in v0.4.0

func NewConnHandler(conn net.PacketConn,
	handlers HandlerMap, logger log.Logger) *ConnHandler

func (*ConnHandler) Close added in v0.4.0

func (srv *ConnHandler) Close() error

func (*ConnHandler) Handle added in v0.4.0

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

func (*ConnHandler) Serve added in v0.4.0

func (srv *ConnHandler) Serve() error

type Handler

type Handler interface {
	Handle(ctx context.Context, conn net.PacketConn, src net.Addr, pld *sciond.Pld)
}

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(ctx context.Context, conn net.PacketConn, src net.Addr,
	pld *sciond.Pld)

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(ctx context.Context, conn net.PacketConn, src net.Addr,
	pld *sciond.Pld)

type RevNotificationHandler

type RevNotificationHandler struct {
	RevCache         revcache.RevCache
	VerifierFactory  infra.VerificationFactory
	NextQueryCleaner segfetcher.NextQueryCleaner
}

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(ctx context.Context, conn net.PacketConn,
	src net.Addr, pld *sciond.Pld)

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(ctx context.Context, conn net.PacketConn,
	src net.Addr, pld *sciond.Pld)

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, filemode os.FileMode, 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.

Jump to

Keyboard shortcuts

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