Secrets refactoring

This commit is contained in:
Kaan Soral
2023-10-28 14:32:43 +03:00
parent f59bc4c02e
commit 41f39fd233
4 changed files with 26 additions and 17 deletions
Vendored
BIN
View File
Binary file not shown.
+19 -11
View File
@@ -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:
+1
View File
@@ -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
+6 -6
View File
@@ -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);
}