feat: updated engine version to 4.4-rc1

This commit is contained in:
Sara 2025-02-23 14:38:14 +01:00
parent ee00efde1f
commit 21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions

View file

@ -30,119 +30,7 @@
#include "upnp_device.h"
#include "upnp.h"
#include <upnpcommands.h>
String UPNPDevice::query_external_address() const {
ERR_FAIL_COND_V_MSG(!is_valid_gateway(), "", "The Internet Gateway Device must be valid.");
char addr[16];
int i = UPNP_GetExternalIPAddress(
igd_control_url.utf8().get_data(),
igd_service_type.utf8().get_data(),
(char *)&addr);
ERR_FAIL_COND_V_MSG(i != UPNPCOMMAND_SUCCESS, "", "Couldn't get external IP address.");
return String(addr);
}
int UPNPDevice::add_port_mapping(int port, int port_internal, String desc, String proto, int duration) const {
ERR_FAIL_COND_V_MSG(!is_valid_gateway(), UPNP::UPNP_RESULT_INVALID_GATEWAY, "The Internet Gateway Device must be valid.");
ERR_FAIL_COND_V_MSG(port < 1 || port > 65535, UPNP::UPNP_RESULT_INVALID_PORT, "The port number must be set between 1 and 65535 (inclusive).");
ERR_FAIL_COND_V_MSG(port_internal < 0 || port_internal > 65535, UPNP::UPNP_RESULT_INVALID_PORT, "The port number must be set between 0 and 65535 (inclusive)."); // Needs to allow 0 because 0 signifies "use external port as internal port"
ERR_FAIL_COND_V_MSG(proto != "UDP" && proto != "TCP", UPNP::UPNP_RESULT_INVALID_PROTOCOL, "The protocol must be either TCP or UDP.");
ERR_FAIL_COND_V_MSG(duration < 0, UPNP::UPNP_RESULT_INVALID_DURATION, "The port mapping's lease duration can't be negative.");
if (port_internal < 1) {
port_internal = port;
}
int i = UPNP_AddPortMapping(
igd_control_url.utf8().get_data(),
igd_service_type.utf8().get_data(),
itos(port).utf8().get_data(),
itos(port_internal).utf8().get_data(),
igd_our_addr.utf8().get_data(),
desc.is_empty() ? nullptr : desc.utf8().get_data(),
proto.utf8().get_data(),
nullptr, // Remote host, always nullptr as IGDs don't support it
duration > 0 ? itos(duration).utf8().get_data() : nullptr);
ERR_FAIL_COND_V_MSG(i != UPNPCOMMAND_SUCCESS, UPNP::upnp_result(i), "Couldn't add port mapping.");
return UPNP::UPNP_RESULT_SUCCESS;
}
int UPNPDevice::delete_port_mapping(int port, String proto) const {
ERR_FAIL_COND_V_MSG(port < 1 || port > 65535, UPNP::UPNP_RESULT_INVALID_PORT, "The port number must be set between 1 and 65535 (inclusive).");
ERR_FAIL_COND_V_MSG(proto != "UDP" && proto != "TCP", UPNP::UPNP_RESULT_INVALID_PROTOCOL, "The protocol must be either TCP or UDP.");
int i = UPNP_DeletePortMapping(
igd_control_url.utf8().get_data(),
igd_service_type.utf8().get_data(),
itos(port).utf8().get_data(),
proto.utf8().get_data(),
nullptr // Remote host, always nullptr as IGDs don't support it
);
ERR_FAIL_COND_V_MSG(i != UPNPCOMMAND_SUCCESS, UPNP::upnp_result(i), "Couldn't delete port mapping.");
return UPNP::UPNP_RESULT_SUCCESS;
}
void UPNPDevice::set_description_url(const String &url) {
description_url = url;
}
String UPNPDevice::get_description_url() const {
return description_url;
}
void UPNPDevice::set_service_type(const String &type) {
service_type = type;
}
String UPNPDevice::get_service_type() const {
return service_type;
}
void UPNPDevice::set_igd_control_url(const String &url) {
igd_control_url = url;
}
String UPNPDevice::get_igd_control_url() const {
return igd_control_url;
}
void UPNPDevice::set_igd_service_type(const String &type) {
igd_service_type = type;
}
String UPNPDevice::get_igd_service_type() const {
return igd_service_type;
}
void UPNPDevice::set_igd_our_addr(const String &addr) {
igd_our_addr = addr;
}
String UPNPDevice::get_igd_our_addr() const {
return igd_our_addr;
}
void UPNPDevice::set_igd_status(IGDStatus status) {
igd_status = status;
}
UPNPDevice::IGDStatus UPNPDevice::get_igd_status() const {
return igd_status;
}
bool UPNPDevice::is_valid_gateway() const {
return igd_status == IGD_STATUS_OK;
}
UPNPDevice *(*UPNPDevice::_create)(bool p_notify_postinitialize) = nullptr;
void UPNPDevice::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_valid_gateway"), &UPNPDevice::is_valid_gateway);
@ -185,15 +73,3 @@ void UPNPDevice::_bind_methods() {
BIND_ENUM_CONSTANT(IGD_STATUS_MALLOC_ERROR);
BIND_ENUM_CONSTANT(IGD_STATUS_UNKNOWN_ERROR);
}
UPNPDevice::UPNPDevice() {
description_url = "";
service_type = "";
igd_control_url = "";
igd_service_type = "";
igd_our_addr = "";
igd_status = IGD_STATUS_UNKNOWN_ERROR;
}
UPNPDevice::~UPNPDevice() {
}