mirror of
https://github.com/ngoduykhanh/wireguard-ui.git
synced 2025-04-18 19:49:30 +03:00
Add golangci-lint CI (#516)
This commit is contained in:
parent
769883f020
commit
b3c22aa81f
14 changed files with 75 additions and 37 deletions
2
.github/workflows/docker-build.yml
vendored
2
.github/workflows/docker-build.yml
vendored
|
@ -11,7 +11,7 @@ jobs:
|
||||||
build-image:
|
build-image:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
# set environment
|
# set environment
|
||||||
- name: Set BUILD_TIME env
|
- name: Set BUILD_TIME env
|
||||||
|
|
31
.github/workflows/lint.yml
vendored
Normal file
31
.github/workflows/lint.yml
vendored
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
name: Lint
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pull-requests: read
|
||||||
|
checks: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
name: Lint
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
timeout-minutes: 10
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: "1.21"
|
||||||
|
|
||||||
|
- name: golangci-lint
|
||||||
|
uses: golangci/golangci-lint-action@v3
|
||||||
|
with:
|
||||||
|
version: v1.54
|
8
.github/workflows/release.yml
vendored
8
.github/workflows/release.yml
vendored
|
@ -24,7 +24,7 @@ jobs:
|
||||||
- 7
|
- 7
|
||||||
steps:
|
steps:
|
||||||
# get the source code
|
# get the source code
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
# set environment
|
# set environment
|
||||||
- name: Set APP_VERSION env
|
- name: Set APP_VERSION env
|
||||||
|
@ -35,9 +35,9 @@ jobs:
|
||||||
uses: managedkaos/print-env@v1.0
|
uses: managedkaos/print-env@v1.0
|
||||||
|
|
||||||
# setup node
|
# setup node
|
||||||
- uses: actions/setup-node@v2
|
- uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '14'
|
node-version: '20'
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
|
|
||||||
# prepare assets
|
# prepare assets
|
||||||
|
@ -53,7 +53,7 @@ jobs:
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
goos: ${{ matrix.goos }}
|
goos: ${{ matrix.goos }}
|
||||||
goarch: ${{ matrix.goarch }}
|
goarch: ${{ matrix.goarch }}
|
||||||
goversion: "https://dl.google.com/go/go1.16.1.linux-amd64.tar.gz"
|
goversion: "https://dl.google.com/go/go1.21.5.linux-amd64.tar.gz"
|
||||||
pre_command: export CGO_ENABLED=0
|
pre_command: export CGO_ENABLED=0
|
||||||
binary_name: "wireguard-ui"
|
binary_name: "wireguard-ui"
|
||||||
build_flags: -v
|
build_flags: -v
|
||||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -14,7 +14,8 @@ wireguard-ui
|
||||||
|
|
||||||
# Dependency directories and files (remove the comment below to include it)
|
# Dependency directories and files (remove the comment below to include it)
|
||||||
vendor/
|
vendor/
|
||||||
assets/
|
assets/*
|
||||||
|
!assets/.gitkeep
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
# IDEs
|
# IDEs
|
||||||
|
|
26
.golangci.yml
Normal file
26
.golangci.yml
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
run:
|
||||||
|
timeout: 5m
|
||||||
|
skip-dirs:
|
||||||
|
- .github
|
||||||
|
- hack
|
||||||
|
- vendor
|
||||||
|
linters:
|
||||||
|
disable-all: true
|
||||||
|
enable:
|
||||||
|
- gofmt
|
||||||
|
- revive
|
||||||
|
- goimports
|
||||||
|
- govet
|
||||||
|
- unused
|
||||||
|
- whitespace
|
||||||
|
- misspell
|
||||||
|
fast: false
|
||||||
|
linters-settings:
|
||||||
|
gofmt:
|
||||||
|
simplify: false
|
||||||
|
revive:
|
||||||
|
rules:
|
||||||
|
- name: exported
|
||||||
|
disabled: true
|
||||||
|
issues:
|
||||||
|
exclude-use-default: false
|
0
assets/.gitkeep
Normal file
0
assets/.gitkeep
Normal file
|
@ -3,9 +3,10 @@ package emailer
|
||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"fmt"
|
"fmt"
|
||||||
mail "github.com/xhit/go-simple-mail/v2"
|
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
mail "github.com/xhit/go-simple-mail/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SmtpMail struct {
|
type SmtpMail struct {
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/labstack/echo/v4"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/labstack/echo/v4"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ContentTypeJson checks that the requests have the Content-Type header set to "application/json".
|
// ContentTypeJson checks that the requests have the Content-Type header set to "application/json".
|
||||||
|
|
|
@ -131,7 +131,6 @@ func Login(db store.IStore) echo.HandlerFunc {
|
||||||
// GetUsers handler return a JSON list of all users
|
// GetUsers handler return a JSON list of all users
|
||||||
func GetUsers(db store.IStore) echo.HandlerFunc {
|
func GetUsers(db store.IStore) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
|
|
||||||
usersList, err := db.GetUsers()
|
usersList, err := db.GetUsers()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{
|
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{
|
||||||
|
@ -344,7 +343,6 @@ func RemoveUser(db store.IStore) echo.HandlerFunc {
|
||||||
// WireGuardClients handler
|
// WireGuardClients handler
|
||||||
func WireGuardClients(db store.IStore) echo.HandlerFunc {
|
func WireGuardClients(db store.IStore) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
|
|
||||||
clientDataList, err := db.GetClients(true)
|
clientDataList, err := db.GetClients(true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{
|
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{
|
||||||
|
@ -362,7 +360,6 @@ func WireGuardClients(db store.IStore) echo.HandlerFunc {
|
||||||
// GetClients handler return a JSON list of Wireguard client data
|
// GetClients handler return a JSON list of Wireguard client data
|
||||||
func GetClients(db store.IStore) echo.HandlerFunc {
|
func GetClients(db store.IStore) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
|
|
||||||
clientDataList, err := db.GetClients(true)
|
clientDataList, err := db.GetClients(true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{
|
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{
|
||||||
|
@ -381,7 +378,6 @@ func GetClients(db store.IStore) echo.HandlerFunc {
|
||||||
// GetClient handler returns a JSON object of Wireguard client data
|
// GetClient handler returns a JSON object of Wireguard client data
|
||||||
func GetClient(db store.IStore) echo.HandlerFunc {
|
func GetClient(db store.IStore) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
|
|
||||||
clientID := c.Param("id")
|
clientID := c.Param("id")
|
||||||
|
|
||||||
if _, err := xid.FromString(clientID); err != nil {
|
if _, err := xid.FromString(clientID); err != nil {
|
||||||
|
@ -406,7 +402,6 @@ func GetClient(db store.IStore) echo.HandlerFunc {
|
||||||
// NewClient handler
|
// NewClient handler
|
||||||
func NewClient(db store.IStore) echo.HandlerFunc {
|
func NewClient(db store.IStore) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
|
|
||||||
var client model.Client
|
var client model.Client
|
||||||
c.Bind(&client)
|
c.Bind(&client)
|
||||||
|
|
||||||
|
@ -475,7 +470,6 @@ func NewClient(db store.IStore) echo.HandlerFunc {
|
||||||
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Duplicate Public Key"})
|
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "Duplicate Public Key"})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if client.PresharedKey == "" {
|
if client.PresharedKey == "" {
|
||||||
|
@ -544,14 +538,14 @@ func EmailClient(db store.IStore, mailer emailer.Emailer, emailSubject, emailCon
|
||||||
globalSettings, _ := db.GetGlobalSettings()
|
globalSettings, _ := db.GetGlobalSettings()
|
||||||
config := util.BuildClientConfig(*clientData.Client, server, globalSettings)
|
config := util.BuildClientConfig(*clientData.Client, server, globalSettings)
|
||||||
|
|
||||||
cfgAtt := emailer.Attachment{"wg0.conf", []byte(config)}
|
cfgAtt := emailer.Attachment{Name: "wg0.conf", Data: []byte(config)}
|
||||||
var attachments []emailer.Attachment
|
var attachments []emailer.Attachment
|
||||||
if clientData.Client.PrivateKey != "" {
|
if clientData.Client.PrivateKey != "" {
|
||||||
qrdata, err := base64.StdEncoding.DecodeString(strings.TrimPrefix(clientData.QRCode, "data:image/png;base64,"))
|
qrdata, err := base64.StdEncoding.DecodeString(strings.TrimPrefix(clientData.QRCode, "data:image/png;base64,"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "decoding: " + err.Error()})
|
return c.JSON(http.StatusInternalServerError, jsonHTTPResponse{false, "decoding: " + err.Error()})
|
||||||
}
|
}
|
||||||
qrAtt := emailer.Attachment{"wg.png", qrdata}
|
qrAtt := emailer.Attachment{Name: "wg.png", Data: qrdata}
|
||||||
attachments = []emailer.Attachment{cfgAtt, qrAtt}
|
attachments = []emailer.Attachment{cfgAtt, qrAtt}
|
||||||
} else {
|
} else {
|
||||||
attachments = []emailer.Attachment{cfgAtt}
|
attachments = []emailer.Attachment{cfgAtt}
|
||||||
|
@ -620,7 +614,6 @@ func SendTelegramClient(db store.IStore) echo.HandlerFunc {
|
||||||
// UpdateClient handler to update client information
|
// UpdateClient handler to update client information
|
||||||
func UpdateClient(db store.IStore) echo.HandlerFunc {
|
func UpdateClient(db store.IStore) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
|
|
||||||
var _client model.Client
|
var _client model.Client
|
||||||
c.Bind(&_client)
|
c.Bind(&_client)
|
||||||
|
|
||||||
|
@ -694,7 +687,6 @@ func UpdateClient(db store.IStore) echo.HandlerFunc {
|
||||||
if client.PrivateKey != "" {
|
if client.PrivateKey != "" {
|
||||||
client.PrivateKey = ""
|
client.PrivateKey = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// update Wireguard Client PresharedKey
|
// update Wireguard Client PresharedKey
|
||||||
|
@ -733,7 +725,6 @@ func UpdateClient(db store.IStore) echo.HandlerFunc {
|
||||||
// SetClientStatus handler to enable / disable a client
|
// SetClientStatus handler to enable / disable a client
|
||||||
func SetClientStatus(db store.IStore) echo.HandlerFunc {
|
func SetClientStatus(db store.IStore) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
|
|
||||||
data := make(map[string]interface{})
|
data := make(map[string]interface{})
|
||||||
err := json.NewDecoder(c.Request().Body).Decode(&data)
|
err := json.NewDecoder(c.Request().Body).Decode(&data)
|
||||||
|
|
||||||
|
@ -806,7 +797,6 @@ func DownloadClient(db store.IStore) echo.HandlerFunc {
|
||||||
// RemoveClient handler
|
// RemoveClient handler
|
||||||
func RemoveClient(db store.IStore) echo.HandlerFunc {
|
func RemoveClient(db store.IStore) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
|
|
||||||
client := new(model.Client)
|
client := new(model.Client)
|
||||||
c.Bind(client)
|
c.Bind(client)
|
||||||
|
|
||||||
|
@ -829,7 +819,6 @@ func RemoveClient(db store.IStore) echo.HandlerFunc {
|
||||||
// WireGuardServer handler
|
// WireGuardServer handler
|
||||||
func WireGuardServer(db store.IStore) echo.HandlerFunc {
|
func WireGuardServer(db store.IStore) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
|
|
||||||
server, err := db.GetServer()
|
server, err := db.GetServer()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Cannot get server config: ", err)
|
log.Error("Cannot get server config: ", err)
|
||||||
|
@ -846,7 +835,6 @@ func WireGuardServer(db store.IStore) echo.HandlerFunc {
|
||||||
// WireGuardServerInterfaces handler
|
// WireGuardServerInterfaces handler
|
||||||
func WireGuardServerInterfaces(db store.IStore) echo.HandlerFunc {
|
func WireGuardServerInterfaces(db store.IStore) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
|
|
||||||
var serverInterface model.ServerInterface
|
var serverInterface model.ServerInterface
|
||||||
c.Bind(&serverInterface)
|
c.Bind(&serverInterface)
|
||||||
|
|
||||||
|
@ -872,7 +860,6 @@ func WireGuardServerInterfaces(db store.IStore) echo.HandlerFunc {
|
||||||
// WireGuardServerKeyPair handler to generate private and public keys
|
// WireGuardServerKeyPair handler to generate private and public keys
|
||||||
func WireGuardServerKeyPair(db store.IStore) echo.HandlerFunc {
|
func WireGuardServerKeyPair(db store.IStore) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
|
|
||||||
// gen Wireguard key pair
|
// gen Wireguard key pair
|
||||||
key, err := wgtypes.GeneratePrivateKey()
|
key, err := wgtypes.GeneratePrivateKey()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -897,7 +884,6 @@ func WireGuardServerKeyPair(db store.IStore) echo.HandlerFunc {
|
||||||
// GlobalSettings handler
|
// GlobalSettings handler
|
||||||
func GlobalSettings(db store.IStore) echo.HandlerFunc {
|
func GlobalSettings(db store.IStore) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
|
|
||||||
globalSettings, err := db.GetGlobalSettings()
|
globalSettings, err := db.GetGlobalSettings()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Cannot get global settings: ", err)
|
log.Error("Cannot get global settings: ", err)
|
||||||
|
@ -930,7 +916,6 @@ func Status(db store.IStore) echo.HandlerFunc {
|
||||||
Peers []PeerVM
|
Peers []PeerVM
|
||||||
}
|
}
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
|
|
||||||
wgClient, err := wgctrl.New()
|
wgClient, err := wgctrl.New()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return c.Render(http.StatusInternalServerError, "status.html", map[string]interface{}{
|
return c.Render(http.StatusInternalServerError, "status.html", map[string]interface{}{
|
||||||
|
@ -1011,7 +996,6 @@ func Status(db store.IStore) echo.HandlerFunc {
|
||||||
// GlobalSettingSubmit handler to update the global settings
|
// GlobalSettingSubmit handler to update the global settings
|
||||||
func GlobalSettingSubmit(db store.IStore) echo.HandlerFunc {
|
func GlobalSettingSubmit(db store.IStore) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
|
|
||||||
var globalSettings model.GlobalSetting
|
var globalSettings model.GlobalSetting
|
||||||
c.Bind(&globalSettings)
|
c.Bind(&globalSettings)
|
||||||
|
|
||||||
|
@ -1037,7 +1021,6 @@ func GlobalSettingSubmit(db store.IStore) echo.HandlerFunc {
|
||||||
// MachineIPAddresses handler to get local interface ip addresses
|
// MachineIPAddresses handler to get local interface ip addresses
|
||||||
func MachineIPAddresses() echo.HandlerFunc {
|
func MachineIPAddresses() echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
|
|
||||||
// get private ip addresses
|
// get private ip addresses
|
||||||
interfaceList, err := util.GetInterfaceIPs()
|
interfaceList, err := util.GetInterfaceIPs()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1068,7 +1051,6 @@ func GetOrderedSubnetRanges() echo.HandlerFunc {
|
||||||
// SuggestIPAllocation handler to get the list of ip address for client
|
// SuggestIPAllocation handler to get the list of ip address for client
|
||||||
func SuggestIPAllocation(db store.IStore) echo.HandlerFunc {
|
func SuggestIPAllocation(db store.IStore) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
|
|
||||||
server, err := db.GetServer()
|
server, err := db.GetServer()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Cannot fetch server config from database: ", err)
|
log.Error("Cannot fetch server config from database: ", err)
|
||||||
|
@ -1135,7 +1117,6 @@ func SuggestIPAllocation(db store.IStore) echo.HandlerFunc {
|
||||||
// ApplyServerConfig handler to write config file and restart Wireguard server
|
// ApplyServerConfig handler to write config file and restart Wireguard server
|
||||||
func ApplyServerConfig(db store.IStore, tmplDir fs.FS) echo.HandlerFunc {
|
func ApplyServerConfig(db store.IStore, tmplDir fs.FS) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
|
|
||||||
server, err := db.GetServer()
|
server, err := db.GetServer()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("Cannot get server config: ", err)
|
log.Error("Cannot get server config: ", err)
|
||||||
|
|
|
@ -2,14 +2,15 @@ package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/labstack/echo/v4"
|
"github.com/labstack/echo/v4"
|
||||||
"github.com/labstack/gommon/log"
|
"github.com/labstack/gommon/log"
|
||||||
"github.com/ngoduykhanh/wireguard-ui/model"
|
"github.com/ngoduykhanh/wireguard-ui/model"
|
||||||
"github.com/ngoduykhanh/wireguard-ui/store"
|
"github.com/ngoduykhanh/wireguard-ui/store"
|
||||||
"github.com/sabhiram/go-wol/wol"
|
"github.com/sabhiram/go-wol/wol"
|
||||||
"net"
|
|
||||||
"net/http"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type WakeOnLanHostSavePayload struct {
|
type WakeOnLanHostSavePayload struct {
|
||||||
|
|
1
main.go
1
main.go
|
@ -73,7 +73,6 @@ var embeddedTemplates embed.FS
|
||||||
var embeddedAssets embed.FS
|
var embeddedAssets embed.FS
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
||||||
// command-line flags and env variables
|
// command-line flags and env variables
|
||||||
flag.BoolVar(&flagDisableLogin, "disable-login", util.LookupEnvOrBool("DISABLE_LOGIN", flagDisableLogin), "Disable authentication on the app. This is potentially dangerous.")
|
flag.BoolVar(&flagDisableLogin, "disable-login", util.LookupEnvOrBool("DISABLE_LOGIN", flagDisableLogin), "Disable authentication on the app. This is potentially dangerous.")
|
||||||
flag.StringVar(&flagBindAddress, "bind-address", util.LookupEnvOrString("BIND_ADDRESS", flagBindAddress), "Address:Port to which the app will be bound.")
|
flag.StringVar(&flagBindAddress, "bind-address", util.LookupEnvOrString("BIND_ADDRESS", flagBindAddress), "Address:Port to which the app will be bound.")
|
||||||
|
|
|
@ -33,7 +33,6 @@ func New(dbPath string) (*JsonDB, error) {
|
||||||
dbPath: dbPath,
|
dbPath: dbPath,
|
||||||
}
|
}
|
||||||
return &ans, nil
|
return &ans, nil
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *JsonDB) Init() error {
|
func (o *JsonDB) Init() error {
|
||||||
|
@ -77,7 +76,6 @@ func (o *JsonDB) Init() error {
|
||||||
|
|
||||||
// server's key pair
|
// server's key pair
|
||||||
if _, err := os.Stat(serverKeyPairPath); os.IsNotExist(err) {
|
if _, err := os.Stat(serverKeyPairPath); os.IsNotExist(err) {
|
||||||
|
|
||||||
key, err := wgtypes.GeneratePrivateKey()
|
key, err := wgtypes.GeneratePrivateKey()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return scribble.ErrMissingCollection
|
return scribble.ErrMissingCollection
|
||||||
|
@ -193,7 +191,6 @@ func (o *JsonDB) GetUsers() ([]model.User, error) {
|
||||||
return users, fmt.Errorf("cannot decode user json structure: %v", err)
|
return users, fmt.Errorf("cannot decode user json structure: %v", err)
|
||||||
}
|
}
|
||||||
users = append(users, user)
|
users = append(users, user)
|
||||||
|
|
||||||
}
|
}
|
||||||
return users, err
|
return users, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,6 @@ func (o *JsonDB) SaveWakeOnLanHost(host model.WakeOnLanHost) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *JsonDB) DeleteWakeOnHost(host model.WakeOnLanHost) error {
|
func (o *JsonDB) DeleteWakeOnHost(host model.WakeOnLanHost) error {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue