cli/src/utils at main · forestvpn/cli

import "github.com/forestvpn/cli/utils"

Index

func ExcludeDisallowedIps

func ExcludeDisallowedIps(allowed []string, disallowed []string) ([]string, error)

ExcludeDisallowedIps is a function that expects two slices of a network values, e.g. [127.0.0.0/8,], where disallowed is a slice of networks to be excluded from the allowed slice. Returns a new slice of networks formed out of the allowed slice without networks of disallowed slice.

func GetActiveSshClientIps

func GetActiveSshClientIps() ([]string, error)

GetActiveSshClientIps is a function that calls the "who" shell command to get active ssh sessions. Then it extracts all the IP addresses from the command output and converts them into networks using ip2Net for a compability with Wiregaurd configuration format. Returns a slice of networks representing the public networks of active ssh clients.

func GetExistingRoutes

func GetExistingRoutes() ([]string, error)

GetExistingRoutes is a function that calls a netstat shell command to get system routing table. Then it extracts all the IP addresses from the shell command's output. Each of an IP addresses is converted into related network using ip2Net in order to be compitable with Wireguard configuration format. Returns a slice of a networks (as a strings) representing system routing table.

func GetHostIP

func GetHostIP() (net.IP, error)

GetHostIP returns the host's public IP address.

See https://github.com/glendc/go-external-ip for more information.

Generated by gomarkdoc