sys

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddDNATRule

func AddDNATRule(protocol, sourceIP, sourcePort, destIP, destPort string) error

AddDNATRule adds a DNAT rule to iptables PRERROUTING chain

func AddForwardIntRule

func AddForwardIntRule(inInt, outInt string) error

AddForwardIntRule adds a FORWARD between interfaces rule to iptables

func AddForwardRule

func AddForwardRule(protocol, destIP, destPort string) error

AddForwardRule adds an ip:port FORWARD rule to iptables

func AddMasqueradeRule

func AddMasqueradeRule() error

AddMasqueradeRule adds a MASQUERADE rule to iptables POSTROUTING chain

func AddRelEstRule

func AddRelEstRule(chain string) error

AddRelEstRule adds a RELATED,ESTABLISHED rule to specified chain of iptables

func DelDNATRule

func DelDNATRule(protocol, sourceIP, sourcePort, destIP, destPort string) error

DelDNATRule deletes a DNAT rule to iptables PRERROUTING chain if it exists

func DelForwardIntRule

func DelForwardIntRule(inInt, outInt string) error

DelForwardIntRule deletes a FORWARD between interfaces rule if it exists

func DelForwardRule

func DelForwardRule(protocol, destIP, destPort string) error

DelForwardRule deletes an ip:port FORWARD rule if it exists

func DelMasqueradeRule

func DelMasqueradeRule() error

DelMasqueradeRule deletes a MASQUERADE rule from the POSTROUTING chain if it exists

func DelRelEstRule

func DelRelEstRule(chain string) error

DelRelEstRule deletes a RELATED,ESTABLISHED rule from the specified chain if it exists

func ForwardingEnabled

func ForwardingEnabled() (bool, error)

ForwardingEnabled checks if IP forwarding is enabled

func GetNetInterfaceByName

func GetNetInterfaceByName(name string) (*net.Interface, error)

GetNetInterfaceByName gets the network interface by name

func GetNetInterfaces

func GetNetInterfaces() ([]net.Interface, error)

GetNetInterfaces gets the list of network interfaces

func GetUsedAddresses

func GetUsedAddresses() ([]string, error)

Types

type NetInterface

type NetInterface struct {
	Iface *water.Interface
	Src   string
	Dst   string
}

// TUN is a struct containing the fields necessary // to configure a system TUN device. Access the // internal TUN device through TUN.Iface

func NewTunTapInterface

func NewTunTapInterface(name string, mode TunTapMode, persist bool) (*NetInterface, error)

NewTunTapInterface creates a new tun/tap interface

func (*NetInterface) AddRouteRule

func (n *NetInterface) AddRouteRule(src, dst, gw string) error

AddRouteRule adds an ip route rule to the network interface

func (*NetInterface) DelRoute

func (n *NetInterface) DelRoute(route string) error

DelRoute deletes a route from the network interface

func (*NetInterface) Delete

func (n *NetInterface) Delete() error

DeleteNetInterface deletes the network interface

func (*NetInterface) Down

func (n *NetInterface) Down() error

DownNetInterface brings the network interface down

func (*NetInterface) SetAddress

func (n *NetInterface) SetAddress(address string) error

SetAddress sets the address of the network interface in CIDR notation

func (*NetInterface) SetMTU

func (n *NetInterface) SetMTU(mtu int) error

SetMTU sets the MTU of the network interface

func (*NetInterface) Up

func (n *NetInterface) Up() error

UpNetInterface brings the network interface up

type TunTapMode

type TunTapMode int

types for tun tap

const (
	NetTunMode TunTapMode = iota
	NetTapMode
)

Jump to

Keyboard shortcuts

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