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
// EnsureIPAddress checks if the specified IP Address is added to specified interface, if not, add it. If the address existed, return true.
EnsureIPAddress(args []string, intName string, ip net.IP) (bool, 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
// Set the DNS server for interface
SetDNSServer(iface string, dns string) error
}
Interface is an injectable interface for running netsh commands. Implementations must be goroutine-safe.
type Ipv4Interface ¶
type Ipv4Interface struct {
Idx int
Name string
InterfaceMetric int
DhcpEnabled bool
IpAddress string
SubnetPrefix int
GatewayMetric int
DefaultGatewayAddress string
DNS string
}
Ipv4Interface models IPv4 interface output from: netsh interface ipv4 show addresses
Click to show internal directories.
Click to hide internal directories.