util

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 15, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DisableLogin   bool
	BindAddress    string
	SendgridApiKey string
	EmailFrom      string
	EmailFromName  string
	EmailSubject   string
	EmailContent   string
	SessionSecret  []byte
)

Runtime config

Functions

func BuildClientConfig

func BuildClientConfig(client model.Client, server model.Server, setting model.GlobalSetting) string

BuildClientConfig to create wireguard client config string

func DBConn

func DBConn() (*scribble.Driver, error)

DBConn to initialize the database connection

func GetAllocatedIPs

func GetAllocatedIPs(ignoreClientID string) ([]string, error)

GetAllocatedIPs to get all ip addresses allocated to clients and server

func GetAvailableIP

func GetAvailableIP(cidr string, allocatedList []string) (string, error)

GetAvailableIP get the ip address that can be allocated from an CIDR

func GetBroadcastIP

func GetBroadcastIP(n *net.IPNet) net.IP

GetBroadcastIP func to get the broadcast ip address of a network

func GetClientByID

func GetClientByID(clientID string, hasQRCode bool) (model.ClientData, error)

GetClientByID func to query a client from the database

func GetClients

func GetClients(hasQRCode bool) ([]model.ClientData, error)

GetClients to get all clients from the database

func GetGlobalSettings

func GetGlobalSettings() (model.GlobalSetting, error)

GetGlobalSettings func to query global settings from the database

func GetIPFromCIDR

func GetIPFromCIDR(cidr string) (string, error)

GetIPFromCIDR get ip from CIDR

func GetInterfaceIPs

func GetInterfaceIPs() ([]model.Interface, error)

GetInterfaceIPs to get local machine's interface ip addresses

func GetPublicIP

func GetPublicIP() (model.Interface, error)

GetPublicIP to get machine's public ip address

func GetServer

func GetServer() (model.Server, error)

GetServer func to query Server setting from the database

func GetUser

func GetUser() (model.User, error)

GetUser func to query user info from the database

func InitDB

func InitDB() error

InitDB to create the default database

func ValidateAllowedIPs

func ValidateAllowedIPs(cidrs []string) bool

ValidateAllowedIPs to validate allowed ip addresses in CIDR format

func ValidateCIDR

func ValidateCIDR(cidr string) bool

ValidateCIDR to validate a network CIDR

func ValidateCIDRList

func ValidateCIDRList(cidrs []string) bool

ValidateCIDRList to validate a list of network CIDR

func ValidateIPAddress

func ValidateIPAddress(ip string) bool

ValidateIPAddress to validate the IPv4 and IPv6 address

func ValidateIPAddressList

func ValidateIPAddressList(ips []string) bool

ValidateIPAddressList to validate a list of IPv4 and IPv6 addresses

func ValidateIPAllocation

func ValidateIPAllocation(serverAddresses []string, ipAllocatedList []string, ipAllocationList []string) (bool, error)

ValidateIPAllocation to validate the list of client's ip allocation They must have a correct format and available in serverAddresses space

func ValidateServerAddresses

func ValidateServerAddresses(cidrs []string) bool

ValidateServerAddresses to validate allowed ip addresses in CIDR format

func WriteWireGuardServerConfig

func WriteWireGuardServerConfig(tmplBox *rice.Box, serverConfig model.Server, clientDataList []model.ClientData, globalSettings model.GlobalSetting) error

WriteWireGuardServerConfig to write Wireguard server config. e.g. wg0.conf

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL