Skip to content

Commit

Permalink
Merge branch 'master' into Design
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentbitter authored Dec 11, 2019
2 parents e49abd1 + b13b7db commit 35d917a
Show file tree
Hide file tree
Showing 16 changed files with 349 additions and 133 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ docker run \
place1/wg-access-server
```

To use a custom [configuration](#configuration) file, please add a `CONFIG` environment variable and make sure the configuration file is mounted:
```
...
-e CONFIG=/config/config.yaml
-v ./config.yaml:/config/config.yaml
...
```

## Configuration

You can configure the server using a config file.
Expand Down
7 changes: 6 additions & 1 deletion internal/services/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package services

import (
"fmt"
"os"
"net"
"sync"
"time"
Expand Down Expand Up @@ -67,7 +68,11 @@ func (d *DeviceManager) AddDevice(user string, name string, publicKey string) (*
}

func (d *DeviceManager) ListDevices(user string) ([]*storage.Device, error) {
return d.storage.List(user + "/")
prefix := ""
if (user != "") {
prefix = user + string(os.PathSeparator)
}
return d.storage.List(prefix)
}

func (d *DeviceManager) DeleteDevice(user string, name string) error {
Expand Down
4 changes: 4 additions & 0 deletions internal/storage/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func (s *DiskStorage) List(prefix string) ([]*Device, error) {
return nil
}
p := strings.TrimPrefix(path, s.directory)
p = strings.TrimPrefix(p, string(os.PathSeparator))
if strings.HasPrefix(p, prefix) {
files = append(files, path)
}
Expand All @@ -58,6 +59,8 @@ func (s *DiskStorage) List(prefix string) ([]*Device, error) {
if err != nil {
return nil, errors.Wrap(err, "failed to list storage directory")
}
logrus.Debugf("Found files: %+v", files)

devices := []*Device{}
for _, file := range files {
bytes, err := ioutil.ReadFile(file)
Expand All @@ -73,6 +76,7 @@ func (s *DiskStorage) List(prefix string) ([]*Device, error) {
}
devices = append(devices, device)
}
logrus.Debugf("Found devices: %+v", devices)
return devices, nil
}

Expand Down
7 changes: 7 additions & 0 deletions website/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
semi: true,
trailingComma: "all",
singleQuote: true,
printWidth: 120,
tabWidth: 2,
};
Loading

0 comments on commit 35d917a

Please sign in to comment.