Browse Source

bug #1847

tags/v0.11.0
Shaun 2 years ago
parent
commit
e8157820b6
4 changed files with 18 additions and 7 deletions
  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 View File

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

//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)
player.dead = false;


+ 6
- 2
src/server/security/router.js View File

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

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

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

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;
}

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



+ 7
- 0
src/server/security/routerConfig.js View File

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


+ 3
- 3
src/server/server/onConnection.js View File

@@ -16,7 +16,9 @@ const onRequest = (socket, msg, callback) => {
if (!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;

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

msg.socket = socket;

if (source)


Loading…
Cancel
Save