svc

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: 15 Imported by: 0

Documentation

Overview

Package svc implements support for SVC Resolution.

Index

Constants

View Source
const ErrHandler common.ErrMsg = "Unable to handle SVC request"

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseHandler

type BaseHandler struct {
	// Message is the payload data to send in the reply. Nil and zero-length
	// payloads are supported.
	Message []byte
}

BaseHandler reverses a SCION packet, replaces the source address with the one in the struct and then sends the message on the connection.

func (*BaseHandler) Handle

func (h *BaseHandler) Handle(request *Request) (Result, error)

type Reply

type Reply struct {
	// Transports maps transport keys (e.g., "QUIC" or "UDP") to network
	// address strings (e.g., "192.168.1.1:80"). Applications should check if
	// the transport keys are acceptable and must parse the address strings
	// accordingly.
	Transports map[Transport]string
	// ReturnPath contains the reversed and initialized path the SVC resolution
	// message arrived on. This can be used to communicate across paths
	// bootstrapped via One-Hop Path communication.
	ReturnPath snet.Path
}

Reply is an SVC resolution reply.

func (*Reply) DecodeFrom

func (r *Reply) DecodeFrom(rd io.Reader) error

DecodeFrom decodes a reply message from its capnp representation. No validation of transport keys is performed.

If the returned error is non-nil, the state of Reply is unspecified.

func (*Reply) SerializeTo

func (r *Reply) SerializeTo(wr io.Writer) error

SerializeTo encodes a reply message into its capnp representation. No validation of transport keys is performed.

type Request

type Request struct {
	// Source is the override value for the source address of the reply packet.
	Source snet.SCIONAddress
	// Conn is the connection to send the reply on. Conn must not be nil.
	Conn    snet.PacketConn
	Packet  *snet.SCIONPacket
	Overlay *overlay.OverlayAddr
}

type RequestHandler

type RequestHandler interface {
	// Handle replies to SCION packets with SVC destinations coming from the
	// specified overlay address.
	//
	// Handle implementantions might panic if the destination is not an SVC
	// address, so callers should perform the check beforehand.
	Handle(*Request) (Result, error)
}

RequestHandler handles SCION packets with SVC destination addresses.

type Resolver

type Resolver struct {
	// LocalIA is the local AS.
	LocalIA addr.IA
	// ConnFactory is used to open ports for SVC resolution messages.
	ConnFactory snet.PacketDispatcherService
	// Machine is used to derive addressing information for local conns.
	Machine snet.LocalMachine
	// RoundTripper performs the request/reply exchange for SVC resolutions. If
	// nil, the default round tripper is used.
	RoundTripper RoundTripper
	// Payload is used for the data part of SVC requests.
	Payload []byte
}

Resolver performs SVC address resolution.

func (*Resolver) LookupSVC

func (r *Resolver) LookupSVC(ctx context.Context, p snet.Path, svc addr.HostSVC) (*Reply, error)

LookupSVC resolves the SVC address for the AS terminating the path.

type ResolverPacketDispatcher

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

ResolverPacketDispatcher is a dispatcher service that returns sockets with built-in SVC address resolution capabilities. Every packet received with a destination SVC address is intercepted inside the socket, and sent to an SVC resolution handler which responds back to the client.

Redirected packets are not returned by the connection, so they cannot be seen via ReadFrom. After redirecting a packet, the connection attempts to read another packet before returning, until a non SVC packet is received or an error occurs.

func NewResolverPacketDispatcher

func NewResolverPacketDispatcher(d snet.PacketDispatcherService,
	h RequestHandler) *ResolverPacketDispatcher

NewResolverPacketDispatcher creates a dispatcher service that returns sockets with built-in SVC address resolution capabilities.

RequestHandler results during connection read operations are handled in the following way:

  • on error result, the error is sent back to the reader
  • on forwarding result, the packet is sent back to the app for processing.
  • on handled result, the packet is discarded after processing, and a new read is attempted from the connection, and the entire decision process repeats.

func (*ResolverPacketDispatcher) RegisterTimeout

func (d *ResolverPacketDispatcher) RegisterTimeout(ia addr.IA, public *addr.AppAddr,
	bind *overlay.OverlayAddr, svc addr.HostSVC,
	timeout time.Duration) (snet.PacketConn, uint16, error)

type Result

type Result int

Result is used to inform Handler users on the outcome of handler execution.

const (
	// Error means that the handler experience an error during processing.
	Error Result = iota
	// Handled means that the handler completed successfully.
	Handled
	// Forward means that the packet should be forwarded to the application.
	Forward
)

type RoundTripper

type RoundTripper interface {
	// RoundTrip performs the round trip interaction.
	RoundTrip(ctx context.Context, c snet.PacketConn, request *snet.SCIONPacket,
		ov *overlay.OverlayAddr) (*Reply, error)
}

RoundTripper does a single SVC resolution request/reply interaction over a connection, using the specified request packet and overlay address.

func DefaultRoundTripper

func DefaultRoundTripper() RoundTripper

DefaultRoundTripper returns a basic implementation of the RoundTripper interface.

type Transport

type Transport string

Transport contains constants for common transport keys.

const (
	UDP  Transport = "UDP"
	QUIC Transport = "QUIC"
)

Directories

Path Synopsis
internal
ctxconn
Package ctxconn provides a helper function to track context cancellation when working with connections.
Package ctxconn provides a helper function to track context cancellation when working with connections.
ctxconn/mock_ctxconn
Package mock_ctxconn is a generated GoMock package.
Package mock_ctxconn is a generated GoMock package.
proto
Package proto implements helpers for capnp SVC address resolution messages.
Package proto implements helpers for capnp SVC address resolution messages.
Package mock_svc is a generated GoMock package.
Package mock_svc is a generated GoMock package.

Jump to

Keyboard shortcuts

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