nmcli

package
v0.0.0-...-4a210da Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UP     = "up"
	DOWN   = "down"
	ADD    = "+"
	DELETE = "-"
	YES    = "yes"
	No     = "no"
)

Variables

This section is empty.

Functions

func AddOrDeleteIp

func AddOrDeleteIp(connectionID string, ip, mask string, operation string) ([]string, error)

添加或者删除ip地址

func GetStdoutText

func GetStdoutText(r io.Reader) (stdout []string)

GetStdoutText reads out and concats string from io.Reader

func ImportOvpnConnection

func ImportOvpnConnection(filepath string) ([]string, error)

ImportOvpnConnection imports connection from openvpn file

func ModifyConnection

func ModifyConnection(connectionID string, settings OvpnConnectionDefaults) ([]string, error)

ModifyConnection modifies the specified connection using settings provided

func ModifyIp

func ModifyIp(connectionID string, settings IpDefaults) ([]string, error)

ModifyConnection modifies the connectionID Ip

func SaveFile

func SaveFile(filepath string, file []byte, permissions int) error

SaveFile saves file at given path

func StringIpToInt

func StringIpToInt(ipstring string) int

func UnusedRoute

func UnusedRoute(connectionID string, ret string) ([]string, error)

是否忽略网关 nmcli connection modify Wired\ connection\ 2 ipv4.never-default yes

func UpDownConnect

func UpDownConnect(connectionID string, updown string) ([]string, error)

nmcli connection up "有线连接 1"

Types

type Auth

type Auth struct {
	Mode string
	User string
	Pass string
}

Auth holds authentication details for setting up a connection

type IpDefaults

type IpDefaults struct {
	DNS         string
	Ipv4Address string
	Ipv4Gateway string
	IgnoreIPV6  bool
}

IpDefaults settings to apply to an existing NetworkManager connection

type NetworkConnection

type NetworkConnection struct {
	Name   string
	UUID   string
	Type   string
	Device string
}

NetworkConnection connection information provided by nmcli

type NetworkConnections

type NetworkConnections []NetworkConnection

NetworkConnections array of NetworkConnection

func ListConnections

func ListConnections(onlyActive bool) (out NetworkConnections, err error)

ListConnections shows connections via nmcli command

func (*NetworkConnections) FilterByType

func (ncs *NetworkConnections) FilterByType(typeName string)

FilterByType excludes given type string

type OvpnConnectionDefaults

type OvpnConnectionDefaults struct {
	DNS          string
	AuthSettings Auth
	IgnoreIPV6   bool
}

OvpnConnectionDefaults settings to apply to an existing NetworkManager connection

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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