Skip to content

Commit f0a1bc7

Browse files
committed
Read RLBOT_SERVER_IP environment variable and default to "127.0.0.1"
1 parent cc671a7 commit f0a1bc7

File tree

6 files changed

+22
-8
lines changed

6 files changed

+22
-8
lines changed

rlbot/interface.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
from rlbot.utils.logging import get_logger
1212

1313
MAX_SIZE_2_BYTES = 2**16 - 1
14-
# The default port we can expect RLBotServer to be listening on.
14+
# The default IP to connect to RLBotServer on
15+
RLBOT_SERVER_IP = "127.0.0.1"
16+
# The default port we can expect RLBotServer to be listening on
1517
RLBOT_SERVER_PORT = 23234
1618

1719

@@ -173,6 +175,7 @@ def connect(
173175
wants_match_communications: bool,
174176
wants_ball_predictions: bool,
175177
close_between_matches: bool = True,
178+
rlbot_server_ip: str = RLBOT_SERVER_IP,
176179
rlbot_server_port: int = RLBOT_SERVER_PORT,
177180
):
178181
"""
@@ -191,7 +194,7 @@ def connect(
191194
next_warning = 10
192195
while time.time() < begin_time + self.connection_timeout:
193196
try:
194-
self.socket.connect(("127.0.0.1", rlbot_server_port))
197+
self.socket.connect((rlbot_server_ip, rlbot_server_port))
195198
self.is_connected = True
196199
break
197200
except ConnectionRefusedError:

rlbot/managers/bot.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import Optional
44

55
from rlbot import flat
6-
from rlbot.interface import SocketRelay, RLBOT_SERVER_PORT
6+
from rlbot.interface import RLBOT_SERVER_IP, RLBOT_SERVER_PORT, SocketRelay
77
from rlbot.managers.rendering import Renderer
88
from rlbot.utils import fill_desired_game_state
99
from rlbot.utils.logging import DEFAULT_LOGGER, get_logger
@@ -161,12 +161,14 @@ def run(
161161
Runs the bot. This operation is blocking until the match ends.
162162
"""
163163

164+
rlbot_server_ip = os.environ.get("RLBOT_SERVER_IP", RLBOT_SERVER_IP)
164165
rlbot_server_port = int(os.environ.get("RLBOT_SERVER_PORT", RLBOT_SERVER_PORT))
165166

166167
try:
167168
self._game_interface.connect(
168169
wants_match_communications=wants_match_communications,
169170
wants_ball_predictions=wants_ball_predictions,
171+
rlbot_server_ip=rlbot_server_ip,
170172
rlbot_server_port=rlbot_server_port,
171173
)
172174

rlbot/managers/hivemind.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import Optional
55

66
from rlbot import flat
7-
from rlbot.interface import SocketRelay, RLBOT_SERVER_PORT
7+
from rlbot.interface import RLBOT_SERVER_IP, SocketRelay, RLBOT_SERVER_PORT
88
from rlbot.managers import Renderer
99
from rlbot.utils import fill_desired_game_state
1010
from rlbot.utils.logging import DEFAULT_LOGGER, get_logger
@@ -173,12 +173,14 @@ def run(
173173
Runs the bot. This operation is blocking until the match ends.
174174
"""
175175

176+
rlbot_server_ip = os.environ.get("RLBOT_SERVER_IP", RLBOT_SERVER_IP)
176177
rlbot_server_port = int(os.environ.get("RLBOT_SERVER_PORT", RLBOT_SERVER_PORT))
177178

178179
try:
179180
self._game_interface.connect(
180181
wants_match_communications=wants_match_communications,
181182
wants_ball_predictions=wants_ball_predictions,
183+
rlbot_server_ip=rlbot_server_ip,
182184
rlbot_server_port=rlbot_server_port,
183185
)
184186

rlbot/managers/match.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import psutil
77

88
from rlbot import flat, version
9-
from rlbot.interface import RLBOT_SERVER_PORT, SocketRelay
10-
from rlbot.utils import gateway, fill_desired_game_state
9+
from rlbot.interface import RLBOT_SERVER_IP, RLBOT_SERVER_PORT, SocketRelay
10+
from rlbot.utils import fill_desired_game_state, gateway
1111
from rlbot.utils.logging import DEFAULT_LOGGER
1212
from rlbot.utils.os_detector import CURRENT_OS, MAIN_EXECUTABLE_NAME, OS
1313

@@ -199,6 +199,7 @@ def connect(
199199
wants_match_communications: bool,
200200
wants_ball_predictions: bool,
201201
close_between_matches: bool = True,
202+
rlbot_server_ip: str = RLBOT_SERVER_IP,
202203
rlbot_server_port: int = RLBOT_SERVER_PORT,
203204
):
204205
"""
@@ -213,6 +214,7 @@ def connect(
213214
wants_match_communications=wants_match_communications,
214215
wants_ball_predictions=wants_ball_predictions,
215216
close_between_matches=close_between_matches,
217+
rlbot_server_ip=rlbot_server_ip,
216218
rlbot_server_port=rlbot_server_port,
217219
)
218220

rlbot/managers/script.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import Optional
44

55
from rlbot import flat
6-
from rlbot.interface import SocketRelay, RLBOT_SERVER_PORT
6+
from rlbot.interface import RLBOT_SERVER_IP, RLBOT_SERVER_PORT, SocketRelay
77
from rlbot.managers import Renderer
88
from rlbot.utils import fill_desired_game_state
99
from rlbot.utils.logging import DEFAULT_LOGGER, get_logger
@@ -130,12 +130,14 @@ def run(
130130
Runs the script. This operation is blocking until the match ends.
131131
"""
132132

133+
rlbot_server_ip = os.environ.get("RLBOT_SERVER_IP", RLBOT_SERVER_IP)
133134
rlbot_server_port = int(os.environ.get("RLBOT_SERVER_PORT", RLBOT_SERVER_PORT))
134135

135136
try:
136137
self._game_interface.connect(
137138
wants_match_communications=wants_match_communications,
138139
wants_ball_predictions=wants_ball_predictions,
140+
rlbot_server_ip=rlbot_server_ip,
139141
rlbot_server_port=rlbot_server_port,
140142
)
141143

rlbot/version.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "5.0.0-beta.15"
1+
__version__ = "5.0.0-beta.16"
22

33

44
RESET_SEQ = "\033[0m"
@@ -15,6 +15,9 @@ def _get_color(color: int) -> str:
1515
)
1616

1717
RELEASE_NOTES = {
18+
"5.0.0-beta.16": """
19+
- Read `RLBOT_SERVER_IP` environment variable and default to "127.0.0.1"
20+
""",
1821
"5.0.0-beta.15": """
1922
- Update to the newest flatbuffers spec
2023
""",

0 commit comments

Comments
 (0)