IP.xml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="IP" inherits="Object" version="4.0">
  3. <brief_description>
  4. Internet protocol (IP) support functions such as DNS resolution.
  5. </brief_description>
  6. <description>
  7. IP contains support functions for the Internet Protocol (IP). TCP/IP support is in different classes (see [StreamPeerTCP] and [TCPServer]). IP provides DNS hostname resolution support, both blocking and threaded.
  8. </description>
  9. <tutorials>
  10. </tutorials>
  11. <methods>
  12. <method name="clear_cache">
  13. <return type="void" />
  14. <argument index="0" name="hostname" type="String" default="&quot;&quot;" />
  15. <description>
  16. Removes all of a [code]hostname[/code]'s cached references. If no [code]hostname[/code] is given, all cached IP addresses are removed.
  17. </description>
  18. </method>
  19. <method name="erase_resolve_item">
  20. <return type="void" />
  21. <argument index="0" name="id" type="int" />
  22. <description>
  23. Removes a given item [code]id[/code] from the queue. This should be used to free a queue after it has completed to enable more queries to happen.
  24. </description>
  25. </method>
  26. <method name="get_local_addresses" qualifiers="const">
  27. <return type="Array" />
  28. <description>
  29. Returns all the user's current IPv4 and IPv6 addresses as an array.
  30. </description>
  31. </method>
  32. <method name="get_local_interfaces" qualifiers="const">
  33. <return type="Array" />
  34. <description>
  35. Returns all network adapters as an array.
  36. Each adapter is a dictionary of the form:
  37. [codeblock]
  38. {
  39. "index": "1", # Interface index.
  40. "name": "eth0", # Interface name.
  41. "friendly": "Ethernet One", # A friendly name (might be empty).
  42. "addresses": ["192.168.1.101"], # An array of IP addresses associated to this interface.
  43. }
  44. [/codeblock]
  45. </description>
  46. </method>
  47. <method name="get_resolve_item_address" qualifiers="const">
  48. <return type="String" />
  49. <argument index="0" name="id" type="int" />
  50. <description>
  51. Returns a queued hostname's IP address, given its queue [code]id[/code]. Returns an empty string on error or if resolution hasn't happened yet (see [method get_resolve_item_status]).
  52. </description>
  53. </method>
  54. <method name="get_resolve_item_addresses" qualifiers="const">
  55. <return type="Array" />
  56. <argument index="0" name="id" type="int" />
  57. <description>
  58. Returns resolved addresses, or an empty array if an error happened or resolution didn't happen yet (see [method get_resolve_item_status]).
  59. </description>
  60. </method>
  61. <method name="get_resolve_item_status" qualifiers="const">
  62. <return type="int" enum="IP.ResolverStatus" />
  63. <argument index="0" name="id" type="int" />
  64. <description>
  65. Returns a queued hostname's status as a [enum ResolverStatus] constant, given its queue [code]id[/code].
  66. </description>
  67. </method>
  68. <method name="resolve_hostname">
  69. <return type="String" />
  70. <argument index="0" name="host" type="String" />
  71. <argument index="1" name="ip_type" type="int" enum="IP.Type" default="3" />
  72. <description>
  73. Returns a given hostname's IPv4 or IPv6 address when resolved (blocking-type method). The address type returned depends on the [enum Type] constant given as [code]ip_type[/code].
  74. </description>
  75. </method>
  76. <method name="resolve_hostname_addresses">
  77. <return type="Array" />
  78. <argument index="0" name="host" type="String" />
  79. <argument index="1" name="ip_type" type="int" enum="IP.Type" default="3" />
  80. <description>
  81. Resolves a given hostname in a blocking way. Addresses are returned as an [Array] of IPv4 or IPv6 addresses depending on [code]ip_type[/code].
  82. </description>
  83. </method>
  84. <method name="resolve_hostname_queue_item">
  85. <return type="int" />
  86. <argument index="0" name="host" type="String" />
  87. <argument index="1" name="ip_type" type="int" enum="IP.Type" default="3" />
  88. <description>
  89. Creates a queue item to resolve a hostname to an IPv4 or IPv6 address depending on the [enum Type] constant given as [code]ip_type[/code]. Returns the queue ID if successful, or [constant RESOLVER_INVALID_ID] on error.
  90. </description>
  91. </method>
  92. </methods>
  93. <constants>
  94. <constant name="RESOLVER_STATUS_NONE" value="0" enum="ResolverStatus">
  95. DNS hostname resolver status: No status.
  96. </constant>
  97. <constant name="RESOLVER_STATUS_WAITING" value="1" enum="ResolverStatus">
  98. DNS hostname resolver status: Waiting.
  99. </constant>
  100. <constant name="RESOLVER_STATUS_DONE" value="2" enum="ResolverStatus">
  101. DNS hostname resolver status: Done.
  102. </constant>
  103. <constant name="RESOLVER_STATUS_ERROR" value="3" enum="ResolverStatus">
  104. DNS hostname resolver status: Error.
  105. </constant>
  106. <constant name="RESOLVER_MAX_QUERIES" value="32">
  107. Maximum number of concurrent DNS resolver queries allowed, [constant RESOLVER_INVALID_ID] is returned if exceeded.
  108. </constant>
  109. <constant name="RESOLVER_INVALID_ID" value="-1">
  110. Invalid ID constant. Returned if [constant RESOLVER_MAX_QUERIES] is exceeded.
  111. </constant>
  112. <constant name="TYPE_NONE" value="0" enum="Type">
  113. Address type: None.
  114. </constant>
  115. <constant name="TYPE_IPV4" value="1" enum="Type">
  116. Address type: Internet protocol version 4 (IPv4).
  117. </constant>
  118. <constant name="TYPE_IPV6" value="2" enum="Type">
  119. Address type: Internet protocol version 6 (IPv6).
  120. </constant>
  121. <constant name="TYPE_ANY" value="3" enum="Type">
  122. Address type: Any.
  123. </constant>
  124. </constants>
  125. </class>