Documentation ¶
Overview ¶
Package topology wraps two versions of the topology. The first is RawTopo (in raw.go), which closely matches the JSON format. It is mainly used for loading the topology from disk. The second data structure is Topo. It is used by Go code directly and thus has a different structure and stricter types.
Index ¶
- Constants
- func LinkTypeFromString(s string) (proto.LinkType, error)
- func StripBind(rt *RawTopo)
- func StripServices(rt *RawTopo)
- type BRInfo
- type IDAddrMap
- type IFInfo
- type IfInfoMap
- type OverBindAddr
- type Provider
- type RawAddr
- type RawAddrMap
- type RawAddrOverlay
- type RawAddrPort
- type RawAddrPortOverlay
- type RawBRAddrMap
- type RawBRInfo
- type RawBRIntf
- type RawOverlayBind
- type RawPubBindOverlay
- type RawSrvInfo
- type RawTopo
- type ServiceNames
- type Topo
- func (t *Topo) Active(now time.Time) bool
- func (t *Topo) Expiry() time.Time
- func (t *Topo) GetAllTopoAddrs(svc proto.ServiceType) ([]TopoAddr, error)
- func (t *Topo) GetAnyTopoAddr(svc proto.ServiceType) (*TopoAddr, error)
- func (t *Topo) GetTopoAddr(id string, svc proto.ServiceType) (*TopoAddr, error)
- type TopoAddr
- func (t *TopoAddr) BindAddr(ot overlay.Type) *addr.AppAddr
- func (t *TopoAddr) BindOrPublic(ot overlay.Type) *addr.AppAddr
- func (t *TopoAddr) Equal(o *TopoAddr) bool
- func (t *TopoAddr) OverlayAddr(ot overlay.Type) *overlay.OverlayAddr
- func (t *TopoAddr) PublicAddr(ot overlay.Type) *addr.AppAddr
- func (t *TopoAddr) String() string
- type TopoBRAddr
- func (t *TopoBRAddr) BindOrPublicOverlay(ot overlay.Type) *overlay.OverlayAddr
- func (t *TopoBRAddr) BindOverlay(ot overlay.Type) *overlay.OverlayAddr
- func (t *TopoBRAddr) Equal(o *TopoBRAddr) bool
- func (t *TopoBRAddr) PublicOverlay(ot overlay.Type) *overlay.OverlayAddr
- func (t *TopoBRAddr) String() string
Constants ¶
const ( ErrUnsupportedOverlay common.ErrMsg = "Unsupported overlay" ErrUnsupportedAddrType common.ErrMsg = "Unsupported address type" ErrInvalidPub common.ErrMsg = "Invalid public address" ErrInvalidBind common.ErrMsg = "Invalid bind address" ErrAtLeastOnePub common.ErrMsg = "Overlay requires at least one public address" ErrOverlayPort common.ErrMsg = "Overlay port set for non-UDP overlay" ErrBindAddrEqPubAddr common.ErrMsg = "Bind address equal to Public address" ErrMismatchOverlayAddr common.ErrMsg = "Mismatch overlay type and address" ErrMismatchPubAddrType common.ErrMsg = "Mismatch public address and type " ErrMismatchBindAddrType common.ErrMsg = "Mismatch bind address and type" )
const ( ErrOpen common.ErrMsg = "Unable to open topology" ErrParse common.ErrMsg = "Unable to parse topology from JSON" ErrConvert common.ErrMsg = "Unable to convert RawTopo to Topo" )
const ( // CoreLinkName indicates a link going to a neighboring core AS. CoreLinkName = "CORE" // ParentLinkName indicates a link to a parent AS. ParentLinkName = "PARENT" // ChildLinkName indicates a link to a child AS. ChildLinkName = "CHILD" // PeerLinkName indicates a link to a neighboring peer AS. PeerLinkName = "PEER" )
const CfgName = "topology.json"
Variables ¶
This section is empty.
Functions ¶
func LinkTypeFromString ¶
LinkTypeFromString parses the link type.
func StripServices ¶
func StripServices(rt *RawTopo)
Types ¶
type BRInfo ¶
type BRInfo struct { Name string // CtrlAddrs are the local control-plane addresses. CtrlAddrs *TopoAddr // InternalAddrs are the local data-plane addresses. InternalAddrs *TopoBRAddr // IFIDs is a sorted list of the interface IDs. IFIDs []common.IFIDType // IFs is a map of interface IDs. IFs map[common.IFIDType]*IFInfo }
BRInfo is a list of AS-wide unique interface IDs for a router. These IDs are also used to point to the specific internal address clients should send their traffic to in order to use that interface, via the IFInfoMap member of the Topo struct.
type IFInfo ¶
type IFInfo struct { // Id is the interface ID. It is unique per AS. Id common.IFIDType BRName string CtrlAddrs *TopoAddr Overlay overlay.Type InternalAddrs *TopoBRAddr Local *TopoBRAddr Remote *overlay.OverlayAddr RemoteIFID common.IFIDType Bandwidth int ISD_AS addr.IA LinkType proto.LinkType MTU int }
IFInfo describes a border router link to another AS, including the internal address applications should send traffic for the link to (InternalAddrs) and information about the link itself and the remote side of it.
type OverBindAddr ¶ added in v0.4.0
type OverBindAddr struct { PublicOverlay *overlay.OverlayAddr BindOverlay *overlay.OverlayAddr }
func (*OverBindAddr) BindOrPublicOverlay ¶ added in v0.4.0
func (t *OverBindAddr) BindOrPublicOverlay() *overlay.OverlayAddr
func (*OverBindAddr) Equal ¶ added in v0.4.0
func (t1 *OverBindAddr) Equal(t2 *OverBindAddr) bool
func (*OverBindAddr) String ¶ added in v0.4.0
func (a *OverBindAddr) String() string
type Provider ¶ added in v0.4.0
type Provider interface { // Get returns a topology. The returned topology is guaranteed to not be // nil. Get() *Topo }
Provider provides a topology.
type RawAddrMap ¶ added in v0.3.0
type RawAddrMap map[string]*RawPubBindOverlay
func (RawAddrMap) String ¶ added in v0.3.0
func (ram RawAddrMap) String() string
func (RawAddrMap) ToTopoAddr ¶ added in v0.3.0
func (ram RawAddrMap) ToTopoAddr(ot overlay.Type) (t *TopoAddr, err error)
type RawAddrOverlay ¶ added in v0.3.0
func (RawAddrOverlay) String ¶ added in v0.3.0
func (a RawAddrOverlay) String() string
type RawAddrPort ¶
func (RawAddrPort) String ¶
func (a RawAddrPort) String() string
type RawAddrPortOverlay ¶
type RawAddrPortOverlay struct { RawAddrPort OverlayPort int `json:",omitempty"` }
Since Public addresses may be associated with an Overlay port, extend the structure used for Bind addresses.
func (RawAddrPortOverlay) String ¶
func (a RawAddrPortOverlay) String() string
type RawBRAddrMap ¶ added in v0.3.0
type RawBRAddrMap map[string]*RawOverlayBind
func (RawBRAddrMap) String ¶ added in v0.3.0
func (roa RawBRAddrMap) String() string
func (RawBRAddrMap) ToTopoBRAddr ¶ added in v0.3.0
func (roa RawBRAddrMap) ToTopoBRAddr(ot overlay.Type) (t *TopoBRAddr, err error)
type RawBRInfo ¶
type RawBRInfo struct { InternalAddrs RawBRAddrMap CtrlAddr RawAddrMap Interfaces map[common.IFIDType]*RawBRIntf }
RawBRInfo contains Border Router specific information.
type RawBRIntf ¶
type RawBRIntf struct { Overlay string `json:",omitempty"` PublicOverlay *RawAddrOverlay `json:",omitempty"` BindOverlay *RawAddr `json:",omitempty"` RemoteOverlay *RawAddrOverlay `json:",omitempty"` Bandwidth int ISD_AS string LinkTo string MTU int }
type RawOverlayBind ¶ added in v0.3.0
type RawOverlayBind struct { PublicOverlay RawAddrOverlay BindOverlay *RawAddr `json:",omitempty"` }
func (RawOverlayBind) String ¶ added in v0.3.0
func (b RawOverlayBind) String() string
type RawPubBindOverlay ¶ added in v0.3.0
type RawPubBindOverlay struct { Public RawAddrPortOverlay Bind *RawAddrPort `json:",omitempty"` }
func (RawPubBindOverlay) String ¶ added in v0.3.0
func (rpbo RawPubBindOverlay) String() string
type RawSrvInfo ¶ added in v0.3.0
type RawSrvInfo struct {
Addrs RawAddrMap
}
func (RawSrvInfo) String ¶ added in v0.3.0
func (ras RawSrvInfo) String() string
type RawTopo ¶
type RawTopo struct { Timestamp int64 TimestampHuman string TTL uint32 ISD_AS string Overlay string MTU int Core bool BorderRouters map[string]*RawBRInfo `json:",omitempty"` ZookeeperService map[int]*RawAddrPort `json:",omitempty"` BeaconService map[string]*RawSrvInfo `json:",omitempty"` CertificateService map[string]*RawSrvInfo `json:",omitempty"` PathService map[string]*RawSrvInfo `json:",omitempty"` SibraService map[string]*RawSrvInfo `json:",omitempty"` RainsService map[string]*RawSrvInfo `json:",omitempty"` SIG map[string]*RawSrvInfo `json:",omitempty"` DiscoveryService map[string]*RawSrvInfo `json:",omitempty"` }
RawTopo is used to un/marshal from/to JSON and should usually not be used by Go code directly. Use Topo (from lib/topology/topology.go) instead.
func LoadRawFromFile ¶
type ServiceNames ¶ added in v0.3.0
type ServiceNames []string
func (ServiceNames) GetRandom ¶ added in v0.3.0
func (s ServiceNames) GetRandom() (string, error)
GetRandom returns a random entry, or an error if the slice is empty.
type Topo ¶
type Topo struct { Timestamp time.Time TimestampHuman string // This can vary wildly in format and is only for informational purposes. TTL time.Duration ISD_AS addr.IA Overlay overlay.Type MTU int Core bool BR map[string]BRInfo BRNames []string // This maps Interface IDs to internal addresses. Clients use this to // figure out which internal BR address they have to send their traffic to // if they want to use a given interface. IFInfoMap IfInfoMap BS IDAddrMap BSNames ServiceNames CS IDAddrMap CSNames ServiceNames PS IDAddrMap PSNames ServiceNames SB IDAddrMap SBNames ServiceNames RS IDAddrMap RSNames ServiceNames DS IDAddrMap DSNames ServiceNames SIG IDAddrMap SIGNames ServiceNames ZK map[int]*addr.AppAddr }
Topo is the main struct encompassing topology information for use in Go code. The first section contains metadata about the topology. All of these fields should be self-explanatory. The unit of TTL is seconds, with the zero value indicating an infinite TTL.
The second section concerns the Border routers. BRNames is just a sorted slice of the names of the BRs in this topolgy. Its contents is exactly the same as the keys in the BR map.
The BR map points from border router names to BRInfo structs, which in turn are lists of IFID type slices, thus defines the IFIDs that belong to a particular border router. The IFInfoMap points from interface IDs to IFInfo structs.
The third section in Topo concerns the SCION-specific services in the topology. The structure is identical between the various elements. For each service, there is again a sorted slice of names of the servers that provide the service. Additionally, there is a map from those names to TopoAddr structs.
func LoadFromFile ¶
func NewTopo ¶
func NewTopo() *Topo
NewTopo creates new empty Topo object, including all possible service maps etc.
func TopoFromRaw ¶
TopoFromRaw converts a JSON-filled RawTopo to a Topo usable by Go code.
func (*Topo) Expiry ¶ added in v0.4.0
Expiry returns the expiration time of the topology. If TTL is zero, the zero value is returned.
func (*Topo) GetAllTopoAddrs ¶ added in v0.3.1
func (t *Topo) GetAllTopoAddrs(svc proto.ServiceType) ([]TopoAddr, error)
func (*Topo) GetAnyTopoAddr ¶ added in v0.4.0
func (t *Topo) GetAnyTopoAddr(svc proto.ServiceType) (*TopoAddr, error)
func (*Topo) GetTopoAddr ¶
type TopoAddr ¶
TopoAddr wraps the possible addresses of a SCION service and describes the overlay to be used for contacting said service.
func TestTopoAddr ¶ added in v0.3.1
func TestTopoAddr(v4AppAddr, v6AppAddr *addr.AppAddr, v4OverlayAddr, v6OverlayAddr *overlay.OverlayAddr) TopoAddr
TestTopoAddr creates a new TopoAddr. This is only for testing and should never be used by apps.
func (*TopoAddr) BindOrPublic ¶ added in v0.2.0
func (*TopoAddr) OverlayAddr ¶ added in v0.2.0
func (t *TopoAddr) OverlayAddr(ot overlay.Type) *overlay.OverlayAddr
func (*TopoAddr) PublicAddr ¶ added in v0.2.0
type TopoBRAddr ¶ added in v0.3.0
type TopoBRAddr struct { IPv4 *OverBindAddr IPv6 *OverBindAddr Overlay overlay.Type }
func (*TopoBRAddr) BindOrPublicOverlay ¶ added in v0.3.0
func (t *TopoBRAddr) BindOrPublicOverlay(ot overlay.Type) *overlay.OverlayAddr
func (*TopoBRAddr) BindOverlay ¶ added in v0.3.0
func (t *TopoBRAddr) BindOverlay(ot overlay.Type) *overlay.OverlayAddr
func (*TopoBRAddr) Equal ¶ added in v0.3.0
func (t *TopoBRAddr) Equal(o *TopoBRAddr) bool
func (*TopoBRAddr) PublicOverlay ¶ added in v0.3.0
func (t *TopoBRAddr) PublicOverlay(ot overlay.Type) *overlay.OverlayAddr
func (*TopoBRAddr) String ¶ added in v0.3.0
func (t *TopoBRAddr) String() string