Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Add timestamp to config #44

Merged
merged 2 commits into from
Mar 16, 2020
Merged
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
5 changes: 5 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net"
"os"
"path/filepath"
"time"

log "github.com/sirupsen/logrus"
"golang.zx2c4.com/wireguard/wgctrl/wgtypes"
Expand All @@ -32,6 +33,8 @@ type ClientConfig struct {
PublicKey string
IP net.IP
Notes string
Created string
Modified string
}

// NewServerConfig creates and returns a reference to a new ServerConfig
Expand Down Expand Up @@ -102,6 +105,8 @@ func NewClientConfig(ip net.IP) *ClientConfig {
PublicKey: key.PublicKey().String(),
IP: ip,
Notes: "",
Created: time.Now().Format(time.RFC3339),
Modified: time.Now().Format(time.RFC3339),
}

return &cfg
Expand Down
3 changes: 3 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"strconv"
"strings"
"sync"
"time"

assetfs "github.com/elazarl/go-bindata-assetfs"
"github.com/google/nftables"
Expand Down Expand Up @@ -545,6 +546,8 @@ func (s *Server) EditClient(w http.ResponseWriter, r *http.Request, ps httproute
client.Notes = cfg.Notes
}

client.Modified = time.Now().Format(time.RFC3339)

s.reconfigure()

w.WriteHeader(http.StatusOK)
Expand Down