Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

UPNPDevice

继承: RefCounted < Object

通用即插即用(UPnP)设备。

描述

通用即插即用(UPnP)设备。UPnP 发现及工具函数见 UPNP。提供对 UPNP 控制命令的低层访问。允许管理端口映射(端口转发)和查询设备的网络信息(如本地和外部 IP 地址和状态)。请注意,这个类的方法是同步的,会阻塞调用线程。

属性

String

description_url

""

String

igd_control_url

""

String

igd_our_addr

""

String

igd_service_type

""

IGDStatus

igd_status

9

String

service_type

""

方法

int

add_port_mapping ( int port, int port_internal=0, String desc="", String proto="UDP", int duration=0 ) const

int

delete_port_mapping ( int port, String proto="UDP" ) const

bool

is_valid_gateway ( ) const

String

query_external_address ( ) const


枚举

enum IGDStatus:

IGDStatus IGD_STATUS_OK = 0

OK。

IGDStatus IGD_STATUS_HTTP_ERROR = 1

HTTP 错误。

IGDStatus IGD_STATUS_HTTP_EMPTY = 2

空的 HTTP 响应。

IGDStatus IGD_STATUS_NO_URLS = 3

返回的响应不包含任何 URL。

IGDStatus IGD_STATUS_NO_IGD = 4

不是有效的 IGD。

IGDStatus IGD_STATUS_DISCONNECTED = 5

已断开连接。

IGDStatus IGD_STATUS_UNKNOWN_DEVICE = 6

未知设备。

IGDStatus IGD_STATUS_INVALID_CONTROL = 7

无效控制。

IGDStatus IGD_STATUS_MALLOC_ERROR = 8

内存分配错误。

IGDStatus IGD_STATUS_UNKNOWN_ERROR = 9

未知错误。


属性说明

String description_url = ""

  • void set_description_url ( String value )

  • String get_description_url ( )

设备描述的 URL。


String igd_control_url = ""

  • void set_igd_control_url ( String value )

  • String get_igd_control_url ( )

IDG 控件 URL。


String igd_our_addr = ""

  • void set_igd_our_addr ( String value )

  • String get_igd_our_addr ( )

将其连接到该 UPNPDevice 的网络中的本地机器的地址。


String igd_service_type = ""

  • void set_igd_service_type ( String value )

  • String get_igd_service_type ( )

IGD 服务类型。


IGDStatus igd_status = 9

IGD 状态。见 IGDStatus


String service_type = ""

  • void set_service_type ( String value )

  • String get_service_type ( )

服务类型。


方法说明

int add_port_mapping ( int port, int port_internal=0, String desc="", String proto="UDP", int duration=0 ) const

添加一个端口映射,将这个 UPNPDevice 上给定的外部端口转发到本地机器上,以给定的协议。见 UPNP.add_port_mapping


int delete_port_mapping ( int port, String proto="UDP" ) const

删除该设备上由给定的端口和协议组合确定的端口映射。见 UPNP.delete_port_mapping


bool is_valid_gateway ( ) const

如果这是一个有效的 IGD(InternetGatewayDevice),可能支持端口转发,则返回 true


String query_external_address ( ) const

返回这个 UPNPDevice 的外部 IP 地址或空字符串。