Shaun pirms 2 gadiem
vecāks
revīzija
e8157820b6
4 mainītis faili ar 18 papildinājumiem un 7 dzēšanām
  1. +2
    -2
      src/server/security/connections.js
  2. +6
    -2
      src/server/security/router.js
  3. +7
    -0
      src/server/security/routerConfig.js
  4. +3
    -3
      src/server/server/onConnection.js

+ 2
- 2
src/server/security/connections.js Parādīt failu

@@ -101,8 +101,8 @@ module.exports = {
}); });


//If we don't do this, the atlas will try to remove it from the thread //If we don't do this, the atlas will try to remove it from the thread
player.zoneName = null;
player.name = null;
delete player.zoneName;
delete player.name;


//A hack to allow us to actually call methods again (like retrieve the player list) //A hack to allow us to actually call methods again (like retrieve the player list)
player.dead = false; player.dead = false;


+ 6
- 2
src/server/security/router.js Parādīt failu

@@ -127,7 +127,7 @@ module.exports = {
return keysCorrect; return keysCorrect;
}, },


isMsgValid: function (msg) {
isMsgValid: function (msg, source) {
let signature; let signature;


if (msg.module) { if (msg.module) {
@@ -152,8 +152,12 @@ module.exports = {


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


if (!result || msg.cpn !== 'player' || msg.method !== 'performAction')
if (!result || msg.cpn !== 'player' || msg.method !== 'performAction') {
if (result && signature.allowWhenIngame === false && source.name !== undefined)
return false;

return result; return result;
}


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




+ 7
- 0
src/server/security/routerConfig.js Parādīt failu

@@ -49,6 +49,7 @@ const routerConfig = {
auth: { auth: {
login: { login: {
callback: true, callback: true,
allowWhenIngame: false,
data: [ data: [
{ {
key: 'username', key: 'username',
@@ -62,6 +63,7 @@ const routerConfig = {
}, },
register: { register: {
callback: true, callback: true,
allowWhenIngame: false,
data: [ data: [
{ {
key: 'username', key: 'username',
@@ -75,6 +77,7 @@ const routerConfig = {
}, },
deleteCharacter: { deleteCharacter: {
callback: true, callback: true,
allowWhenIngame: false,
data: [ data: [
{ {
key: 'name', key: 'name',
@@ -88,6 +91,7 @@ const routerConfig = {
}, },
createCharacter: { createCharacter: {
callback: true, callback: true,
allowWhenIngame: false,
data: [ data: [
{ {
key: 'name', key: 'name',
@@ -109,10 +113,12 @@ const routerConfig = {
}, },
getCharacterList: { getCharacterList: {
callback: true, callback: true,
allowWhenIngame: false,
data: [] data: []
}, },
getCharacter: { getCharacter: {
callback: true, callback: true,
allowWhenIngame: false,
data: [ data: [
{ {
key: 'name', key: 'name',
@@ -122,6 +128,7 @@ const routerConfig = {
}, },
play: { play: {
callback: true, callback: true,
allowWhenIngame: false,
data: [ data: [
{ {
key: 'name', key: 'name',


+ 3
- 3
src/server/server/onConnection.js Parādīt failu

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


if (!router.isMsgValid(msg))
const source = cons.players.find(p => p.socket.id === socket.id);

if (!router.isMsgValid(msg, source))
return; return;


if (msg.cpn) if (msg.cpn)
@@ -24,8 +26,6 @@ const onRequest = (socket, msg, callback) => {
else if (msg.threadModule) else if (msg.threadModule)
cons.route(socket, msg); cons.route(socket, msg);
else { else {
const source = cons.players.find(p => p.socket.id === socket.id);

msg.socket = socket; msg.socket = socket;


if (source) if (source)


Notiek ielāde…
Atcelt
Saglabāt