Documentation
¶
Overview ¶
Package contains internal logic and processing of utilities before launch.
Package describes the operation of the server's internal utilities.
Index ¶
- Constants
- func FormatCmdAwgAddPeer(iface, pk, aips, kp, epoint string) string
- func FormatCmdAwgDeletePeer(iface, pk string) string
- func FormatCmdAwgShow(iface string) string
- func FormatCmdAwgUpdatePort(iface, port string) string
- func FormatCmdAwgUpdatePrivateKey(iface, pk string) string
- func FormatCmdIpAddrDev(iface, ip string, flag IpFlagString) string
- func FormatCmdIpLinkDelete(iface string) string
- func FormatCmdIpLinkSet(iface string, flag IpFlagString) string
- func FormatCmdIpShowJSON(iface string) string
- func FormatCmdIptablesFirewall(flag IpFlagString, osIface, wgIface string) string
- func FormatCmdIptablesFirewallPort(flag IpFlagString, dport string) string
- func FormatCmdIptablesNat(flag IpFlagString, osIface, subnet string) string
- func GetNetInterfaceNameLinux() string
- func ShellCommand(cmd string, shell bool) error
- func ShellCommandOutput(cmd string) (*bytes.Buffer, error)
- type IpFlagString
Constants ¶
const ( // Add Rules. SysctlIpv4Up string = "sysctl -w net.ipv4.ip_forward=1" SysctlIpv6Up string = "sysctl -w net.ipv6.conf.all.forwarding=1" // Delete Rules. SysctlIpv4Down string = "sysctl -w net.ipv4.ip_forward=0" SysctlIpv6Down string = "sysctl -w net.ipv6.conf.all.forwarding=0" // Check Rules. SysctlIpv4Check string = "sysctl net.ipv4.ip_forward" SysctlIpv6Check string = "sysctl net.ipv6.conf.all.forwarding" // Execute Rules. SysctlRules string = "sysctl -p" )
const ( // Command: ip. IpJSON string = "ip -j addr" IpBriefJSON string = "ip -j -br addr" // Command: iptables. IptablesFirewall string = "iptables -L -v -n" IptablesNat string = "iptables -t nat -L -v" )
Variables ¶
This section is empty.
Functions ¶
func FormatCmdAwgAddPeer ¶
Function creates the 'awg set <interface> peer <publicKey> allowed-ips <allowedIPs> [persistent-keepalive <keepalive>] [endpoint <endpoint>]' command string. This command is used to add a new peer to a specified WireGuard interface, optionally including persistent keepalive and endpoint settings.
func FormatCmdAwgDeletePeer ¶
func FormatCmdAwgShow ¶
Function creates the 'awg show <interface>' command string. This command is used to display the configuration and status of a specific WireGuard interface.
func FormatCmdAwgUpdatePort ¶
Function creates the 'awg set <interface> listen-port <port>' command string. This command is used to update the listening port of a specific WireGuard interface.
func FormatCmdAwgUpdatePrivateKey ¶
Function creates the 'awg set <interface> private-key <(echo '<privateKey>')' command string. This command is used to set the private key for a specific WireGuard interface using a secure shell redirection.
func FormatCmdIpAddrDev ¶
func FormatCmdIpAddrDev(iface, ip string, flag IpFlagString) string
Function generates the `ip` command to add or remove an IP address.
func FormatCmdIpLinkDelete ¶
Function generate the `ip` command when deleting.
func FormatCmdIpLinkSet ¶
func FormatCmdIpLinkSet(iface string, flag IpFlagString) string
Function generates the `ip` command to control the status of the network interface.
func FormatCmdIpShowJSON ¶
Function constructs the 'ip link show' command for a given interface.
func FormatCmdIptablesFirewall ¶
func FormatCmdIptablesFirewall(flag IpFlagString, osIface, wgIface string) string
Function generates the `iptables` command to manage the firewall rules.
func FormatCmdIptablesFirewallPort ¶
func FormatCmdIptablesFirewallPort(flag IpFlagString, dport string) string
Function generates an iptables command to manage (add/remove) an INGRESS rule for UDP traffic on the specified destination port.
func FormatCmdIptablesNat ¶
func FormatCmdIptablesNat(flag IpFlagString, osIface, subnet string) string
Function generates the `iptables` command to manage the NAT rules.
func GetNetInterfaceNameLinux ¶
func GetNetInterfaceNameLinux() string
Function to get active Linux network interface.
func ShellCommand ¶
Function of executing commands in the system shell.
Types ¶
type IpFlagString ¶
type IpFlagString string
const ( IpUp IpFlagString = "up" IpDown IpFlagString = "down" IpAdd IpFlagString = "add" IpDel IpFlagString = "del" IpTablesAdd IpFlagString = "A" IpTablesDel IpFlagString = "D" )