Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This snippet checks if the router is available to port forward using Godot's RPC system
extends Node2D
func _ready():
var port = 12345
var upnp =
for i in range(upnp.get_device_count()):
var upnp_device = upnp.get_device(i)
print('- igd_our_addr: ', upnp_device.igd_our_addr)
print('- igd_service_type: ', upnp_device.igd_service_type)
print('- igd_status: ', upnp_device.igd_status)
print('- service_type: ', upnp_device.service_type)
print('gateway:', upnp.get_gateway())
if upnp.get_gateway() and upnp.get_gateway().is_valid_gateway():
var res_udp = upnp.add_port_mapping(port, port, 'Godot', 'UDP')
var res_tcp = upnp.add_port_mapping(port, port, 'Godot', 'TCP')
print('res_udp:', res_udp)
print('res_tcp:', res_tcp)
print('no valid gateway')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.