net

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2021 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package net supplies some assistant functions about net, such as the gateway ip and routes.

Index

Constants

This section is empty.

Variables

View Source
var ErrRouteTableNotImplemented = errors.New("route table has not implemented")

ErrRouteTableNotImplemented is returned when the route table has not implemented.

Functions

func GetDefaultGateway

func GetDefaultGateway() (gateway net.IP, err error)

GetDefaultGateway returns the default gateway.

func GetDefaultIP

func GetDefaultIP() (ip string, err error)

GetDefaultIP returns the default ip.

Types

type Route

type Route struct {
	Dst *net.IPNet
	Src net.IP
	Gw  net.IP
}

Route is the route information.

type Routes

type Routes []Route

Routes is a set of Routes.

func GetIPv4Routes

func GetIPv4Routes() (Routes, error)

GetIPv4Routes returns the ipv4 routes.

func GetIPv6Routes

func GetIPv6Routes() (Routes, error)

GetIPv6Routes returns the ipv6 routes.

func (Routes) DefaultGateway

func (rs Routes) DefaultGateway() net.IP

DefaultGateway returns the default gateway. Return nil if not exist.

Jump to

Keyboard shortcuts

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