network

package
v0.0.0-...-6337964 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2014 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SelectInternalAddress

func SelectInternalAddress(addresses []Address, machineLocal bool) string

SelectInternalAddress picks one address from a slice that can be used as an endpoint for juju internal communication. If there are no suitable addresses, the empty string is returned.

func SelectInternalHostPort

func SelectInternalHostPort(hps []HostPort, machineLocal bool) string

SelectInternalHostPort picks one HostPort from a slice that can be used as an endpoint for juju internal communication and returns it in its NetAddr form. If there are no suitable addresses, the empty string is returned.

func SelectPublicAddress

func SelectPublicAddress(addresses []Address) string

SelectPublicAddress picks one address from a slice that would be appropriate to display as a publicly accessible endpoint. If there are no suitable addresses, the empty string is returned.

TODO(dimitern) Make this work properly with #IPv6 addresses.

func SelectPublicHostPort

func SelectPublicHostPort(hps []HostPort) string

func SortPorts

func SortPorts(ports []Port)

SortPorts sorts the given ports, first by protocol, then by number.

Types

type Address

type Address struct {
	Value       string
	Type        AddressType
	NetworkName string
	Scope
}

Address represents the location of a machine, including metadata about what kind of location the address describes.

func NewAddress

func NewAddress(value string, scope Scope) Address

NewAddress creates a new Address, deriving its type from the value.

If the specified scope is ScopeUnknown, then NewAddress will attempt derive the scope based on reserved IP address ranges.

func NewAddresses

func NewAddresses(inAddresses ...string) (outAddresses []Address)

NewAddresses is a convenience function to create addresses from a string slice

func (Address) String

func (a Address) String() string

String returns a string representation of the address, in the form: scope:address(network name); for example:

public:c2-54-226-162-124.compute-1.amazonaws.com(ec2network)

If the scope is NetworkUnknown, the initial scope: prefix will be omitted. If the NetworkName is blank, the (network name) suffix will be omitted.

type AddressType

type AddressType string

AddressType represents the possible ways of specifying a machine location by either a hostname resolvable by dns lookup, or IPv4 or IPv6 address.

const (
	HostName    AddressType = "hostname"
	IPv4Address AddressType = "ipv4"
	IPv6Address AddressType = "ipv6"
)

func DeriveAddressType

func DeriveAddressType(value string) AddressType

DeriveAddressType attempts to detect the type of address given.

type BasicInfo

type BasicInfo struct {
	// CIDR of the network, in 123.45.67.89/24 format. Can be empty if
	// unknown.
	CIDR string

	// ProviderId is a provider-specific network id. This the only
	// required field.
	ProviderId Id

	// VLANTag needs to be between 1 and 4094 for VLANs and 0 for
	// normal networks. It's defined by IEEE 802.1Q standard, and used
	// to define a VLAN network. For more information, see:
	// http://en.wikipedia.org/wiki/IEEE_802.1Q.
	VLANTag int
}

BasicInfo describes the bare minimum information for a network, which the provider knows about but juju might not yet.

type HostPort

type HostPort struct {
	Address
	Port int
}

HostPort associates an address with a port.

func AddressesWithPort

func AddressesWithPort(addrs []Address, port int) []HostPort

AddressesWithPort returns the given addresses all associated with the given port.

func (HostPort) NetAddr

func (hp HostPort) NetAddr() string

NetAddr returns the host-port as an address suitable for calling net.Dial.

type Id

type Id string

Id defines a provider-specific network id.

type Info

type Info struct {
	// MACAddress is the network interface's hardware MAC address
	// (e.g. "aa:bb:cc:dd:ee:ff").
	MACAddress string

	// CIDR of the network, in 123.45.67.89/24 format.
	CIDR string

	// NetworkName is juju-internal name of the network.
	NetworkName string

	// ProviderId is a provider-specific network id.
	ProviderId Id

	// VLANTag needs to be between 1 and 4094 for VLANs and 0 for
	// normal networks. It's defined by IEEE 802.1Q standard.
	VLANTag int

	// InterfaceName is the raw OS-specific network device name (e.g.
	// "eth1", even for a VLAN eth1.42 virtual interface).
	InterfaceName string

	// Disabled is true when the interface needs to be disabled on the
	// machine, e.g. not to configure it.
	Disabled bool
}

Info describes a single network interface available on an instance. For providers that support networks, this will be available at StartInstance() time.

func (*Info) ActualInterfaceName

func (i *Info) ActualInterfaceName() string

ActualInterfaceName returns raw interface name for raw interface (e.g. "eth0") and virtual interface name for virtual interface (e.g. "eth0.42")

func (*Info) IsVirtual

func (i *Info) IsVirtual() bool

IsVirtual returns true when the interface is a virtual device, as opposed to a physical device (e.g. a VLAN or a network alias)

type Port

type Port struct {
	Protocol string
	Number   int
}

Port identifies a network port number for a particular protocol.

func (Port) String

func (p Port) String() string

String implements Stringer.

type Scope

type Scope string

Scope denotes the context a location may apply to. If a name or address can be reached from the wider internet, it is considered public. A private network address is either specific to the cloud or cloud subnet a machine belongs to, or to the machine itself for containers.

const (
	ScopeUnknown      Scope = ""
	ScopePublic       Scope = "public"
	ScopeCloudLocal   Scope = "local-cloud"
	ScopeMachineLocal Scope = "local-machine"
)

Jump to

Keyboard shortcuts

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