Documentation
¶
Index ¶
- func DiscoverGateway() (ip net.IP, err error)
- func DiscoverGatewayIPv6() (ip net.IP, err error)
- func DiscoverGateways() (ips []net.IP, err error)
- func DiscoverGatewaysIPv6() (ips []net.IP, err error)
- func DiscoverInterface() (ip net.IP, err error)
- func DiscoverInterfaceIPv6() (ip net.IP, err error)
- type ErrCantParse
- type ErrInvalidRouteFileFormat
- type ErrNoGateway
- type ErrNotImplemented
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DiscoverGateway ¶
DiscoverGateway is the OS independent function to get the default gateway
Example ¶
gateway, err := DiscoverGateway()
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Gateway:", gateway.String())
}
func DiscoverGatewayIPv6 ¶ added in v1.2.0
DiscoverGatewayIPv6 is the OS independent function to get the default IPv6 gateway
func DiscoverGateways ¶ added in v1.1.0
DiscoverGateways is the OS independent function to get all gateways. If err is nil, then ips is guarenteed to have at least one element.
func DiscoverGatewaysIPv6 ¶ added in v1.2.0
DiscoverGatewaysIPv6 is the OS independent function to get all IPv6 default gateways. If err is nil, then ips is guaranteed to have at least one element.
func DiscoverInterface ¶ added in v1.0.7
DiscoverInterface is the OS independent function to call to get the default network interface IP that uses the default gateway
func DiscoverInterfaceIPv6 ¶ added in v1.2.0
DiscoverInterfaceIPv6 is the OS independent function to call to get the default network interface IPv6 address that uses the default gateway
Types ¶
type ErrCantParse ¶ added in v1.0.12
type ErrCantParse struct{}
ErrCantParse is returned if the route table is garbage.
func (*ErrCantParse) Error ¶ added in v1.0.12
func (*ErrCantParse) Error() string
type ErrInvalidRouteFileFormat ¶ added in v1.0.12
type ErrInvalidRouteFileFormat struct {
// contains filtered or unexported fields
}
ErrInvalidRouteFileFormat is returned if the format of /proc/net/route is unexpected on Linux systems. Please raise an issue.
func (*ErrInvalidRouteFileFormat) Error ¶ added in v1.0.12
func (e *ErrInvalidRouteFileFormat) Error() string
type ErrNoGateway ¶ added in v1.0.12
type ErrNoGateway struct{}
ErrNoGateway is returned if a valid gateway entry was not found in the route table.
func (*ErrNoGateway) Error ¶ added in v1.0.12
func (*ErrNoGateway) Error() string
type ErrNotImplemented ¶ added in v1.0.13
type ErrNotImplemented struct{}
ErrNotImplemented is returned if your operating system is not supported by this package. Please raise an issue to request support.
func (*ErrNotImplemented) Error ¶ added in v1.0.13
func (*ErrNotImplemented) Error() string