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
- func AddHost(hostname, address string) error
- func ChoosePathByMetric(pathAlgo int, dst addr.IA) (snet.Path, error)
- func ChoosePathInteractive(dst addr.IA) (snet.Path, error)
- func Dial(address string) (*snet.Conn, error)
- func DialAddr(raddr *snet.UDPAddr) (*snet.Conn, error)
- func GetHostByName(hostname string) (snet.SCIONAddress, error)
- func GetHostnamesByAddress(address snet.SCIONAddress) ([]string, error)
- func Listen(listen *net.UDPAddr) (*snet.Conn, error)
- func ListenPort(port uint16) (*snet.Conn, error)
- func MangleSCIONAddr(address string) string
- func QueryPaths(ia addr.IA) ([]snet.Path, error)
- func ResolveUDPAddr(address string) (*snet.UDPAddr, error)
- func SetDefaultPath(addr *snet.UDPAddr) error
- func SetPath(addr *snet.UDPAddr, path snet.Path)
- func SplitHostPort(hostport string) (host, port string, err error)
- func UnmangleSCIONAddr(address string) string
- type Network
Constants ¶
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 ¶
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 ¶
ChoosePathByMetric chooses the best path based on the metric pathAlgo If the remote address is in the local IA, return (nil, nil).
func ChoosePathInteractive ¶
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 ¶
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 ¶
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 ¶
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 ¶
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
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 ¶
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 ¶
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 ¶
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 SplitHostPort ¶
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
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.