tuntap

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TUN = 1
	TAP = 2
)

Variables

View Source
var (
	ErrDeviceMode = errors.New("unsupport device mode")
)

Functions

func AddIP

func AddIP(name, ip string) (err error)

AddIP 通过ip命令添加IP地址

func GetHardwareAddr

func GetHardwareAddr(name string) (string, error)

func NewNetDev

func NewNetDev(c *Config) (fd int, err error)

NewNetDev根据配置返回虚拟网卡的文件描述符

func SetLinkUp

func SetLinkUp(name string) (err error)

SetLinkUp 让系统启动该网卡

func SetRoute

func SetRoute(name, cidr string) (err error)

SetRoute 通过ip命令添加路由

Types

type Config

type Config struct {
	Name string // 网卡名
	Mode int    // 网卡模式,TUN or TAP
}

虚拟网卡设置的配置

Jump to

Keyboard shortcuts

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