common

package module
v0.0.0-...-0ec82b5 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2018 License: Apache-2.0 Imports: 2 Imported by: 1

README

common

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAddresses

func GetAddresses() ([]string, error)

GetAddresses returns a slice of all detected external addresses or an error if any

Types

type Addr

type Addr struct {
	MainAddr string
	Port     uint16
	Addrs    []string
}

Addr is an interface for net.Addr.

func MustNewAddr

func MustNewAddr(port uint16) *Addr

MustNewAddr does the same as NewAddr but returns an empty main address as "::"

func NewAddr

func NewAddr(port uint16) (*Addr, error)

NewAddr build a new Addr pointer with all addresses for every network interfaces with the first external IP as default or an error if any

func (*Addr) AddAddr

func (a *Addr) AddAddr(new string) (addAtIndex int)

AddAddr adds a new address to the list and returns it's position

func (*Addr) AddAddrAndSwitch

func (a *Addr) AddAddrAndSwitch(new string)

AddAddrAndSwitch does the same as AddAddr but switch to the new address as main address

func (*Addr) ForListenerBroadcast

func (a *Addr) ForListenerBroadcast() string

ForListenerBroadcast can be used for listeners to listen on any interfaces at the registered port

func (*Addr) IP

func (a *Addr) IP() net.IP

IP returns the main address as a net.IP variable

func (*Addr) Network

func (a *Addr) Network() string

Network returns "tcp", it's part of the net.Addr interface

func (*Addr) String

func (a *Addr) String() string

String returns the main address with the port as net.Addr expect it

func (*Addr) SwitchMain

func (a *Addr) SwitchMain(i int) string

SwitchMain switch the default address returned by Addr which is the port of the net.Addr interface

Jump to

Keyboard shortcuts

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