diff --git a/.gitignore b/.gitignore
index a1bc87bc..1dbcd7b4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
/secrets.py
+/environment.py
/node/live_variables.js
/node/variables.js
/stack/
diff --git a/README.md b/README.md
index 394c2ae6..516707df 100644
--- a/README.md
+++ b/README.md
@@ -27,6 +27,7 @@ git clone https://github.com/kaansoral/adventureland-appserver appserver
Set up secrets files and remember to change secret keys!
```sh
+cp adventureland/useful/template.environment.py adventureland/environment.py
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
diff --git a/api.py b/api.py
index 8a44cb4b..d41298d5 100644
--- a/api.py
+++ b/api.py
@@ -1,5 +1,6 @@
from config import *
from functions import *
+import environment
def signup_or_login_api(**args):
#time.sleep(10)
@@ -1494,7 +1495,13 @@ def create_server_api(**args):
self,domain,keyword,port,region,pvp,gameplay,sname=gdmuld(args,"self","domain","keyword","port","region","pvp","gameplay","name")
if keyword!=secrets.SERVER_MASTER: jhtml(self,{"failed":1}); return
actual_ip=ip=request.remote_addr; server_name="XX"
- if is_sdk: actual_ip=ip=domain.server_ip
+ if is_sdk:
+ # The ip we store should be the url the client needs to use
+ ip = "%s"%(environment.REQUEST_IP_TO_HOSTNAME.get(ip,ip))
+ # If we are not running in HTTPS_MODE servers_to_client will use actual_ip instead
+ actual_ip = ip
+
+ # TODO: makes an ip like eu1.adventure.land, this is hardcoded and should be changed
if domain.https_mode: ip="%s.%s"%(ip_to_subdomain.get(ip,ip),live_domain)
lat,lon=(request.headers.get("X-Appengine-Citylatlong")or"0,0").split(",")
try: lat,lon=float(lat),float(lon)
diff --git a/config.py b/config.py
index 0727b405..4f8c733f 100644
--- a/config.py
+++ b/config.py
@@ -66,6 +66,7 @@ def __getattr__(self,*d,**f):
class GG(): pass
import secrets
+import environment
from libraries.country_to_latlon import c_to_ll
#from libraries import get_image_size
@@ -120,25 +121,14 @@ class GG(): pass
"Last Update [April 25th]",
"Cost reduction trial"
]
-ip_to_subdomain={ #IMPORTANT: SPECIAL PAGE RULES ARE NEEDED: https://dash.cloudflare.com/b6f5a13bded5fdd273e4a1cd3777162d/adventure.land/page-rules - uss1 / eus1 was best
- "35.187.255.184":"asia1",
- "35.246.244.105":"eu1",
- "35.228.96.241":"eu2",
- "35.234.72.136":"eupvp",
- "35.184.37.35":"us1",
- "34.67.188.57":"us2",
- "34.75.5.124":"us3",
- "34.67.187.11":"uspvp",
- "195.201.181.245":"eud1",
- "158.69.23.127":"usd1",
-}
+ip_to_subdomain=environment.IP_TO_SUBDOMAIN
HTTPS_MODE=True #IMPORTANT: converts server IP's to subdomain urls at create_server_api [17/11/18]
always_amazon_ses=True
SCREENSHOT_MODE=is_sdk and False
-game_name="Adventure Land"
-appengine_id="twodimensionalgame"
-live_domain='adventure.land'
-sdk_domain='thegame.com'
+game_name=environment.GAME_NAME
+appengine_id=environment.APPENGINE_ID
+live_domain=environment.DOMAIN_NAME
+sdk_domain=environment.DOMAIN_NAME
SDK_UPLOAD_PASSWORD=ELEMENT_PASSWORD=secrets.sdk_password
def init_request(request):
@@ -161,7 +151,7 @@ def gdi(request=None):
domain.base_url=protocol + "://" + hostname
domain.pref_url=domain.base_url
- domain.server_ip="192.168.1.125"
+ # domain.server_ip="192.168.1.125" # See environment.py
domain.stripe_pkey=stripe_pkey
domain.stripe_enabled=False
domain.https_mode=False
@@ -180,7 +170,7 @@ def gdi(request=None):
domain.ip_to_subdomain=ip_to_subdomain
domain.https=False
domain.secure_base_url=domain.base_url.replace("http://","https://")
- domain.discord_url="https://discord.gg/44yUVeU"
+ domain.discord_url=secrets.DISCORD["URL"]["WELCOME"]
domain.is_sdk=is_sdk
domain.io_version="4.2.0" #upgraded from 1.4.5 now [18/03/17] upgraded from 1.7.2 now [31/12/17] upgraded from 2.1.0 now [20/06/19] 2.3.0 [28/06/20] 4.0.0 [18/03/21]
domain.cm_version="5.65.1"
diff --git a/htmls/contents/guide.html b/htmls/contents/guide.html
index 986325e3..3a458b84 100644
--- a/htmls/contents/guide.html
+++ b/htmls/contents/guide.html
@@ -43,7 +43,7 @@
> For accessories, reaching a higher level is more challenging, for an +1 accessory, you need 3x +0 accessories of the same kind, and so on.
> You can use "Primordial Shard"s increase the chances of success of both upgrades and compounds, the essence of the shard is absorbed inside the item.
Communities | Links
- > Discord: Discord is our most active community, ideal for questions of all kinds and to provide feedback, suggest new ideas. The coding channels are also quite useful.
+ > Discord: Discord is our most active community, ideal for questions of all kinds and to provide feedback, suggest new ideas. The coding channels are also quite useful.
> Github: Our Official Github houses the "runner_functions.js" - which includes all the base CODE functions
> Reddit: You can use Reddit to share things, Discord is more practical for asking quick questions
diff --git a/htmls/contents/section_buttons.html b/htmls/contents/section_buttons.html
index 304c88f5..4761b51a 100644
--- a/htmls/contents/section_buttons.html
+++ b/htmls/contents/section_buttons.html
@@ -1,7 +1,7 @@
{% if buttons=="essentials" %}
Docs
- Discord!
+ Discord!
{% endif %}
{% if buttons=="musts" %}
{# Terms
diff --git a/htmls/page.html b/htmls/page.html
index 6e822d4d..cf01c19f 100644
--- a/htmls/page.html
+++ b/htmls/page.html
@@ -15,7 +15,7 @@
{% elif content=="contact"%}
You can always email me at hello@adventure.land
- Also check out our Discord! - You can PM Wizard on Discord for faster and more informal replies :)
+ Also check out our Discord! - You can PM Wizard on Discord for faster and more informal replies :)
{%endif%}
diff --git a/js/game.js b/js/game.js
index a53515ac..2a4e7548 100644
--- a/js/game.js
+++ b/js/game.js
@@ -1149,16 +1149,15 @@ function init_socket(args)
window.socket.destroy();
}
$(".disconnected").hide();
- if(is_sdk && (Cookies.get("windows") || Cookies.get("local_ip") || window.location.host=="advanture.land" || window.location.host=="x.thegame.com")) server_addr="192.168.1.125"; // Cookies.set('windows','1',{expires:12*365});
- else if(is_sdk)
- {
- if(window.location.origin=='http://127.0.0.1/') server_addr="127.0.0.1";
- else server_addr="0.0.0.0";
+
+ add_log("Connecting to the server.");
+ if (is_sdk) {
+ add_log(`${location.protocol} ${server_addr} ${server_port}`);
}
+
var query=args.secret&&"desktop="+(!is_comm&&1||"")+"&secret="+args.secret||undefined;
if(location.protocol=="https:") window.socket=io('wss://'+server_addr+':'+server_port,{secure:true,transports:['websocket'],query:query});
- else window.socket=io(server_addr+':'+server_port,{transports:['websocket'],query:query});
- add_log("Connecting to the server.");
+ else window.socket=io('ws://'+server_addr+':'+server_port,{transports:['websocket'],query:query});
socket_ready=false; socket_welcomed=false; observing=null; $("#observeui").hide();
original_onevent=socket.onevent;
original_emit=socket.emit;
diff --git a/node/server.js b/node/server.js
index 3d396a24..bb0f7c6a 100644
--- a/node/server.js
+++ b/node/server.js
@@ -167,6 +167,8 @@ var mode = {
prevent_external: 0, // for "test" / "hardcore"
pvp_level_gap: 0, // have to be within 10 level to attack
};
+// Override default settings
+mode = { ...mode, ...variables.MODE };
var events = {
// SEASONS
holidayseason: false,
@@ -9646,10 +9648,12 @@ function init_io() {
// player.vision[1]=min(700,player.vision[1]);
player.vision = B.vision;
- if (!player.verified) {
- player.s.notverified = { ms: 30 * 60 * 1000 };
- } else if (player.s.notverified) {
- player.s.notverified = { ms: 100 };
+ if (mode.notverified_debuff) {
+ if (!player.verified) {
+ player.s.notverified = { ms: 30 * 60 * 1000 };
+ } else if (player.s.notverified) {
+ player.s.notverified = { ms: 100 };
+ }
}
if (player.guild) {
diff --git a/node/server_functions.js b/node/server_functions.js
index d221f440..f8d2f804 100644
--- a/node/server_functions.js
+++ b/node/server_functions.js
@@ -3270,27 +3270,34 @@ function appengine_call(method, args, on_success, on_error) {
}
function discord_call(message) {
+ // TODO: should it not post to the channel either way? I vote to remove this return
if (gameplay == "hardcore" || gameplay == "test") {
return;
}
+
if (is_sdk) {
- return server_log("Discord: " + message);
+ server_log("Discord: " + message);
}
- var url = "https://discordapp.com/api/channels/404333059018719233/messages";
+
+ if (!variables.DISCORD.ENABLED) {
+ return;
+ }
+
+ var url = variables.DISCORD.EVENT_CHANNELS.DEFAULT; // #game_events
if (message.search(" joined Adventure Land") != -1) {
- url = "https://discordapp.com/api/channels/839163123499794481/messages";
+ url = variables.DISCORD.EVENT_CHANNELS.NEW_PLAYER; // #new_players
}
request(
{
url: url,
- headers: { Authorization: "Bot " + variables.discord_token },
+ headers: { Authorization: "Bot " + variables.DISCORD.TOKEN },
method: "POST",
json: {
content: message,
},
},
function (err, response, body) {
- //console.log(response);
+ console.log(err, response);
},
);
}
diff --git a/useful/template.environment.py b/useful/template.environment.py
new file mode 100644
index 00000000..b2c3fa80
--- /dev/null
+++ b/useful/template.environment.py
@@ -0,0 +1,22 @@
+GAME_NAME = "Adventure Land"
+APPENGINE_ID = "twodimensionalgame"
+DOMAIN_NAME = "adventure.land"
+#IMPORTANT: SPECIAL PAGE RULES ARE NEEDED: https://dash.cloudflare.com/b6f5a13bded5fdd273e4a1cd3777162d/adventure.land/page-rules - uss1 / eus1 was best
+IP_TO_SUBDOMAIN = {
+ "35.187.255.184":"asia1",
+ "35.246.244.105":"eu1",
+ "35.228.96.241":"eu2",
+ "35.234.72.136":"eupvp",
+ "35.184.37.35":"us1",
+ "34.67.188.57":"us2",
+ "34.75.5.124":"us3",
+ "34.67.187.11":"uspvp",
+ "195.201.181.245":"eud1",
+ "158.69.23.127":"usd1"
+}
+
+# This is currently only used in SDK mode to map the hostname
+REQUEST_IP_TO_HOSTNAME = {
+ "172.20.0.4":"localhost", #EU1 docker internal ip
+ "172.20.0.3":"localhost", #US1 docker internal ip
+}
\ No newline at end of file
diff --git a/useful/template.live_variables.js b/useful/template.live_variables.js
index c622edd9..b9e6e33d 100644
--- a/useful/template.live_variables.js
+++ b/useful/template.live_variables.js
@@ -1,18 +1,25 @@
module.exports = {
- cfunctions_path: "./server/common_functions.js",
- functions_path: "./server/server_functions.js",
- worker_path: "./server/server_worker.js",
- data_path: "./server/data.js",
- base_url: "https://yourappspoturldontincludedashes.appspot.com",
- keyword: "123",
- access_master: "123",
- bot_key: "123",
- discord_token: "NDXXXXXXXXXXX...",
- apple_token: "acXXXXXXXX...",
- steam_key: "8aXXXXXXXXX...",
- steam_web_key: "B4XXXXXXX...",
- steam_partner_key: "F9XXXXXXX...",
- close_timeout: 24000,
- ip_limit: 3,
- character_limit: 3,
+ cfunctions_path: "./server/common_functions.js",
+ functions_path: "./server/server_functions.js",
+ worker_path: "./server/server_worker.js",
+ data_path: "./server/data.js",
+ base_url: "https://yourappspoturldontincludedashes.appspot.com",
+ keyword: "123",
+ access_master: "123",
+ bot_key: "123",
+ apple_token: "acXXXXXXXX...",
+ steam_key: "8aXXXXXXXXX...",
+ steam_web_key: "B4XXXXXXX...",
+ steam_partner_key: "F9XXXXXXX...",
+ close_timeout: 24000,
+ ip_limit: 3,
+ character_limit: 3,
+ DISCORD: {
+ ENABLED: false,
+ TOKEN: "NDXXXXXXXXXXX",
+ EVENT_CHANNELS: {
+ DEFAULT: "https://discordapp.com/api/channels/404333059018719233/messages",
+ NEW_PLAYER: "https://discordapp.com/api/channels/839163123499794481/messages",
+ },
+ },
};
diff --git a/useful/template.secrets.py b/useful/template.secrets.py
index 54564a12..9896902d 100644
--- a/useful/template.secrets.py
+++ b/useful/template.secrets.py
@@ -19,3 +19,10 @@
ssh-keygen -o #Doesn't work
ssh-keygen -t rsa -b 4096
"""
+
+# Discord
+DISCORD = {
+ "URL": {
+ "WELCOME": "https://discord.gg/44yUVeU"
+ },
+}
diff --git a/useful/template.variables.js b/useful/template.variables.js
index c44d4616..ed9c4e89 100644
--- a/useful/template.variables.js
+++ b/useful/template.variables.js
@@ -1,22 +1,35 @@
const path = require("node:path");
module.exports = {
- cfunctions_path: path.resolve(__dirname, "../js/common_functions.js"),
- functions_path: path.resolve(__dirname, "server_functions.js"),
- worker_path: path.resolve(__dirname, "server_worker.js"),
- data_path: path.resolve(__dirname, "data.js"),
- base_url: "http://thegame.com",
- keyword: "123",
- access_master: "123",
- bot_key: "123",
- discord_token: "NDXXXXXXXXXXX...",
- apple_token: "acXXXXXXXX...",
- steam_key: "8aXXXXXXXXX...",
- steam_web_key: "B4XXXXXXX...",
- steam_partner_key: "F9XXXXXXX...",
- is_sdk: 1,
- close_timeout: 4000,
- ip_limit: 3,
- character_limit: 3,
- fast_sdk: 0,
+ cfunctions_path: path.resolve(__dirname, "../js/common_functions.js"),
+ functions_path: path.resolve(__dirname, "server_functions.js"),
+ worker_path: path.resolve(__dirname, "server_worker.js"),
+ data_path: path.resolve(__dirname, "data.js"),
+ base_url: "http://thegame.com",
+ keyword: "123",
+ access_master: "123",
+ bot_key: "123",
+ apple_token: "acXXXXXXXX...",
+ steam_key: "8aXXXXXXXXX...",
+ steam_web_key: "B4XXXXXXX...",
+ steam_partner_key: "F9XXXXXXX...",
+ is_sdk: 1,
+ close_timeout: 4000,
+ ip_limit: 3,
+ character_limit: 3,
+ fast_sdk: 0,
+ DISCORD: {
+ ENABLED: false,
+ TOKEN: "NDXXXXXXXXXXX", // Your discord applications bot token
+ EVENT_CHANNELS: {
+ DEFAULT: "https://discordapp.com/api/channels/404333059018719233/messages", // #game_events
+ NEW_PLAYER: "https://discordapp.com/api/channels/839163123499794481/messages", // #new_players
+ },
+ },
+
+ // mode variable in server.js can be overridden here
+ MODE: {
+ drm_check: 0, // Enable steam/mac DRM check, prevents authfail debuff being added if disabled
+ notverified_debuff: 0, // disables the debuff for not being verified
+ },
};