From 0606fdb9fb3e08b4f10ab1ccbcdb59e5a283ba76 Mon Sep 17 00:00:00 2001 From: Dimitrios Karagiannis Date: Mon, 15 Feb 2021 17:04:44 +0000 Subject: [PATCH] Use wireguard devices on linux by default Signed-off-by: Dimitrios Karagiannis --- main.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 4a25d20..7851383 100644 --- a/main.go +++ b/main.go @@ -4,6 +4,7 @@ import ( "flag" "os" "os/signal" + "runtime" "strings" "syscall" "time" @@ -22,13 +23,21 @@ var ( // looking wiresteward initials hex on ascii table (w = 0x77 and s = 0x73) flagAgentAddress = flag.String("agent-listen-address", "localhost:7773", "Address where the agent http server runs.\nThe URL http:///oauth2/callback must be a valid callback url for the oauth2 application.") flagConfig = flag.String("config", "/etc/wiresteward/config.json", "Config file") - flagDeviceType = flag.String("device-type", "tun", "Type of the network device to use for the agent, 'tun' or 'wireguard'.\nThe tun device relies on the wireguard-go userspace implementation that is compatible with all platforms.\nA wireguard device relies on wireguard-enabled linux kernels (5.6 or newer).") + flagDeviceType *string flagLogLevel = flag.String("log-level", "info", "Log Level (debug|info|error)") flagMetricsAddr = flag.String("metrics-address", ":8081", "Metrics server address, meaningful when combined with -server flag") flagServer = flag.Bool("server", false, "Run application in \"server\" mode") flagVersion = flag.Bool("version", false, "Prints out application version") ) +func init() { + defaultDeviceType := "tun" + if runtime.GOOS == "linux" { + defaultDeviceType = "wireguard" + } + flagDeviceType = flag.String("device-type", defaultDeviceType, "Type of the network device to use for the agent, 'tun' or 'wireguard'.\nThe tun device relies on the wireguard-go userspace implementation that is compatible with all platforms.\nA wireguard device relies on wireguard-enabled linux kernels (5.6 or newer).") +} + func main() { flag.Parse()