bug fix
This commit is contained in:
parent
3d3d2be6df
commit
9001b21b07
@ -290,7 +290,7 @@ function Database(user, password, dbname, host = 'localhost') {
|
||||
db.getData = function(snID, logtime) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let statement = "SELECT * FROM _" + snID +
|
||||
" WHERE " + L_struct.LOG_TIME + ">=" + logtime +
|
||||
" WHERE " + L_struct.LOG_TIME + ">" + logtime +
|
||||
" ORDER BY " + L_struct.LOG_TIME;
|
||||
db.query(statement)
|
||||
.then(result => resolve(result))
|
||||
|
||||
23
src/intra.js
23
src/intra.js
@ -136,14 +136,19 @@ packet_.constuct = function(message) {
|
||||
};
|
||||
packet_.s = d => [JSON.stringify(d.message), d.time].join("|");
|
||||
packet_.parse = function(str) {
|
||||
let packet = JSON.parse(str.substring(SUPERNODE_INDICATOR.length));
|
||||
let curTime = Date.now();
|
||||
if (packet.time > curTime - floGlobals.sn_config.delayDelta &&
|
||||
packet.from in floGlobals.supernodes &&
|
||||
floCrypto.verifySign(this.s(packet), packet.sign, floGlobals.supernodes[packet.from].pubKey)) {
|
||||
if (!Array.isArray(packet.message))
|
||||
packet.message = [packet.message];
|
||||
return packet;
|
||||
try {
|
||||
let packet = JSON.parse(str.substring(SUPERNODE_INDICATOR.length));
|
||||
let curTime = Date.now();
|
||||
if (packet.time > curTime - floGlobals.sn_config.delayDelta &&
|
||||
packet.from in floGlobals.supernodes &&
|
||||
floCrypto.verifySign(this.s(packet), packet.sign, floGlobals.supernodes[packet.from].pubKey)) {
|
||||
if (!Array.isArray(packet.message))
|
||||
packet.message = [packet.message];
|
||||
return packet;
|
||||
};
|
||||
} catch (error) {
|
||||
console.error(str, error);
|
||||
return false;
|
||||
};
|
||||
};
|
||||
|
||||
@ -416,7 +421,7 @@ function handshakeEnd() {
|
||||
|
||||
//Reconnect to next available node
|
||||
function reconnectNextNode() {
|
||||
if (_nextNode.ws)
|
||||
if (_nextNode.id)
|
||||
_nextNode.close();
|
||||
connectToNextNode()
|
||||
.then(result => console.log(result))
|
||||
|
||||
@ -51,15 +51,21 @@ module.exports = function Server(port, client, intra) {
|
||||
intra.processTaskFromSupernode(message, ws);
|
||||
else {
|
||||
console.debug("WS: ", message);
|
||||
var request = JSON.parse(message);
|
||||
client.processRequestFromUser(request)
|
||||
.then(result => {
|
||||
ws.send(JSON.stringify(result[0]));
|
||||
ws._liveReq = request;
|
||||
}).catch(error => {
|
||||
if (floGlobals.sn_config.errorFeedback)
|
||||
ws.send(error.toString());
|
||||
});
|
||||
try {
|
||||
var request = JSON.parse(message);
|
||||
client.processRequestFromUser(request)
|
||||
.then(result => {
|
||||
ws.send(JSON.stringify(result[0]));
|
||||
ws._liveReq = request;
|
||||
}).catch(error => {
|
||||
if (floGlobals.sn_config.errorFeedback)
|
||||
ws.send(error.toString());
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
if (floGlobals.sn_config.errorFeedback)
|
||||
ws.send("Request not in JSON format");
|
||||
};
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user