IP.xml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="IP" inherits="Object" version="3.4">
  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 [TCP_Server]). 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. </return>
  15. <argument index="0" name="hostname" type="String" default="&quot;&quot;">
  16. </argument>
  17. <description>
  18. Removes all of a [code]hostname[/code]'s cached references. If no [code]hostname[/code] is given, all cached IP addresses are removed.
  19. </description>
  20. </method>
  21. <method name="erase_resolve_item">
  22. <return type="void">
  23. </return>
  24. <argument index="0" name="id" type="int">
  25. </argument>
  26. <description>
  27. 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.
  28. </description>
  29. </method>
  30. <method name="get_local_addresses" qualifiers="const">
  31. <return type="Array">
  32. </return>
  33. <description>
  34. Returns all the user's current IPv4 and IPv6 addresses as an array.
  35. </description>
  36. </method>
  37. <method name="get_local_interfaces" qualifiers="const">
  38. <return type="Array">
  39. </return>
  40. <description>
  41. Returns all network adapters as an array.
  42. Each adapter is a dictionary of the form:
  43. [codeblock]
  44. {
  45. "index": "1", # Interface index.
  46. "name": "eth0", # Interface name.
  47. "friendly": "Ethernet One", # A friendly name (might be empty).
  48. "addresses": ["192.168.1.101"], # An array of IP addresses associated to this interface.
  49. }
  50. [/codeblock]
  51. </description>
  52. </method>
  53. <method name="get_resolve_item_address" qualifiers="const">
  54. <return type="String">
  55. </return>
  56. <argument index="0" name="id" type="int">
  57. </argument>
  58. <description>
  59. 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]).
  60. </description>
  61. </method>
  62. <method name="get_resolve_item_status" qualifiers="const">
  63. <return type="int" enum="IP.ResolverStatus">
  64. </return>
  65. <argument index="0" name="id" type="int">
  66. </argument>
  67. <description>
  68. Returns a queued hostname's status as a [enum ResolverStatus] constant, given its queue [code]id[/code].
  69. </description>
  70. </method>
  71. <method name="resolve_hostname">
  72. <return type="String">
  73. </return>
  74. <argument index="0" name="host" type="String">
  75. </argument>
  76. <argument index="1" name="ip_type" type="int" enum="IP.Type" default="3">
  77. </argument>
  78. <description>
  79. 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].
  80. </description>
  81. </method>
  82. <method name="resolve_hostname_queue_item">
  83. <return type="int">
  84. </return>
  85. <argument index="0" name="host" type="String">
  86. </argument>
  87. <argument index="1" name="ip_type" type="int" enum="IP.Type" default="3">
  88. </argument>
  89. <description>
  90. 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.
  91. </description>
  92. </method>
  93. </methods>
  94. <constants>
  95. <constant name="RESOLVER_STATUS_NONE" value="0" enum="ResolverStatus">
  96. DNS hostname resolver status: No status.
  97. </constant>
  98. <constant name="RESOLVER_STATUS_WAITING" value="1" enum="ResolverStatus">
  99. DNS hostname resolver status: Waiting.
  100. </constant>
  101. <constant name="RESOLVER_STATUS_DONE" value="2" enum="ResolverStatus">
  102. DNS hostname resolver status: Done.
  103. </constant>
  104. <constant name="RESOLVER_STATUS_ERROR" value="3" enum="ResolverStatus">
  105. DNS hostname resolver status: Error.
  106. </constant>
  107. <constant name="RESOLVER_MAX_QUERIES" value="32">
  108. Maximum number of concurrent DNS resolver queries allowed, [constant RESOLVER_INVALID_ID] is returned if exceeded.
  109. </constant>
  110. <constant name="RESOLVER_INVALID_ID" value="-1">
  111. Invalid ID constant. Returned if [constant RESOLVER_MAX_QUERIES] is exceeded.
  112. </constant>
  113. <constant name="TYPE_NONE" value="0" enum="Type">
  114. Address type: None.
  115. </constant>
  116. <constant name="TYPE_IPV4" value="1" enum="Type">
  117. Address type: Internet protocol version 4 (IPv4).
  118. </constant>
  119. <constant name="TYPE_IPV6" value="2" enum="Type">
  120. Address type: Internet protocol version 6 (IPv6).
  121. </constant>
  122. <constant name="TYPE_ANY" value="3" enum="Type">
  123. Address type: Any.
  124. </constant>
  125. </constants>
  126. </class>