mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-04-19 19:59:13 +03:00

Evidently, wireguard's (use of) fwmark is not well understood. In short, it determines which routing table to use for a tunnel's packets. Adding a fwmark to a roadwarrior client config won't do anything to the actual packets sent to a peer: Packets do not get marked. A QRCode with `FwMark = ...` in it is invalid. FwMark is now excluded from client configs (but is written to the server config /etc/wireguard/wgX.conf). Potential breaking change of `WGUI_FORWARD_MARK` to `WGUI_FIREWALL_MARK` But this has the effect of making users eventually notice that it probably does not do what they want/think. See: https://ro-che.info/articles/2021-02-27-linux-routing https://casavant.org/2020/10/10/wireguard-fwmark.html https://www.blinkenlights.ch/ccms/posts/source-based-routing/
62 lines
2.3 KiB
Go
62 lines
2.3 KiB
Go
package util
|
|
|
|
import "strings"
|
|
|
|
// Runtime config
|
|
var (
|
|
DisableLogin bool
|
|
BindAddress string
|
|
SmtpHostname string
|
|
SmtpPort int
|
|
SmtpUsername string
|
|
SmtpPassword string
|
|
SmtpNoTLSCheck bool
|
|
SmtpEncryption string
|
|
SmtpAuthType string
|
|
SendgridApiKey string
|
|
EmailFrom string
|
|
EmailFromName string
|
|
SessionSecret []byte
|
|
WgConfTemplate string
|
|
BasePath string
|
|
)
|
|
|
|
const (
|
|
DefaultUsername = "admin"
|
|
DefaultPassword = "admin"
|
|
DefaultServerAddress = "10.252.1.0/24"
|
|
DefaultServerPort = 51820
|
|
DefaultDNS = "1.1.1.1"
|
|
DefaultMTU = 1450
|
|
DefaultPersistentKeepalive = 15
|
|
DefaultFirewallMark = "0xca6c" // i.e. 51820
|
|
DefaultConfigFilePath = "/etc/wireguard/wg0.conf"
|
|
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"
|
|
ConfigFilePathEnvVar = "WGUI_CONFIG_FILE_PATH"
|
|
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"
|
|
)
|
|
|
|
func ParseBasePath(basePath string) string {
|
|
if !strings.HasPrefix(basePath, "/") {
|
|
basePath = "/" + basePath
|
|
}
|
|
if strings.HasSuffix(basePath, "/") {
|
|
basePath = strings.TrimSuffix(basePath, "/")
|
|
}
|
|
return basePath
|
|
}
|