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..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", "attachment; filename="+profile.WireGuardConfigName()) + 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 { 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 @@
/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