From 45e980346b56edf825134d9bce2e221c30f8f4ab Mon Sep 17 00:00:00 2001 From: Roman Kulayev Date: Fri, 25 Jun 2021 11:21:59 +0300 Subject: [PATCH 1/3] Possibility to set client config filename to download --- README.md | 1 + cmd/subspace/config.go | 6 +----- cmd/subspace/handlers.go | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d59616d0..ebc2a056 100644 --- a/README.md +++ b/README.md @@ -127,6 +127,7 @@ $ subspace --http-host subspace.example.com | `SUBSPACE_THEME` | `green` | The theme to use, please refer to [semantic-ui](https://semantic-ui.com/usage/theming.html) for accepted colors | | `SUBSPACE_BACKLINK` | `/` | The page to set the home button to | | `SUBSPACE_DISABLE_DNS` | `false` | Whether to disable DNS so the client uses their own configured DNS server(s). Consider disabling DNS server, if supporting international VPN clients | +| `SUBSPACE_CONFIG_FILENAME` | `wg0.conf` | Client config filename to download | ### Run as a Docker container diff --git a/cmd/subspace/config.go b/cmd/subspace/config.go index 73b2230c..9c69eb2f 100644 --- a/cmd/subspace/config.go +++ b/cmd/subspace/config.go @@ -55,10 +55,6 @@ func (p Profile) WireGuardConfigPath() string { return fmt.Sprintf("%s/wireguard/clients/%s.conf", datadir, p.ID) } -func (p Profile) WireGuardConfigName() string { - return "wg0.conf" -} - type Info struct { Email string `json:"email"` Password []byte `json:"password"` @@ -102,7 +98,7 @@ func NewConfig(filename string) (*Config, error) { // Create new config with defaults if os.IsNotExist(err) { c.Info = &Info{ - Email: "null", + Email: "null", HashKey: RandomString(32), BlockKey: RandomString(32), } diff --git a/cmd/subspace/handlers.go b/cmd/subspace/handlers.go index 229417be..a0999488 100644 --- a/cmd/subspace/handlers.go +++ b/cmd/subspace/handlers.go @@ -109,7 +109,7 @@ func wireguardConfigHandler(w *Web) { return } - w.w.Header().Set("Content-Disposition", "attachment; filename="+profile.WireGuardConfigName()) + w.w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", getEnv("SUBSPACE_CONFIG_FILENAME", "wg0.conf"))) w.w.Header().Set("Content-Type", "application/x-wireguard-profile") w.w.Header().Set("Content-Length", fmt.Sprintf("%d", len(b))) if _, err := w.w.Write(b); err != nil { From 4d39528a28eecf1703872c5f0203e312f0bd7447 Mon Sep 17 00:00:00 2001 From: Roman Kulayev Date: Fri, 25 Jun 2021 12:53:10 +0300 Subject: [PATCH 2/3] Update connection help page for linux devices --- web/templates/profile/connect.html | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/web/templates/profile/connect.html b/web/templates/profile/connect.html index b7cd4a2f..c3fd203a 100644 --- a/web/templates/profile/connect.html +++ b/web/templates/profile/connect.html @@ -199,7 +199,16 @@
- Connect to your VPN server + Import config to the Network Manager and connect to your VPN server +
+
+ +
+ +
+
+ To connect from the terminal copy config file to the /etc/wireguard directory and connect using wg-quick up [CONFIG_FILE] Where CONFIG_FILE is a configuration file, whose filename is the interface name + followed by .conf
From 6e59fd7021ddb86f0fca6fb62759118ce211ac79 Mon Sep 17 00:00:00 2001 From: Roman Kulayev Date: Fri, 25 Jun 2021 13:46:24 +0300 Subject: [PATCH 3/3] Fix sonarcloud issue --- cmd/subspace/handlers.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/subspace/handlers.go b/cmd/subspace/handlers.go index a0999488..1197199d 100644 --- a/cmd/subspace/handlers.go +++ b/cmd/subspace/handlers.go @@ -109,7 +109,8 @@ func wireguardConfigHandler(w *Web) { return } - w.w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", getEnv("SUBSPACE_CONFIG_FILENAME", "wg0.conf"))) + configFilename := getEnv("SUBSPACE_CONFIG_FILENAME", "wg0.conf") + w.w.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=%s", configFilename)) w.w.Header().Set("Content-Type", "application/x-wireguard-profile") w.w.Header().Set("Content-Length", fmt.Sprintf("%d", len(b))) if _, err := w.w.Write(b); err != nil {