Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to set client config filename to download #198

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 1 addition & 5 deletions cmd/subspace/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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),
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/subspace/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 10 additions & 1 deletion web/templates/profile/connect.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,16 @@
<i class="right triangle icon"></i>
<div class="content">
<div class="description">
Connect to your VPN server
Import config to the Network Manager and connect to your VPN server
</div>
</div>
</div>
<div class="item">
<i class="right triangle icon"></i>
<div class="content">
<div class="description">
To connect from the terminal copy config file to the <code>/etc/wireguard</code> directory and connect using <code>wg-quick up [CONFIG_FILE]</code> Where <code>CONFIG_FILE</code> is a configuration file, whose filename is the interface name
followed by <code>.conf</code>
</div>
</div>
</div>
Expand Down