Skip to content

Commit

Permalink
Map servers by region and server name EUI instead of ip due to dock…
Browse files Browse the repository at this point in the history
…er changing internal ip at will
  • Loading branch information
thmsndk committed Aug 13, 2024
1 parent 6c18af3 commit 3455645
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 3 additions & 1 deletion api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1497,9 +1497,11 @@ def create_server_api(**args):
actual_ip=ip=request.remote_addr; server_name="XX"
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))
mappingKey = "%s%s"%(region,sname)
ip = "%s"%(environment.CREATE_SERVER_MAPPING.get(mappingKey,ip))
# If we are not running in HTTPS_MODE servers_to_client will use actual_ip instead
actual_ip = ip
logging.info("create_server_api: sname: %s region:%s %s %s"%(sname,region,ip,actual_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)
Expand Down
12 changes: 8 additions & 4 deletions useful/template.environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
"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
# This is responsible for mapping the correct ip/domain that the client should use to connect with in the websocket
CREATE_SERVER_MAPPING = {

# example of how thmsn.adventureland.community works
# "EUI": "eu1.thmsn.adventureland.community"

# When running a local test server on your private machine
"EUI": "localhost"
}

0 comments on commit 3455645

Please sign in to comment.