tuntap

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: May 31, 2023 License: Apache-2.0 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 AddGateWay

func AddGateWay(dst, gateway, name string) (err error)

AddGateWay 通过ip命令 添加网关

func AddIP

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

AddIP 通过ip命令添加ip地址

func CreateTap

func CreateTap(name string) (err error)

CreateTap 通过命令行 ip 创建网卡

func DelTap

func DelTap(name string) (err error)

DelTap 删除网卡

func GetHardwareAddr

func GetHardwareAddr(name string) (string, error)

GetHardwareAddr gethard

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