Documentation ¶
Index ¶
- Constants
- Variables
- func BuildClientConfig(client model.Client, server model.Server, setting model.GlobalSetting) string
- func ClientDefaultsFromEnv() model.ClientDefaults
- func GetAllocatedIPs(ignoreClientID string) ([]string, error)
- func GetAvailableIP(cidr string, allocatedList []string) (string, error)
- func GetBroadcastIP(n *net.IPNet) net.IP
- func GetCurrentHash(db store.IStore) (string, string)
- func GetIPFromCIDR(cidr string) (string, error)
- func GetInterfaceIPs() ([]model.Interface, error)
- func GetPublicIP() (model.Interface, error)
- func HashPassword(plaintext string) (string, error)
- func HashesChanged(db store.IStore) bool
- func LookupEnvOrBool(key string, defaultVal bool) bool
- func LookupEnvOrInt(key string, defaultVal int) int
- func LookupEnvOrString(key string, defaultVal string) string
- func LookupEnvOrStrings(key string, defaultVal []string) []string
- func ParseBasePath(basePath string) string
- func ParseLogLevel(lvl string) (log.Lvl, error)
- func StringFromEmbedFile(embed fs.FS, filename string) (string, error)
- func UpdateHashes(db store.IStore) error
- func ValidateAllowedIPs(cidrs []string) bool
- func ValidateCIDR(cidr string) bool
- func ValidateCIDRList(cidrs []string, allowEmpty bool) bool
- func ValidateExtraAllowedIPs(cidrs []string) bool
- func ValidateIPAddress(ip string) bool
- func ValidateIPAddressList(ips []string) bool
- func ValidateIPAllocation(serverAddresses []string, ipAllocatedList []string, ipAllocationList []string) (bool, error)
- func ValidateServerAddresses(cidrs []string) bool
- func VerifyHash(base64Hash string, plaintext string) (bool, error)
- func WriteWireGuardServerConfig(tmplDir fs.FS, serverConfig model.Server, clientDataList []model.ClientData, ...) error
Constants ¶
const ( DefaultUsername = "admin" DefaultPassword = "admin" DefaultIsAdmin = true DefaultServerAddress = "10.252.1.0/24" DefaultServerPort = 51820 DefaultDNS = "1.1.1.1" DefaultMTU = 1450 DefaultPersistentKeepalive = 15 DefaultFirewallMark = "0xca6c" // i.e. 51820 DefaultTable = "auto" DefaultConfigFilePath = "/etc/wireguard/wg0.conf" DefaultRemoteAPI = "http://127.0.0.1:1234" DefaultTelegramChat = -1001866387689 EnvTelegramChat = "WGUI_TELEGRAM_CHAT" EnvTelegramToken = "WGUI_TELEGRAM_TOKEN" DefaultTelegramToken = "bot" UsernameEnvVar = "WGUI_USERNAME" PasswordEnvVar = "WGUI_PASSWORD" PasswordHashEnvVar = "WGUI_PASSWORD_HASH" FaviconFilePathEnvVar = "WGUI_FAVICON_FILE_PATH" EndpointAddressEnvVar = "WGUI_ENDPOINT_ADDRESS" DNSEnvVar = "WGUI_DNS" MTUEnvVar = "WGUI_MTU" PersistentKeepaliveEnvVar = "WGUI_PERSISTENT_KEEPALIVE" FirewallMarkEnvVar = "WGUI_FIREWALL_MARK" TableEnvVar = "WGUI_TABLE" ConfigFilePathEnvVar = "WGUI_CONFIG_FILE_PATH" ConfigRemoteAPIEnvVar = "WGUI_CONFIG_RemoteAPI" LogLevel = "WGUI_LOG_LEVEL" ServerAddressesEnvVar = "WGUI_SERVER_INTERFACE_ADDRESSES" ServerListenPortEnvVar = "WGUI_SERVER_LISTEN_PORT" ServerPostUpScriptEnvVar = "WGUI_SERVER_POST_UP_SCRIPT" ServerPostDownScriptEnvVar = "WGUI_SERVER_POST_DOWN_SCRIPT" DefaultClientAllowedIpsEnvVar = "WGUI_DEFAULT_CLIENT_ALLOWED_IPS" DefaultClientExtraAllowedIpsEnvVar = "WGUI_DEFAULT_CLIENT_EXTRA_ALLOWED_IPS" DefaultClientUseServerDNSEnvVar = "WGUI_DEFAULT_CLIENT_USE_SERVER_DNS" DefaultClientEnableAfterCreationEnvVar = "WGUI_DEFAULT_CLIENT_ENABLE_AFTER_CREATION" CronEnvVar = "WGUI_SCHEDULER_CRON" )
Variables ¶
var ( DisableLogin bool BindAddress string SmtpHostname string SmtpPort int SmtpUsername string SmtpPassword string SmtpNoTLSCheck bool SmtpEncryption string SmtpAuthType string SendgridApiKey string MailgunApiKey string MailgunDomain string MailgunAPIBase string EmailFrom string EmailFromName string SessionSecret []byte WgConfTemplate string BasePath string )
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 ClientDefaultsFromEnv ¶
func ClientDefaultsFromEnv() model.ClientDefaults
ClientDefaultsFromEnv to read the default values for creating a new client from the environment or use sane defaults
func GetAllocatedIPs ¶
GetAllocatedIPs to get all ip addresses allocated to clients and server
func GetAvailableIP ¶
GetAvailableIP get the ip address that can be allocated from an CIDR
func GetBroadcastIP ¶
GetBroadcastIP func to get the broadcast ip address of a network
func GetCurrentHash ¶
GetCurrentHash returns current hashes
func GetInterfaceIPs ¶
GetInterfaceIPs to get local machine's interface ip addresses
func GetPublicIP ¶
GetPublicIP to get machine's public ip address
func HashPassword ¶
func HashesChanged ¶
func LookupEnvOrBool ¶
func LookupEnvOrInt ¶
func LookupEnvOrString ¶
func LookupEnvOrStrings ¶
func ParseBasePath ¶
func UpdateHashes ¶
func ValidateAllowedIPs ¶
ValidateAllowedIPs to validate allowed ip addresses in CIDR format
func ValidateCIDRList ¶
ValidateCIDRList to validate a list of network CIDR
func ValidateExtraAllowedIPs ¶
ValidateExtraAllowedIPs to validate extra Allowed ip addresses, allowing empty strings
func ValidateIPAddress ¶
ValidateIPAddress to validate the IPv4 and IPv6 address
func ValidateIPAddressList ¶
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 ¶
ValidateServerAddresses to validate allowed ip addresses in CIDR format
func WriteWireGuardServerConfig ¶
func WriteWireGuardServerConfig(tmplDir fs.FS, serverConfig model.Server, clientDataList []model.ClientData, usersList []model.User, globalSettings model.GlobalSetting) error
WriteWireGuardServerConfig to write Wireguard server config. e.g. wg0.conf
Types ¶
This section is empty.