summaryrefslogtreecommitdiff
path: root/client/service
diff options
context:
space:
mode:
authornokoe <nokoe@mailbox.org>2025-07-08 00:08:18 +0200
committernokoe <nokoe@mailbox.org>2025-07-08 00:10:03 +0200
commitf1ac43aaac6f330fc8e7217437b52c0b2ce836c8 (patch)
tree93f878387d56230c344da60aa14121f7787a7fd1 /client/service
parentac1ecb0876d57d73cee54127f5ba793095808b92 (diff)
downloadhurrycurry-f1ac43aaac6f330fc8e7217437b52c0b2ce836c8.tar
hurrycurry-f1ac43aaac6f330fc8e7217437b52c0b2ce836c8.tar.bz2
hurrycurry-f1ac43aaac6f330fc8e7217437b52c0b2ce836c8.tar.zst
add server bind settings; fixes #348
Diffstat (limited to 'client/service')
-rw-r--r--client/service/server.gd15
-rw-r--r--client/service/service.gd5
2 files changed, 18 insertions, 2 deletions
diff --git a/client/service/server.gd b/client/service/server.gd
index b2db04de..0c656c10 100644
--- a/client/service/server.gd
+++ b/client/service/server.gd
@@ -33,6 +33,8 @@ func arguments():
args.push_back("--upnp")
if Global.get_setting("server.register"):
args.push_back("--register")
+ args.push_back("--listen")
+ args.push_back("%s:%d" % [bind_address(), Global.get_setting("server.bind_port")])
return args
func exe_path() -> String:
@@ -41,4 +43,15 @@ func exe_path() -> String:
else: return "hurrycurry-server"
func test_port():
- return 27032
+ return Global.get_setting("server.bind_port")
+func test_host():
+ return "::1" if Global.get_setting("server.enable_ipv6") else "127.0.0.1"
+
+static func bind_address() -> String:
+ if Global.get_setting("server.allow_external_connections"):
+ return "[::]" if Global.get_setting("server.enable_ipv6") else "0.0.0.0"
+ else:
+ return connect_address()
+
+static func connect_address() -> String:
+ return "[::1]" if Global.get_setting("server.enable_ipv6") else "127.0.0.1"
diff --git a/client/service/service.gd b/client/service/service.gd
index 9695714f..d06ad364 100644
--- a/client/service/service.gd
+++ b/client/service/service.gd
@@ -27,6 +27,9 @@ func exe_path():
return "false"
func test_port():
return 25565
+func test_host():
+ return "127.0.0.1"
+
var thread = null
var pid = null
@@ -82,7 +85,7 @@ func _server_exec():
var ok = false
while not ok:
var conn = StreamPeerTCP.new()
- if conn.connect_to_host("127.0.0.1", test_port()) == OK:
+ if conn.connect_to_host(test_host(), test_port()) == OK:
while conn.poll() == OK:
if conn.get_status() == StreamPeerTCP.STATUS_ERROR: break
elif conn.get_status() == StreamPeerTCP.STATUS_CONNECTED: ok = true; break