Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Place1 committed Feb 20, 2020
1 parent 70bc176 commit e8d88f7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
config.yaml
data/
5 changes: 5 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ func Read() *AppConfig {

if config.Storage.Directory == "" {
logrus.Warn("storage directory not configured - using in-memory storage backend! wireguard devices will be lost when the process exits!")
} else {
config.Storage.Directory, err = filepath.Abs(config.Storage.Directory)
if err != nil {
logrus.Fatal(errors.Wrap(err, "failed to get absolute path to storage directory"))
}
}

return &config
Expand Down
3 changes: 2 additions & 1 deletion internal/devices/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"net"
"os"
"path/filepath"
"sync"
"time"

Expand Down Expand Up @@ -89,7 +90,7 @@ func (d *DeviceManager) DeleteDevice(user string, name string) error {
}

func key(user string, device string) string {
return fmt.Sprintf("%s/%s", user, device)
return filepath.Join(user, device)
}

var nextIPLock = sync.Mutex{}
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func main() {
// Storage
var storageDriver storage.Storage
if conf.Storage.Directory != "" {
logrus.Infof("storing data in %s", conf.Storage.Directory)
storageDriver = storage.NewDiskStorage(conf.Storage.Directory)
} else {
storageDriver = storage.NewMemoryStorage()
Expand Down Expand Up @@ -128,7 +129,7 @@ func main() {
handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
base.ServeHTTP(w, r.WithContext(authsession.SetIdentityCtx(r.Context(), &authsession.AuthSession{
Identity: &authsession.Identity{
Subject: "default",
Subject: "",
},
})))
})
Expand Down

0 comments on commit e8d88f7

Please sign in to comment.