knxultimate
Advanced tools
Comparing version 1.0.10 to 1.0.11
@@ -10,2 +10,7 @@ ![Sample Node](img/logo.png) | ||
<p> | ||
<b>Version 1.0.11</b> - February 2022<br/> | ||
- Added the property containing the decoded Keyring file, accessible by all modules referencing the "index.js".<br/> | ||
- Updated the secure sample code.<br/> | ||
</p> | ||
<p> | ||
<b>Version 1.0.10</b> - February 2022<br/> | ||
@@ -12,0 +17,0 @@ - Added secure connection sample code.<br/> |
@@ -1,4 +0,4 @@ | ||
const {KNXClient,KNXClientEvents} = require("./../knxultimate/src/KNXClient.js"); | ||
const KNXSecureKeyring = require('./../knxultimate/src/KNXsecureKeyring.js'); | ||
exports.KNXSecureKeyring = KNXSecureKeyring; | ||
const {KNXClient,KNXClientEvents,getDecodedKeyring} = require("./src/KNXClient.js"); | ||
//const KNXSecureKeyring = require('./../knxultimate/src/KNXsecureKeyring.js'); | ||
//exports.KNXSecureKeyring = KNXSecureKeyring; | ||
@@ -9,4 +9,5 @@ //exports.KNXClientEvents = KNXClient.KNXClientEvents; | ||
exports.KNXClient.KNXClientEvents = KNXClientEvents; | ||
exports.getDecodedKeyring = getDecodedKeyring; | ||
} catch (error) { | ||
console.log("KNXSecureKeyring",error) | ||
console.log("index",error) | ||
} | ||
@@ -13,0 +14,0 @@ |
{ | ||
"name": "knxultimate", | ||
"description": "KNX IP protocol implementation for Node. This is the ENGINE of Node-Red KNX-Ultimate node.", | ||
"version": "1.0.10", | ||
"version": "1.0.11", | ||
"engines": { | ||
@@ -6,0 +6,0 @@ "node": ">=14" |
@@ -317,2 +317,3 @@ ![Logo](img/logo-big.png) | ||
const knx = require("./index.js"); | ||
const KNXsecureKeyring = require("./src/KNXsecureKeyring.js"); | ||
@@ -355,7 +356,7 @@ // This is the content of the ETS Keyring file obtained doing this: https://www.youtube.com/watch?v=OpR7ZQTlMRU | ||
localIPAddress: "", // Leave blank, will be automatically filled by KNXUltimate | ||
jKNXSecureKeyring:"", // This is the unencrypted Keyring file content (see below) | ||
jKNXSecureKeyring: "", // This is the unencrypted Keyring file content (see below) | ||
}; | ||
async function LoadKeyringFile(_keyring, _password) { | ||
return knx.KNXSecureKeyring.keyring.load(_keyring, _password); | ||
return KNXsecureKeyring.keyring.load(_keyring, _password); | ||
} | ||
@@ -370,2 +371,3 @@ | ||
// Log some infos | ||
@@ -376,2 +378,5 @@ console.log("KNX-Secure: Keyring for ETS proj " + knxUltimateClientProperties.jKNXSecureKeyring.ETSProjectName + ", created by " + knxUltimateClientProperties.jKNXSecureKeyring.ETSCreatedBy + " on " + knxUltimateClientProperties.jKNXSecureKeyring.ETSCreated + " succesfully validated with provided password"); | ||
const knxUltimateClient = new knx.KNXClient(knxUltimateClientProperties); | ||
// This contains the decrypted keyring file, accessible to all .js files referencing the "index.js" module. | ||
console.log(knx.getDecodedKeyring()); | ||
@@ -420,3 +425,3 @@ // Setting handlers | ||
// Wait some second, just for fun | ||
// Wait some seconds, just for fun | ||
await new Promise((resolve, reject) => setTimeout(resolve, 6000)); | ||
@@ -429,3 +434,3 @@ | ||
// START | ||
// Gona fishing. | ||
go(); | ||
@@ -432,0 +437,0 @@ |
const knx = require("./index.js"); | ||
const KNXsecureKeyring = require("./src/KNXsecureKeyring.js"); | ||
@@ -40,7 +41,7 @@ // This is the content of the ETS Keyring file obtained doing this: https://www.youtube.com/watch?v=OpR7ZQTlMRU | ||
localIPAddress: "", // Leave blank, will be automatically filled by KNXUltimate | ||
jKNXSecureKeyring:"", // This is the unencrypted Keyring file content (see below) | ||
jKNXSecureKeyring: "", // This is the unencrypted Keyring file content (see below) | ||
}; | ||
async function LoadKeyringFile(_keyring, _password) { | ||
return knx.KNXSecureKeyring.keyring.load(_keyring, _password); | ||
return KNXsecureKeyring.keyring.load(_keyring, _password); | ||
} | ||
@@ -55,2 +56,3 @@ | ||
// Log some infos | ||
@@ -61,2 +63,5 @@ console.log("KNX-Secure: Keyring for ETS proj " + knxUltimateClientProperties.jKNXSecureKeyring.ETSProjectName + ", created by " + knxUltimateClientProperties.jKNXSecureKeyring.ETSCreatedBy + " on " + knxUltimateClientProperties.jKNXSecureKeyring.ETSCreated + " succesfully validated with provided password"); | ||
const knxUltimateClient = new knx.KNXClient(knxUltimateClientProperties); | ||
// This contains the decrypted keyring file, accessible to all .js files referencing the "index.js" module. | ||
console.log(knx.getDecodedKeyring()); | ||
@@ -105,3 +110,3 @@ // Setting handlers | ||
// Wait some second, just for fun | ||
// Wait some seconds, just for fun | ||
await new Promise((resolve, reject) => setTimeout(resolve, 6000)); | ||
@@ -108,0 +113,0 @@ |
@@ -22,3 +22,3 @@ // Made with love by Supergiovane | ||
const DPTLib = require('./dptlib'); | ||
const KNXsecureKeyring = require("./KNXsecureKeyring.js"); | ||
//const KNXsecureKeyring = require("./KNXsecureKeyring.js"); | ||
//const lodash = require("lodash"); | ||
@@ -68,2 +68,5 @@ | ||
// Contains the decrypted keyring file | ||
var jKNXSecureKeyring = ""; | ||
// options: | ||
@@ -109,3 +112,3 @@ const optionsDefaults = { | ||
this.sysLogger = null; | ||
this.jKNXSecureKeyring = this._options.jKNXSecureKeyring; // 28/12/2021 Contains the Keyring JSON object | ||
jKNXSecureKeyring = this._options.jKNXSecureKeyring; // 28/12/2021 Contains the Keyring JSON object | ||
try { | ||
@@ -126,2 +129,3 @@ this.sysLogger = require("./KnxLog.js").get({ loglevel: this._options.loglevel }); // 08/04/2021 new logger to adhere to the loglevel selected in the config-window | ||
let conn = this; | ||
@@ -658,3 +662,3 @@ // 07/12/2021 Based on protocol instantiate the right socket | ||
conn._clientTunnelSeqNumber = 0; | ||
if (conn._options.isSecureKNXEnabled) conn._sendSecureSessionRequestMessage(new TunnelCRI.TunnelCRI(knxLayer), conn.jKNXSecureKeyring); | ||
if (conn._options.isSecureKNXEnabled) conn._sendSecureSessionRequestMessage(new TunnelCRI.TunnelCRI(knxLayer)); | ||
}); | ||
@@ -1054,8 +1058,9 @@ | ||
} | ||
_sendSecureSessionRequestMessage(cri, jKNXSecureKeyring) { | ||
_sendSecureSessionRequestMessage(cri) { | ||
let oHPAI = new HPAI.HPAI("0.0.0.0", 0, this._options.hostProtocol === "TunnelTCP" ? KNXConstants.KNX_CONSTANTS.IPV4_TCP : KNXConstants.KNX_CONSTANTS.IPV4_UDP); | ||
this.send(KNXProtocol.KNXProtocol.newKNXSecureSessionRequest(cri, oHPAI, jKNXSecureKeyring)); | ||
this.send(KNXProtocol.KNXProtocol.newKNXSecureSessionRequest(cri, oHPAI)); | ||
} | ||
} | ||
// module.exports = function KNXClientEvents() { | ||
@@ -1066,5 +1071,8 @@ // return KNXClientEvents; | ||
KNXClient: KNXClient, | ||
KNXClientEvents: KNXClientEvents | ||
KNXClientEvents: KNXClientEvents, | ||
getDecodedKeyring: function () { | ||
return jKNXSecureKeyring; | ||
} // Contains the decoded keyring file | ||
}; | ||
//exports.KNXClient = KNXClient; | ||
//exports.KNXClientEvents = KNXClientEvents; |
@@ -122,4 +122,4 @@ /** | ||
// Class returned by the keyring function after the load | ||
var _retJson = {}; | ||
// Returned by the keyring function after the load | ||
let _retJson = {}; | ||
@@ -422,3 +422,3 @@ var signature = ""; | ||
} catch (error) { | ||
KnxLog.get().error("load " + error.message); | ||
KnxLog.get().error("get " + error.message); | ||
throw (error); | ||
@@ -558,14 +558,13 @@ } | ||
} | ||
return _retJson; | ||
} | ||
return { | ||
load: load | ||
}; | ||
})(); | ||
exports.keyring = keyring; |
@@ -102,4 +102,4 @@ 'use strict'; | ||
} | ||
static newKNXSecureSessionRequest(cri, hpaiData = HPAI.HPAI.NULLHPAI, jKNXSecureKeyring) { | ||
return new KNXSecureSessionRequest.KNXSecureSessionRequest(cri, hpaiData, jKNXSecureKeyring); | ||
static newKNXSecureSessionRequest(cri, hpaiData = HPAI.HPAI.NULLHPAI) { | ||
return new KNXSecureSessionRequest.KNXSecureSessionRequest(cri, hpaiData); | ||
} | ||
@@ -106,0 +106,0 @@ } |
@@ -11,5 +11,6 @@ 'use strict'; | ||
const CRIFactory = __importDefault(require("./CRIFactory")); | ||
const knx = require("../../index.js"); | ||
class KNXSecureSessionRequest extends KNXPacket.KNXPacket { | ||
constructor(cri, hpaiData = HPAI.HPAI.NULLHPAI, _jKNXSecureKeyring = {}) { | ||
constructor(cri, hpaiData = HPAI.HPAI.NULLHPAI) { | ||
//super(KNXConstants.KNX_CONSTANTS.SECURE_SESSION_REQUEST, hpaiControl.length + hpaiData.length + cri.length + 32); | ||
@@ -19,2 +20,4 @@ super(KNXConstants.KNX_CONSTANTS.SECURE_SESSION_REQUEST, hpaiData.length + 32); | ||
this.hpaiData = hpaiData; | ||
// Get the Keyring | ||
this.keyring = knx.getDecodedKeyring(); | ||
this.diffieHellmanClientPublicValue = new Buffer.alloc(32); | ||
@@ -24,3 +27,3 @@ | ||
// 02/01/2022 SONO ARRIVATO QUI get the authentication password from the first tunnel of the interface | ||
let authenticationPassword = _jKNXSecureKeyring.Devices[0].authenticationPassword; | ||
let authenticationPassword = this.keyring.Devices[0].authenticationPassword; | ||
//authenticationPassword = authenticationPassword.length === 0 ? new byte[16] : authenticationPassword; | ||
@@ -27,0 +30,0 @@ authenticationPassword = authenticationPassword.length === 0 ? "00000000000000000000000000000000" : authenticationPassword; |
939789
103
9158
457