netsh

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// EnsurePortProxyRule checks if the specified redirect exists, if not creates it
	EnsurePortProxyRule(args []string) (bool, error)
	// DeletePortProxyRule deletes the specified portproxy rule.  If the rule did not exist, return error.
	DeletePortProxyRule(args []string) error
	// DeleteIPAddress checks if the specified IP address is present and, if so, deletes it.
	DeleteIPAddress(args []string) error
	// Restore runs `netsh exec` to restore portproxy or addresses using a file.
	// TODO Check if this is required, most likely not
	Restore(args []string) error
	// Get the interface name that has the default gateway
	GetDefaultGatewayIfaceName() (string, error)
	// Get a list of interfaces and addresses
	GetInterfaces() ([]Ipv4Interface, error)
	// Gets an interface by name
	GetInterfaceByName(name string) (Ipv4Interface, error)
	// Gets an interface by ip address in the format a.b.c.d
	GetInterfaceByIP(ipAddr string) (Ipv4Interface, error)
	// Enable forwarding on the interface (name or index)
	EnableForwarding(iface string) error
}

Interface is an injectable interface for running netsh commands. Implementations must be goroutine-safe.

func New

func New(exec utilexec.Interface) Interface

New returns a new Interface which will exec netsh.

type Ipv4Interface

type Ipv4Interface struct {
	Idx                   int
	Name                  string
	InterfaceMetric       int
	DhcpEnabled           bool
	IpAddress             string
	SubnetPrefix          int
	GatewayMetric         int
	DefaultGatewayAddress string
}

Ipv4Interface models IPv4 interface output from: netsh interface ipv4 show addresses

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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