Browse Source

chore #1912: removed test code

tags/v0.10.6.10^2
Shaun 2 years ago
parent
commit
1765690747
2 changed files with 8 additions and 33 deletions
  1. +7
    -29
      src/server/security/router.js
  2. +1
    -4
      src/server/server/onConnection.js

+ 7
- 29
src/server/security/router.js View File

@@ -69,11 +69,8 @@ module.exports = {
return true;

const foundIncorrectObject = value.some(v => !this.keysCorrect(v, spec));
if (foundIncorrectObject) {
console.log('array of objects spec match failed');

if (foundIncorrectObject)
return true;
}

return foundIncorrectObject;
} else if (dataType === 'object') {
@@ -84,11 +81,8 @@ module.exports = {
return false;

const foundIncorrectObject = !this.keysCorrect(value, spec);
if (foundIncorrectObject) {
console.log('object spec match failed');

if (foundIncorrectObject)
return true;
}

return foundIncorrectObject;
} else if (dataType === 'stringOrNull')
@@ -126,53 +120,37 @@ module.exports = {
let signature;

if (msg.module) {
if (msg.threadModule !== undefined || msg.cpn !== undefined || msg.data.cpn !== undefined) {
console.log('msg contains invalid root key');
if (msg.threadModule !== undefined || msg.cpn !== undefined || msg.data.cpn !== undefined)
return false;
}

signature = signatures.global[msg.module]?.[msg.method];
} else if (msg.threadModule) {
if (msg.module !== undefined || msg.cpn !== undefined || msg.data.cpn !== undefined) {
console.log('msg contains invalid root key');
if (msg.module !== undefined || msg.cpn !== undefined || msg.data.cpn !== undefined)
return false;
}

signature = signatures.threadGlobal[msg.threadModule]?.[msg.method];
} else if (msg.cpn) {
if (msg.module !== undefined || msg.threadModule !== undefined) {
console.log('msg contains invalid root key');
if (msg.module !== undefined || msg.threadModule !== undefined)
return false;
}

signature = signatures.cpnMethods[msg.cpn]?.[msg.method];
}

if (!signature) {
console.log('signature not found');
if (!signature)
return false;
}

const result = this.signatureCorrect(msg, signature);

if (!result)
console.log('signature check failed');

if (!result || msg.cpn !== 'player' || (msg.method !== 'performAction' && msg.method !== 'queueAction'))
return result;

const signatureThreadMsg = signatures.threadCpnMethods[msg.data.cpn]?.[msg.data.method];

if (!signatureThreadMsg) {
console.log('sub signature not found');
if (!signatureThreadMsg)
return false;
}

const resultSub = this.signatureCorrect(msg.data, signatureThreadMsg);

if (!resultSub)
console.log('sub signature check failed');

return resultSub;
}
};

+ 1
- 4
src/server/server/onConnection.js View File

@@ -16,11 +16,8 @@ const onRequest = (socket, msg, callback) => {
if (!msg.data)
msg.data = {};

if (!router.isMsgValid(msg)) {
console.log(msg);
if (!router.isMsgValid(msg))
return;
}

if (msg.cpn)
cons.route(socket, msg);


Loading…
Cancel
Save