Documentation
¶
Index ¶
- func AddDNATRule(protocol, sourceIP, sourcePort, destIP, destPort string) error
- func AddForwardIntRule(inInt, outInt string) error
- func AddForwardRule(protocol, destIP, destPort string) error
- func AddMasqueradeRule() error
- func AddRelEstRule(chain string) error
- func DelDNATRule(protocol, sourceIP, sourcePort, destIP, destPort string) error
- func DelForwardIntRule(inInt, outInt string) error
- func DelForwardRule(protocol, destIP, destPort string) error
- func DelMasqueradeRule() error
- func DelRelEstRule(chain string) error
- func ForwardingEnabled() (bool, error)
- func GetNetInterfaceByName(name string) (*net.Interface, error)
- func GetNetInterfaces() ([]net.Interface, error)
- func GetUsedAddresses() ([]string, error)
- type NetInterface
- func (n *NetInterface) AddRouteRule(src, dst, gw string) error
- func (n *NetInterface) DelRoute(route string) error
- func (n *NetInterface) Delete() error
- func (n *NetInterface) Down() error
- func (n *NetInterface) SetAddress(address string) error
- func (n *NetInterface) SetMTU(mtu int) error
- func (n *NetInterface) Up() error
- type TunTapMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddDNATRule ¶
AddDNATRule adds a DNAT rule to iptables PRERROUTING chain
func AddForwardIntRule ¶
AddForwardIntRule adds a FORWARD between interfaces rule to iptables
func AddForwardRule ¶
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 ¶
AddRelEstRule adds a RELATED,ESTABLISHED rule to specified chain of iptables
func DelDNATRule ¶
DelDNATRule deletes a DNAT rule to iptables PRERROUTING chain if it exists
func DelForwardIntRule ¶
DelForwardIntRule deletes a FORWARD between interfaces rule if it exists
func DelForwardRule ¶
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 ¶
DelRelEstRule deletes a RELATED,ESTABLISHED rule from the specified chain if it exists
func ForwardingEnabled ¶
ForwardingEnabled checks if IP forwarding is enabled
func GetNetInterfaceByName ¶
GetNetInterfaceByName gets the network interface by name
func GetNetInterfaces ¶
GetNetInterfaces gets the list of network interfaces
func GetUsedAddresses ¶
Types ¶
type NetInterface ¶
// 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 )