From 7502997e7e3d1269694a1c7b2aa3231232516538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Colomb?= Date: Thu, 17 Dec 2020 19:54:31 +0100 Subject: [PATCH] all: Store pending devices and folders in database (fixes #7178) (#6443) --- cmd/stindex/dump.go | 17 + gui/default/index.html | 32 +- .../syncthing/core/syncthingController.js | 72 +- lib/api/api.go | 89 ++- lib/api/mocked_config_test.go | 4 + lib/api/mocked_model_test.go | 8 + lib/config/config.go | 32 +- lib/config/config.pb.go | 105 +-- lib/config/config_test.go | 18 - lib/config/deviceconfiguration.go | 9 - lib/config/deviceconfiguration.pb.go | 146 ++-- lib/config/wrapper.go | 59 +- lib/db/keyer.go | 49 ++ lib/db/observed.go | 172 +++++ lib/db/structs.pb.go | 640 +++++++++++++++--- lib/model/model.go | 102 ++- lib/model/model_test.go | 72 ++ proto/lib/config/config.proto | 2 +- proto/lib/config/deviceconfiguration.proto | 2 +- proto/lib/db/structs.proto | 12 + 20 files changed, 1259 insertions(+), 383 deletions(-) create mode 100644 lib/db/observed.go diff --git a/cmd/stindex/dump.go b/cmd/stindex/dump.go index 44514dabd..7f2f704c4 100644 --- a/cmd/stindex/dump.go +++ b/cmd/stindex/dump.go @@ -131,6 +131,23 @@ func dump(ldb backend.Backend) { fmt.Printf(" V:%v\n", v) } + case db.KeyTypePendingFolder: + device := binary.BigEndian.Uint32(key[1:]) + folder := string(key[5:]) + var of db.ObservedFolder + of.Unmarshal(it.Value()) + fmt.Printf("[pendingFolder] D:%d F:%s V:%v\n", device, folder, of) + + case db.KeyTypePendingDevice: + device := "" + dev, err := protocol.DeviceIDFromBytes(key[1:]) + if err == nil { + device = dev.String() + } + var od db.ObservedDevice + od.Unmarshal(it.Value()) + fmt.Printf("[pendingDevice] D:%v V:%v\n", device, od) + default: fmt.Printf("[??? %d]\n %x\n %x\n", key[0], key, it.Value()) } diff --git a/gui/default/index.html b/gui/default/index.html index b980ccf5c..f2bff80d3 100644 --- a/gui/default/index.html +++ b/gui/default/index.html @@ -190,7 +190,7 @@ -
+
@@ -202,17 +202,17 @@

- + Device "{%name%}" ({%device%} at {%address%}) wants to connect. Add new device?

-
-
+
+
@@ -231,32 +231,32 @@
- New Folder - Share Folder - {{ pendingFolder.time | date:"yyyy-MM-dd HH:mm:ss" }} + New Folder + Share Folder + {{ offeringDevice.time | date:"yyyy-MM-dd HH:mm:ss" }}

- + {%device%} wants to share folder "{%folder%}". - + {%device%} wants to share folder "{%folderlabel%}" ({%folder%}). - Share this folder? - Add new folder? + Share this folder? + Add new folder?