From a93d27f08e5194ba58b3423cf4c4887d92b7b8f0 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Thu, 6 Apr 2023 00:35:11 +0200 Subject: [PATCH] server: print multiple qrcodes if multiple network interfaces are available and prevent printing a qrcode for the localhost address --- CHANGELOG.md | 5 ++++- src/server/index.js | 28 +++++++++++++++++++--------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a5506a4..8629d68f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## 1.23.1 +## 1.24.0 - bug fixes - widgets: circular value feedback issues @@ -14,6 +14,9 @@ - custom module - add optional `errorCallback` argument to`loadJSON` and `saveJSON` +- server + - print multiple qrcodes if multiple network interfaces are available and prevent printing a qrcode for the localhost address + - misc - add linux rpm packages diff --git a/src/server/index.js b/src/server/index.js index 3fac5cb4..70da7123 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -86,17 +86,27 @@ function openClient() { function showQRCode(){ - var QRCode = require('qrcode') + var QRCode = require('qrcode'), + addresses = settings.appAddresses().filter(a=>!a.includes('127.0.0.1') && !a.includes('localhost')) - if (launcher) { - QRCode.toString(settings.appAddresses().pop(),{type:'svg', small: true, margin: 1}, (err, qr)=>{ - launcher.webContents.send('stdout', '
' + qr + '
') - }) - } else { - QRCode.toString(settings.appAddresses().pop(),{type:'terminal', small: true}, (err, qr)=>{ - console.log('\n' + qr.replace(/^/gm, ' ')) - }) + for (var add of addresses) { + if (launcher) { + QRCode.toString(add,{type:'svg', small: true, margin: 1}, (err, qr)=>{ + launcher.webContents.send('stdout', '
' + qr + '
') + }) + if (addresses.length > 1) { + launcher.webContents.send('stdout', '(' + add + ')') + } + } else { + QRCode.toString(add,{type:'terminal', small: true}, (err, qr)=>{ + console.log('\n' + qr.replace(/^/gm, ' ')) + }) + if (addresses.length > 1) { + console.log(' (' + add + ')') + } + } } + } function startServerProcess() {