Преглед на файлове

Issue#123: compatibility issue with zerotier 1.12.1 (#125)

* issue#123: version bump

* Fix incompatibility with ZeroTier 1.12 (#124)

Co-authored-by: Niels Martignène <niels.martignene@protonmail.com>

* issue#123: Credit to @Koromix for fix

---------

Co-authored-by: Niels Martignène <niels.martignene@protonmail.com>
key-networks преди 1 година
родител
ревизия
1b2284864d
променени са 3 файла, в които са добавени 18 реда и са изтрити 6 реда
  1. 2 1
      README.md
  2. 15 4
      src/controllers/networkController.js
  3. 1 1
      src/package.json

+ 2 - 1
README.md

@@ -305,4 +305,5 @@ Problems with ztncui can be reported using the GitHub issue tracking system.  Pl
 The ztncui code is open source code, licensed under the GNU GPLv3, and is free to use on those terms. If you are interested in commercial licensing, please contact us via the contact form at [key-networks.com](https://key-networks.com) .
 The ztncui code is open source code, licensed under the GNU GPLv3, and is free to use on those terms. If you are interested in commercial licensing, please contact us via the contact form at [key-networks.com](https://key-networks.com) .
 
 
 ## Thanks
 ## Thanks
-@lideming for a rework and improvement of the network details page, adding DNS support, peer status/address/latency and other improvements.
+- @lideming for a rework and improvement of the network details page, adding DNS support, peer status/address/latency and other improvements.
+- @Koromix for a fix for incompatibility with ZeroTier 1.12.

+ 15 - 4
src/controllers/networkController.js

@@ -17,15 +17,26 @@ async function get_network_with_members(nwid) {
     zt.network_detail(nwid),
     zt.network_detail(nwid),
     zt.peers(),
     zt.peers(),
     zt.members(nwid)
     zt.members(nwid)
-      .then(member_ids =>
-        Promise.all(
+      .then(member_ids => {
+        // Fix weird data returned by ZeroTier 1.12
+        if (Array.isArray(member_ids)) {
+          let obj = {};
+          for (let id of member_ids) {
+            let key = Object.keys(id)[0];
+            let value = Object.values(id)[0];
+            obj[key] = value;
+          }
+          member_ids = obj;
+        }
+
+        return Promise.all(
           Object.keys(member_ids)
           Object.keys(member_ids)
             .map(id => Promise.all([
             .map(id => Promise.all([
               zt.member_detail(nwid, id),
               zt.member_detail(nwid, id),
               storage.getItem(id)
               storage.getItem(id)
             ]))
             ]))
-        )
-      ).then(results => results.map(([member, name]) => {
+        );
+      }).then(results => results.map(([member, name]) => {
         member.name = name || '';
         member.name = name || '';
         return member;
         return member;
       }))
       }))

+ 1 - 1
src/package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "ztncui",
   "name": "ztncui",
-  "version": "0.8.13",
+  "version": "0.8.14",
   "private": true,
   "private": true,
   "scripts": {
   "scripts": {
     "start": "node ./bin/www",
     "start": "node ./bin/www",