appnet

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package infraenv contains convenience function common to SCION infra services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateTLSConfig

func GenerateTLSConfig() (*tls.Config, error)

GenerateTLSConfig generates a self-signed certificate.

func NewRouter

func NewRouter(localIA addr.IA, sd env.Daemon) (snet.Router, error)

NewRouter constructs a path router for paths starting from localIA.

Types

type AddressRewriter

type AddressRewriter struct {
	// Router obtains path information to fill in address paths, if they are
	// required and missing.
	Router snet.Router
	// SVCRouter builds underlay addresses for intra-AS SVC traffic, based on
	// information found in the topology.
	SVCRouter SVCResolver
	// Resolver performs SVC resolution if enabled.
	Resolver Resolver
	// SVCResolutionFraction enables SVC resolution for traffic to SVC
	// destinations in a way that is also compatible with control plane servers
	// that do not implement the SVC Resolution Mechanism. The value represents
	// the percentage of time, out of the total available context timeout,
	// spent attempting to perform SVC resolution. If SVCResolutionFraction is
	// 0 or less, SVC resolution is never attempted. If it is between 0 and 1,
	// the remaining context timeout is multiplied by the value, and that
	// amount of time is spent waiting for an SVC resolution reply from the
	// server. If this times out, the data packet is sent with an SVC
	// destination. If the value is 1 or more, then legacy behavior is
	// disabled, and data packets are never sent to SVC destinations unless the
	// resolution step is successful.
	SVCResolutionFraction float64
}

AddressRewriter is used to compute paths and replace SVC destinations with unicast addresses.

func (AddressRewriter) RedirectToQUIC

func (r AddressRewriter) RedirectToQUIC(ctx context.Context,
	address net.Addr) (net.Addr, bool, error)

RedirectToQUIC takes an address and adds a path (if one does not already exist but is required), and replaces SVC destinations with QUIC unicast ones, if possible.

The returned boolean value is set to true if the remote server is QUIC-compatible and we have successfully discovered its address.

If the address is already unicast, no redirection to QUIC is attempted.

type IntraASPathQuerier added in v0.9.0

type IntraASPathQuerier struct {
	IA  addr.IA
	MTU uint16
}

IntraASPathQuerier implements the PathQuerier interface. It will only provide AS-internal paths, i.e., zero-hops paths with only the IA as destination. This should only be used in places where you know that you only need to communicate inside the AS. The type of Path returned is a complete implementation with proper metadata.

func (IntraASPathQuerier) Query added in v0.9.0

func (q IntraASPathQuerier) Query(_ context.Context, _ addr.IA) ([]snet.Path, error)

Query implements PathQuerier.

type NetworkConfig

type NetworkConfig struct {
	// IA is the local AS number.
	IA addr.IA
	// Public is the Internet-reachable address in the case where the service
	// is behind NAT.
	Public *net.UDPAddr
	// ReconnectToDispatcher sets up sockets that automatically reconnect if
	// the dispatcher closes the connection (e.g., if the dispatcher goes
	// down).
	ReconnectToDispatcher bool
	// QUIC contains configuration details for QUIC servers. If the listening
	// address is the empty string, then no QUIC socket is opened.
	QUIC QUIC
	// SVCResolver is used to discover the underlay addresses of intra-AS SVC
	// servers.
	SVCResolver SVCResolver
	// SCMPHandler is the SCMP handler to use. This handler is only applied to
	// client connections. The connection the server listens on will always
	// ignore SCMP messages. Otherwise, the server will shutdown when receiving
	// an SCMP error message.
	SCMPHandler snet.SCMPHandler
	// Metrics injected into SCIONNetwork.
	SCIONNetworkMetrics snet.SCIONNetworkMetrics
	// Metrics injected into DefaultPacketDispatcherService.
	SCIONPacketConnMetrics snet.SCIONPacketConnMetrics
	// MTU of the local AS
	MTU uint16
}

NetworkConfig describes the networking configuration of a SCION control-plane RPC endpoint.

func (*NetworkConfig) AddressRewriter

func (nc *NetworkConfig) AddressRewriter(
	connFactory snet.PacketDispatcherService) *AddressRewriter

AddressRewriter initializes path and svc resolvers for infra servers.

The connection factory is used to open sockets for SVC resolution requests. If the connection factory is nil, the default connection factory is used.

func (*NetworkConfig) QUICStack

func (nc *NetworkConfig) QUICStack() (*QUICStack, error)

func (*NetworkConfig) TCPStack

func (nc *NetworkConfig) TCPStack() (net.Listener, error)

type QUIC

type QUIC struct {
	// Address is the UDP address to start the QUIC server on.
	Address string

	GetCertificate       func(*tls.ClientHelloInfo) (*tls.Certificate, error)
	GetClientCertificate func(*tls.CertificateRequestInfo) (*tls.Certificate, error)
	TLSVerifier          *trust.TLSCryptoVerifier
}

QUIC contains the QUIC configuration for control-plane speakers.

type QUICStack

type QUICStack struct {
	Listener       *squic.ConnListener
	InsecureDialer *squic.ConnDialer
	Dialer         *squic.ConnDialer
	RedirectCloser func()
}

QUICStack contains everything to run a QUIC based RPC stack.

type Resolver

type Resolver interface {
	// LookupSVC resolves the SVC address for the AS terminating the path.
	LookupSVC(ctx context.Context, path snet.Path, svc addr.SVC) (*svc.Reply, error)
}

Resolver performs SVC resolution for a remote AS, thus converting an anycast SVC address to a unicast IP/UDP one.

type SVCResolver

type SVCResolver interface {
	// GetUnderlay returns the underlay address of a SVC server of the specified
	// type. When multiple servers are available, the choice is random. If no
	// servers are available an error should be returned.
	GetUnderlay(svc addr.SVC) (*net.UDPAddr, error)
}

SVCResolver is used to construct underlay information for SVC servers running in the local AS.

Directories

Path Synopsis
Package mock_infraenv is a generated GoMock package.
Package mock_infraenv is a generated GoMock package.

Jump to

Keyboard shortcuts

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