Port forwarding

This commit is contained in:
Rendo 2025-12-10 20:08:35 +05:00
commit fc984d6b45
6 changed files with 56 additions and 1 deletions

View file

@ -0,0 +1,24 @@
extends Button
func _pressed() -> void:
var upnp = UPNP.new()
var discover_error = upnp.discover()
if discover_error != UPNP.UPNPResult.UPNP_RESULT_SUCCESS:
Lobby.update_ip.emit("Discover error: " + str(discover_error as UPNP.UPNPResult))
return
var error_udp = upnp.add_port_mapping(Lobby.PORT)
if error_udp != UPNP.UPNPResult.UPNP_RESULT_SUCCESS:
Lobby.update_ip.emit("UDP forward error: " + str(error_udp as UPNP.UPNPResult))
return
var error_tcp = upnp.add_port_mapping(Lobby.PORT,0,"","TCP")
if error_tcp != UPNP.UPNPResult.UPNP_RESULT_SUCCESS:
Lobby.update_ip.emit("TCP forward error: " + str(error_tcp as UPNP.UPNPResult))
return
Lobby.update_ip.emit(upnp.query_external_address())