Documentation ¶
Index ¶
- Constants
- Variables
- func CanConnect(host string, port int) bool
- func GetNextAvailabeInterface(prefix string) (string, error)
- func IncIP(ip net.IP)
- func IsPrivateAddr(addr netip.Addr) bool
- func ResolveNames(dnsNames []string, flatten bool) ([]string, [][]string, error)
- type DNSManager
- type FilterRouter
- type NetworkContext
- type PortGroup
- type Protocol
- type RoutableInterface
- type Route
- type RouteManager
- type SecurityGroup
Constants ¶
View Source
const ( WORLD4 = "0.0.0.0/0" WORLD6 = "::/0" LAN4 = "4" LAN6 = "6" )
Variables ¶
View Source
var Network = struct { // default interface and gateway for // all WAN traffic (i.e. 0.0.0.0/0 & ::/0) DefaultIPv4Route *Route DefaultIPv6Route *Route // additional default routes scoped // to specific interfaces ScopedDefaults []*Route // all static routes StaticRoutes []*Route }{}
global network properties
View Source
var ( // negative offset will give chains created for // this router a high priority compared chains // in the kernal with default priorities NftChainPriorityOffset int32 = 0 )
Functions ¶
func GetNextAvailabeInterface ¶
given a device name prefix return the next available one
func IsPrivateAddr ¶
returns whether the given ipv4 or ipv6 address is a private address
func ResolveNames ¶
resolves the given list of domain names and returns their corresponding as two lists. The first list will either be a flattened list of all resolved ips as stringsor just the first resolved ip giving a 1:1 mapping to the given names. The second list is a list of ips resolved for each name.
Types ¶
type DNSManager ¶
type FilterRouter ¶
type FilterRouter interface { AddIPsToDenyList(ips []netip.Addr) error DeleteIPsFromDenyList(ips []netip.Addr) error AddIPsToAllowList(ips []netip.Addr) error DeleteIPsFromAllowList(ips []netip.Addr) error SetSecurityGroups(sgs []SecurityGroup, iifName string) error DeleteSecurityGroups(sgs []SecurityGroup, iifName string) error ForwardPort(dstPort, forwardPort int, forwardIP netip.Addr, proto Protocol) (string, error) DeleteForwardPort(dstPort, forwardPort int, forwardIP netip.Addr, proto Protocol) error ForwardPortOnIP(dstPort, forwardPort int, dstIP, forwardIP netip.Addr, proto Protocol) (string, error) DeleteForwardPortOnIP(dstPort, forwardPort int, dstIP, forwardIP netip.Addr, proto Protocol) error ForwardTraffic(srcItfName, dstItfName string, srcNetwork, dstNetwork netip.Prefix, withNat bool) (string, error) DeleteForwardTraffic(srcItfName, dstItfName string, srcNetwork, dstNetwork netip.Prefix) error DeleteFilter(key string) error Clear() }
type NetworkContext ¶
type NetworkContext interface { DefaultDeviceName() string DefaultInterface() string DefaultGateway() string DefaultIP() string DisableIPv6() error NewDNSManager() (DNSManager, error) NewRouteManager() (RouteManager, error) Clear() }
func NewNetworkContext ¶
func NewNetworkContext() (NetworkContext, error)
type RoutableInterface ¶
type RoutableInterface interface { Name() string Address4() (string, string, error) Address6() (string, string, error) MakeDefaultRoute() error SetSecurityGroups(sgs []SecurityGroup) error DeleteSecurityGroups(sgs []SecurityGroup) error ForwardPortTo(proto Protocol, dstPort int, forwardPort int, forwardIP netip.Addr) (string, error) DeletePortForwardedTo(proto Protocol, dstPort int, forwardPort int, forwardIP netip.Addr) error FowardTrafficTo(dstItf RoutableInterface, srcNetwork, dstNetwork string, withNat bool) (string, error) DeleteTrafficForwardedTo(dstItf RoutableInterface, srcNetwork, dstNetwork string) error FowardTrafficFrom(srcItf RoutableInterface, srcNetwork, dstNetwork string, withNat bool) (string, error) DeleteTrafficForwardedFrom(srcItf RoutableInterface, srcNetwork, destNetwork string) error }
type Route ¶
type RouteManager ¶
type RouteManager interface { GetDefaultInterface() (RoutableInterface, error) GetRoutableInterface(ifaceName string) (RoutableInterface, error) NewRoutableInterface(ifaceName, tunAddress string) (RoutableInterface, error) NewFilterRouter(denyAll bool) (FilterRouter, error) AddExternalRouteToIPs(ips []string) error AddDefaultRoute(gateway string) error Clear() }
type SecurityGroup ¶
type SecurityGroup struct { Deny bool // default to allow SrcNetwork, DstNetwork netip.Prefix Oifname string Ports []PortGroup }
func (SecurityGroup) CreateSecurityGroupKeys ¶
func (sg SecurityGroup) CreateSecurityGroupKeys(iifName string) (string, []string, error)
Click to show internal directories.
Click to hide internal directories.