From 1b2284864de48d2dcae22582fff122fe24909c3d Mon Sep 17 00:00:00 2001 From: key-networks <34238649+key-networks@users.noreply.github.com> Date: Wed, 30 Aug 2023 07:17:08 +0800 Subject: [PATCH] Issue#123: compatibility issue with zerotier 1.12.1 (#125) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * issue#123: version bump * Fix incompatibility with ZeroTier 1.12 (#124) Co-authored-by: Niels Martignène * issue#123: Credit to @Koromix for fix --------- Co-authored-by: Niels Martignène --- README.md | 3 ++- src/controllers/networkController.js | 19 +++++++++++++++---- src/package.json | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b83906d..fb48efc 100644 --- a/README.md +++ b/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) . ## 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. diff --git a/src/controllers/networkController.js b/src/controllers/networkController.js index d186ee2..50c10ee 100644 --- a/src/controllers/networkController.js +++ b/src/controllers/networkController.js @@ -17,15 +17,26 @@ async function get_network_with_members(nwid) { zt.network_detail(nwid), zt.peers(), 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) .map(id => Promise.all([ zt.member_detail(nwid, id), storage.getItem(id) ])) - ) - ).then(results => results.map(([member, name]) => { + ); + }).then(results => results.map(([member, name]) => { member.name = name || ''; return member; })) diff --git a/src/package.json b/src/package.json index 6898ec2..501a6e2 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "ztncui", - "version": "0.8.13", + "version": "0.8.14", "private": true, "scripts": { "start": "node ./bin/www",