From 41f39fd23337464ec298ddab58ae4eb70ceb9b1c Mon Sep 17 00:00:00 2001 From: Kaan Soral Date: Sat, 28 Oct 2023 14:32:43 +0300 Subject: [PATCH] Secrets refactoring --- .DS_Store | Bin 30724 -> 32772 bytes README.md | 30 +++++++++++++++++++----------- functions.py | 1 + node/server.js | 12 ++++++------ 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/.DS_Store b/.DS_Store index ce753197973afd0ef7d15cb5aae8d121192cb49d..6779848ad753acd243824f2b0af0a128c4d52003 100644 GIT binary patch delta 420 zcmZqqz}V8jB+bCU!01$(V#vUd!N9=4!2qEJco-N8CQ6&I7BDa{ux||6&dlbx pj<6ylD3qBP7#LVL^CWCwgG-!cWXgA$EEBG{Su$LjeeyehF#yG#W_ADo delta 258 zcmZo^U~2imD9ymY!01$(V#vTyz`(%3!2qEJco-NGCQ6&I<})xbux$+4&d(^enKk7C z^XA88XBjv12qbZB=2keuyV*#>hG{dm0hG0v+d+U)VzQo>*kq*u&&e5DEuzMz#ySdy zW=6F-3e|?jmL@t1<|by78MRF}e-8T1GkIs8=4So`XU543{L@*P7#J8>HuDs0VA~v; zxPfW2jJGM{n{#5Cm{F9ff*cBRD>nlJgDV3A*u6Xq3<^993z>% diff --git a/README.md b/README.md index 2269f6d..c3f63ee 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,14 @@ Clone a modified copy of Python2 App Engine Local App Server into the python fol ```sh git clone https://github.com/kaansoral/adventureland-appserver appserver ``` + +Set up secrets files and remember to change secret keys! +```sh +cp adventureland/useful/template.secrets.py adventureland/secrets.py +cp adventureland/useful/template.variables.js adventureland/node/variables.js +cp adventureland/useful/template.live_variables.js adventureland/node/live_variables.js +``` + You'll need to download Python2.7 and use the command that comes along with it - it could be ./python or python.exe depending on your setup method Here's the download page: https://www.python.org/downloads/release/python-2718/ For Linux: @@ -41,12 +49,7 @@ pip2.7 install lxml Run the Python2.7 backend - includes an HTTP server, datastore, various utilities - emulates Google App Engine: ```sh -python2.7 appserver/sdk/dev_appserver.py --storage_path=appserver/storage/ --blobstore_path=appserver/storage/blobstore/ --datastore_path=appserver/storage/db.rdbms --host=0.0.0.0 --port=8083 adventureland/ --require_indexes --skip_sdk_update_check -``` - -Set up the NodeJS project for helpful scripts: -```sh -npm install adventureland/scripts/ +python2.7 appserver/sdk/dev_appserver.py --storage_path=appserver/storage/ --blobstore_path=appserver/storage/blobstore/ --datastore_path=appserver/storage/db.rdbms --host=0.0.0.0 --port=80 adventureland/ --require_indexes --skip_sdk_update_check ``` Set up the NodeJS game server: @@ -54,19 +57,24 @@ Set up the NodeJS game server: npm install adventureland/node/ ``` -Edit the paths in `adventureland/node/variables.js` +Edit the paths in `adventureland/node/variables.js` if you want to run the server from any path + +Enter the path of the NodeJS server: +```sh +cd adventureland/node +``` Run a server: ```sh -node adventureland/node/server.js EU I 8022 +node server.js EU I 8022 ``` -You should be able to access the game at: http://0.0.0.0:8083/ +You should be able to access the game at: http://0.0.0.0/ + +If you're on Windows and have issues with `0.0.0.0` - replace them with `127.0.0.1` and use http://127.0.0.1/ The **useful/** folder has useful commands -`secrets.py` has the secrets - ## Network Add these to your /etc/hosts file: diff --git a/functions.py b/functions.py index 55e63b9..1699ab3 100644 --- a/functions.py +++ b/functions.py @@ -283,6 +283,7 @@ def security_threat(self,domain): #referer="www.thegame2.com" logging.info(referer) if referer.startswith("127.0.0.1"): return False + if referer.startswith("0.0.0.0"): return False if not (referer.startswith("%s.%s.%s/"%(domain.domain[0],domain.domain[1],domain.domain[2])) or referer.startswith("%s.%s/"%(domain.domain[1],domain.domain[2])) or referer=="%s.%s.%s"%(domain.domain[0],domain.domain[1],domain.domain[2]) or referer=="%s.%s"%(domain.domain[1],domain.domain[2])): self.response.out.write("Threat detected") return True diff --git a/node/server.js b/node/server.js index 76c0118..c594c53 100644 --- a/node/server.js +++ b/node/server.js @@ -426,7 +426,7 @@ function http_handler(request,response) // server_log("ipass for "+players[id].name); } } - if(args.spass!=variables.master) + if(args.spass!=variables.access_master) { response.writeHead(200); response.end(output); @@ -2778,7 +2778,7 @@ function init_io(){ io.on('connection', function (socket) { if(socket.handshake.query.server_method) { - if(socket.handshake.query.server_master==variables.server_master) + if(0 && socket.handshake.query.server_master==variables.server_master) // this was to make servers communicate with each other and disconnect overflows immediately [28/10/23] { if(socket.handshake.query.server_method=="players") { @@ -7082,16 +7082,16 @@ io.on('connection', function (socket) { } }); socket.on('shutdown',function(data){ - if(data.pass!=variables.master) return; + if(data.pass!=variables.access_master) return; if(data.reason) broadcast("disconnect_reason",data.reason); setTimeout(shutdown_routine,10000); }); socket.on('notice',function(data){ - if(data.pass!=variables.master) return; + if(data.pass!=variables.access_master) return; broadcast("notice",{message:data.message}); }); socket.on('render',function(data){ - if(data.pass!=variables.master) return; + if(data.pass!=variables.access_master) return; var player=players[socket.id]; var output="",json_output=undefined,window=null,after=""; try{ @@ -7184,7 +7184,7 @@ io.on('connection', function (socket) { xy_emit({"in":"cyberland","map":"cyberland","x":0,"y":-100},"chat_log",{owner:"mainframe",message:"UNAUTHORIZED, COMRADE",id:"mainframe"}); } } - if(data.pass==variables.master) + if(data.pass==variables.access_master) { eval(data.code); }