diff --git a/Dockerfile b/Dockerfile index c532e42..0a96884 100644 --- a/Dockerfile +++ b/Dockerfile @@ -71,6 +71,7 @@ RUN mkdir -p db COPY --from=builder --chown=wgui:wgui /build/wg-ui . RUN chmod +x wg-ui COPY init.sh . +RUN chmod +x init.sh EXPOSE 5000/tcp ENTRYPOINT ["./init.sh"] diff --git a/custom/js/helper.js b/custom/js/helper.js index d98eacb..5b43272 100644 --- a/custom/js/helper.js +++ b/custom/js/helper.js @@ -38,13 +38,18 @@ function renderClientList(data) { subnetRangesString = obj.Client.subnet_ranges.join(',') } + let additionalNotesHtml = ""; + if (obj.Client.additional_notes && obj.Client.additional_notes.length > 0) { + additionalNotesHtml = `` + } + // render client html content let html = `
-
+
@@ -81,6 +86,7 @@ function renderClientList(data) { ${telegramHtml} + ${additionalNotesHtml} ${obj.Client.email} ${prettyDateTime(obj.Client.created_at)} @@ -88,6 +94,8 @@ function renderClientList(data) { ${prettyDateTime(obj.Client.updated_at)} ${obj.Client.use_server_dns ? 'DNS enabled' : 'DNS disabled'} + + ${obj.Client.additional_notes} IP Allocation` + allocatedIpsHtml + `Allowed IPs` diff --git a/go.mod b/go.mod index 6255955..e9647ca 100644 --- a/go.mod +++ b/go.mod @@ -47,6 +47,6 @@ require ( golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.5.0 // indirect - golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 // indirect + golang.zx2c4.com/wireguard v0.0.0-20210427022245-097af6e1351b // indirect gopkg.in/go-playground/assert.v1 v1.2.1 // indirect ) diff --git a/go.sum b/go.sum index 16f05fe..3aa2ceb 100644 --- a/go.sum +++ b/go.sum @@ -174,13 +174,10 @@ golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.zx2c4.com/wireguard v0.0.0-20210427022245-097af6e1351b h1:XDLXhn7ryprJVo+Lpkiib6CIuXE2031GDwtfEm7vLjI= golang.zx2c4.com/wireguard v0.0.0-20210427022245-097af6e1351b/go.mod h1:a057zjmoc00UN7gVkaJt2sXVK523kMJcogDTEvPIasg= -golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173 h1:/jFs0duh4rdb8uIfPMv78iAJGcPKDeqAFnaLBropIC4= -golang.zx2c4.com/wireguard v0.0.0-20231211153847-12269c276173/go.mod h1:tkCQ4FQXmpAgYVh++1cq16/dH4QJtmvpRv19DWGAHSA= golang.zx2c4.com/wireguard/wgctrl v0.0.0-20210803171230-4253848d036c h1:ADNrRDI5NR23/TUCnEmlLZLt4u9DnZ2nwRkPrAcFvto= golang.zx2c4.com/wireguard/wgctrl v0.0.0-20210803171230-4253848d036c/go.mod h1:+1XihzyZUBJcSc5WO9SwNA7v26puQwOEDwanaxfNXPQ= -golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6 h1:CawjfCvYQH2OU3/TnxLx97WDSUDRABfT18pCOYwc2GE= -golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6/go.mod h1:3rxYc4HtVcSG9gVaTs2GEBdehh+sYPOwKtyUWEOTb80= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= diff --git a/handler/routes.go b/handler/routes.go index ef01d08..ede3654 100644 --- a/handler/routes.go +++ b/handler/routes.go @@ -720,6 +720,7 @@ func UpdateClient(db store.IStore) echo.HandlerFunc { client.PublicKey = _client.PublicKey client.PresharedKey = _client.PresharedKey client.UpdatedAt = time.Now().UTC() + client.AdditionalNotes = strings.ReplaceAll(strings.Trim(_client.AdditionalNotes, "\r\n"), "\r\n", "\n") // write to the database if err := db.SaveClient(client); err != nil { @@ -978,10 +979,13 @@ func Status(db store.IStore) echo.HandlerFunc { LastHandshakeTime: devices[i].Peers[j].LastHandshakeTime, LastHandshakeRel: time.Since(devices[i].Peers[j].LastHandshakeTime), AllocatedIP: allocatedIPs, - Endpoint: devices[i].Peers[j].Endpoint.String(), } pVm.Connected = pVm.LastHandshakeRel.Minutes() < 3. + if isAdmin(c) { + pVm.Endpoint = devices[i].Peers[j].Endpoint.String() + } + if _client, ok := m[pVm.PublicKey]; ok { pVm.Name = _client.Name pVm.Email = _client.Email diff --git a/model/client.go b/model/client.go index cb00016..d835124 100644 --- a/model/client.go +++ b/model/client.go @@ -18,6 +18,7 @@ type Client struct { AllowedIPs []string `json:"allowed_ips"` ExtraAllowedIPs []string `json:"extra_allowed_ips"` Endpoint string `json:"endpoint"` + AdditionalNotes string `json:"additional_notes"` UseServerDNS bool `json:"use_server_dns"` Enabled bool `json:"enabled"` CreatedAt time.Time `json:"created_at"` diff --git a/store/jsondb/jsondb.go b/store/jsondb/jsondb.go index 1401b2c..1cd0a43 100644 --- a/store/jsondb/jsondb.go +++ b/store/jsondb/jsondb.go @@ -154,6 +154,7 @@ func (o *JsonDB) Init() error { } o.conn.Write("users", user.Username, user) + results, _ = o.conn.ReadAll("users") err = util.ManagePerms(path.Join(path.Join(o.dbPath, "users"), user.Username+".json")) if err != nil { return err diff --git a/templates/base.html b/templates/base.html index ab086e1..3640699 100644 --- a/templates/base.html +++ b/templates/base.html @@ -288,6 +288,10 @@
+
+ + +
+
+ + +