Documentation
¶
Overview ¶
Package netctl pkg/vpn/netctl/netctl_linux.go c4-app-vpn
netctl is a Go-native (netlink + /proc) replacement for the `ip` and `sysctl` shell-outs the VPN router/client used to make via osutil.RunElevated. Talking netlink directly is what `ip` does under the hood — identical kernel behavior — but with no iproute2 dependency, no PATH assumptions, and no per-command pkexec/sudo. That removes the "pkexec flood" on non-root hosts and, crucially, lets skywire's router run on a userland-less appliance (gokrazy) that has no `ip` binary at all. The process must hold CAP_NET_ADMIN (i.e. run privileged), which it already does wherever it performs network setup.
Firewall rules (iptables) are handled separately; see the netctl nftables backend (Phase 0b).
Index ¶
- func AddRuleIif(ifName string, table int) error
- func AddrAdd(ifName, cidr string) error
- func AddrDel(ifName, cidr string) error
- func DelRuleIif(ifName string, table int) error
- func FlushAddrs(ifName string) error
- func FlushTable(table int) error
- func GetIPv4Forwarding() (string, error)
- func GetIPv6Forwarding() (string, error)
- func LinkUp(ifName string) error
- func ReplaceDefaultRouteDev(ifName string, table int) error
- func RouteAddViaGateway(dst, gateway string) error
- func RouteDelViaGateway(dst, gateway string) error
- func RouteReplaceDev(dst, ifName string) error
- func RouteReplaceViaGateway(dst, gateway string) error
- func SetIPv4Forwarding(val string) error
- func SetIPv6Forwarding(val string) error
- func SetMTU(ifName string, mtu int) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddRuleIif ¶
AddRuleIif adds an ip rule matching packets forwarded in from ifName to look up the given table (≡ `ip rule add iif <if> lookup <t>`). It first deletes any identical rule so a restart doesn't stack duplicates.
func DelRuleIif ¶
DelRuleIif removes the `iif <if> lookup <t>` rule (≡ `ip rule del ...`).
func FlushAddrs ¶
FlushAddrs removes every IPv4 address from ifName (≡ `ip addr flush dev`).
func FlushTable ¶
FlushTable removes every route from a routing table (≡ `ip route flush table <t>`).
func GetIPv4Forwarding ¶
GetIPv4Forwarding reads net.ipv4.ip_forward (≡ `sysctl net.ipv4.ip_forward`).
func GetIPv6Forwarding ¶
GetIPv6Forwarding reads net.ipv6.conf.all.forwarding.
func ReplaceDefaultRouteDev ¶
ReplaceDefaultRouteDev installs a default route out ifName (no gateway — a point-to-point tun) in the given routing table (≡ `ip route replace default dev <if> table <t>`).
func RouteAddViaGateway ¶
RouteAddViaGateway adds a route to dst through gateway, failing if it already exists (≡ `ip route add <dst> via <gw>` — distinct from replace, which the callers rely on to detect a pre-existing route).
func RouteDelViaGateway ¶
RouteDelViaGateway removes a route to dst through gateway (≡ `ip route del <dst> via <gw>`).
func RouteReplaceDev ¶ added in v1.3.100
RouteReplaceDev installs a route to dst out ifName with no gateway, as for a point to point tun (≡ `ip route replace <dst> dev <if>`).
func RouteReplaceViaGateway ¶
RouteReplaceViaGateway installs/updates a route to dst through gateway (≡ `ip route replace <dst> via <gw>` — also covers `add`/`change`, which the kernel treats as replace-or-create for our purposes).
func SetIPv4Forwarding ¶
SetIPv4Forwarding writes net.ipv4.ip_forward (≡ `sysctl -w ...`).
func SetIPv6Forwarding ¶
SetIPv6Forwarding writes net.ipv6.conf.all.forwarding.
Types ¶
This section is empty.