appnet

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package appnet provides a simplified and functionally extended wrapper interface to the scionproto/scion package snet.

Dispatcher and SCION daemon connections

During the hidden initialisation of this package, the dispatcher and sciond connections are opened. The sciond connection determines the local IA. The dispatcher and sciond sockets are assumed to be at default locations, but this can be overridden using environment variables:

SCION_DISPATCHER_SOCKET: /run/shm/dispatcher/default.sock
SCION_DAEMON_ADDRESS: 127.0.0.1:30255

This is convenient for the normal use case of running a the endhost stack for a single SCION AS. When running multiple local ASes, e.g. during development, the address of the sciond corresponding to the desired AS needs to be specified in the SCION_DAEMON_ADDRESS environment variable.

Wildcard IP Addresses

snet does not currently support binding to wildcard addresses. This will hopefully be added soon-ish, but in the meantime, this package emulates this functionality. There is one restriction, that applies to hosts with multiple IP addresses in the AS: the behaviour will be that of binding to one specific local IP address, which means that the application will not be reachable using any of the other IP addresses. Traffic sent will always appear to originate from this specific IP address, even if that's not the correct route to a destination in the local AS.

This restriction will very likely not cause any issues, as a fairly contrived network setup would be required. Also, sciond has a similar restriction (binds to one specific IP address).

Index

Constants

View Source
const (
	PathAlgoDefault = iota // default algorithm
	MTU                    // metric for path with biggest MTU
	Shortest               // metric for shortest path
)

metrics for path selection

Variables

This section is empty.

Functions

func AddHost

func AddHost(hostname, address string) error

AddHost adds a host to the map of known hosts An error is returned if the address has a wrong format or the hostname already exists The added host will not persist between program executions

func ChoosePathByMetric

func ChoosePathByMetric(pathAlgo int, dst addr.IA) (snet.Path, error)

ChoosePathByMetric chooses the best path based on the metric pathAlgo If the remote address is in the local IA, return (nil, nil).

func ChoosePathInteractive

func ChoosePathInteractive(dst addr.IA) (snet.Path, error)

ChoosePathInteractive presents the user a selection of paths to choose from. If the remote address is in the local IA, return (nil, nil), without prompting the user.

func Dial

func Dial(address string) (*snet.Conn, error)

Dial connects to the address (on the SCION/UDP network). The address can be of the form of a SCION address (i.e. of the form "ISD-AS,[IP]:port") or in the form of hostname:port.

func DialAddr

func DialAddr(raddr *snet.UDPAddr) (*snet.Conn, error)

DialAddr connects to the address (on the SCION/UDP network).

If no path is specified in raddr, DialAddr will choose the first available path. This path is never updated during the lifetime of the conn. This does not support long lived connections well, as the path *will* expire. This is all that snet currently provides, we'll need to add a layer on top that updates the paths in case they expire or are revoked.

func GetHostByName

func GetHostByName(hostname string) (snet.SCIONAddress, error)

GetHostByName returns the IA and HostAddr corresponding to hostname

func GetHostnamesByAddress

func GetHostnamesByAddress(address snet.SCIONAddress) ([]string, error)

GetHostnamesByAddress returns the hostnames corresponding to address TODO: (chaehni) RAINS address query to resolve address to name

func Listen

func Listen(listen *net.UDPAddr) (*snet.Conn, error)

Listen acts like net.ListenUDP in a SCION network. The listen address or parts of it may be nil or unspecified, signifying to listen on a wildcard address.

See note on wildcard addresses in the package documentation.

func ListenPort

func ListenPort(port uint16) (*snet.Conn, error)

ListenPort is a shortcut to Listen on a specific port with a wildcard IP address.

See note on wildcard addresses in the package documentation.

func MangleSCIONAddr added in v0.2.0

func MangleSCIONAddr(address string) string

MangleSCIONAddr mangles a SCION address string (if it is one) so it can be safely used in the host part of a URL.

func QueryPaths

func QueryPaths(ia addr.IA) ([]snet.Path, error)

QueryPaths queries the DefNetwork's sciond PathQuerier connection for paths to addr If addr is in the local IA, an empty slice and no error is returned.

func ResolveUDPAddr

func ResolveUDPAddr(address string) (*snet.UDPAddr, error)

ResolveUDPAddr parses the address and resolves the hostname. The address can be of the form of a SCION address (i.e. of the form "ISD-AS,[IP]:port") or in the form of "hostname:port".

func SetDefaultPath

func SetDefaultPath(addr *snet.UDPAddr) error

SetDefaultPath sets the first path returned by a query to sciond. This is a no-op if if remote is in the local AS.

func SetPath

func SetPath(addr *snet.UDPAddr, path snet.Path)

SetPath is a helper function to set the path on an snet.UDPAddr

func SplitHostPort

func SplitHostPort(hostport string) (host, port string, err error)

SplitHostPort splits a host:port string into host and port variables. This is analogous to net.SplitHostPort, which however refuses to handle SCION addresses. The address can be of the form of a SCION address (i.e. of the form "ISD-AS,[IP]:port") or in the form of "hostname:port".

func UnmangleSCIONAddr added in v0.2.0

func UnmangleSCIONAddr(address string) string

UnmangleSCIONAddr returns a SCION address that can be parsed with with snet.ParseUDPAddr. If the input is not a SCION address (e.g. a hostname), the address is returned unchanged. This parses the address, so that it can safely join host and port, with the brackets in the right place. Yes, this means this will be parsed twice.

Assumes that address always has a port (this is enforced by the http3 roundtripper code)

Types

type Network

type Network struct {
	snet.Network
	IA          addr.IA
	PathQuerier snet.PathQuerier
	// contains filtered or unexported fields
}

Network extends the snet.Network interface by making the local IA and common sciond connections public. The default singleton instance of this type is obtained by the DefNetwork function.

func DefNetwork

func DefNetwork() *Network

DefNetwork initialises and returns the singleton default Network. Typically, this will not be needed for applications directly, as they can use the simplified Dial/Listen functions provided here.

Directories

Path Synopsis
Package appquic provides a simple interface to use QUIC over SCION.
Package appquic provides a simple interface to use QUIC over SCION.

Jump to

Keyboard shortcuts

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