react-native-zeroconf 0.13.8 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (294) hide show
  1. package/NOTICE +49 -0
  2. package/README.md +473 -65
  3. package/android/build.gradle +28 -22
  4. package/android/src/main/AndroidManifest.xml +1 -2
  5. package/android/src/main/java/com/balthazargronon/RCTZeroconf/rx2dnssd/DnssdImpl.java +19 -3
  6. package/android/src/main/java/com/github/druk/dnssd/BaseListener.java +33 -0
  7. package/android/src/main/java/com/github/druk/dnssd/BrowseListener.java +67 -0
  8. package/android/src/main/java/com/github/druk/dnssd/DNSRecord.java +47 -0
  9. package/android/src/main/java/com/github/druk/dnssd/DNSSD.java +650 -0
  10. package/android/src/main/java/com/github/druk/dnssd/DNSSDBindable.java +67 -0
  11. package/android/src/main/java/com/github/druk/dnssd/DNSSDEmbedded.java +135 -0
  12. package/android/src/main/java/com/github/druk/dnssd/DNSSDException.java +66 -0
  13. package/android/src/main/java/com/github/druk/dnssd/DNSSDRecordRegistrar.java +55 -0
  14. package/android/src/main/java/com/github/druk/dnssd/DNSSDRegistration.java +54 -0
  15. package/android/src/main/java/com/github/druk/dnssd/DNSSDService.java +35 -0
  16. package/android/src/main/java/com/github/druk/dnssd/DomainListener.java +57 -0
  17. package/android/src/main/java/com/github/druk/dnssd/InternalBrowseListener.java +76 -0
  18. package/android/src/main/java/com/github/druk/dnssd/InternalDNSSD.java +870 -0
  19. package/android/src/main/java/com/github/druk/dnssd/InternalDNSSDRecordRegistrar.java +30 -0
  20. package/android/src/main/java/com/github/druk/dnssd/InternalDNSSDRegistration.java +34 -0
  21. package/android/src/main/java/com/github/druk/dnssd/InternalDNSSDService.java +29 -0
  22. package/android/src/main/java/com/github/druk/dnssd/InternalDomainListener.java +62 -0
  23. package/android/src/main/java/com/github/druk/dnssd/InternalQueryListener.java +61 -0
  24. package/android/src/main/java/com/github/druk/dnssd/InternalRegisterListener.java +51 -0
  25. package/android/src/main/java/com/github/druk/dnssd/InternalResolveListener.java +58 -0
  26. package/android/src/main/java/com/github/druk/dnssd/NSClass.java +16 -0
  27. package/android/src/main/java/com/github/druk/dnssd/NSType.java +58 -0
  28. package/android/src/main/java/com/github/druk/dnssd/QueryListener.java +54 -0
  29. package/android/src/main/java/com/github/druk/dnssd/RegisterListener.java +46 -0
  30. package/android/src/main/java/com/github/druk/dnssd/RegisterRecordListener.java +35 -0
  31. package/android/src/main/java/com/github/druk/dnssd/ResolveListener.java +55 -0
  32. package/android/src/main/java/com/github/druk/dnssd/TXTRecord.java +293 -0
  33. package/android/src/main/java/com/github/druk/rx2dnssd/BonjourService.java +400 -0
  34. package/android/src/main/java/com/github/druk/rx2dnssd/Rx2BrowseListener.java +55 -0
  35. package/android/src/main/java/com/github/druk/rx2dnssd/Rx2Dnssd.java +127 -0
  36. package/android/src/main/java/com/github/druk/rx2dnssd/Rx2DnssdBindable.java +35 -0
  37. package/android/src/main/java/com/github/druk/rx2dnssd/Rx2DnssdCommon.java +280 -0
  38. package/android/src/main/java/com/github/druk/rx2dnssd/Rx2DnssdEmbedded.java +31 -0
  39. package/android/src/main/java/com/github/druk/rx2dnssd/Rx2QueryListener.java +70 -0
  40. package/android/src/main/java/com/github/druk/rx2dnssd/Rx2RegisterListener.java +47 -0
  41. package/android/src/main/java/com/github/druk/rx2dnssd/Rx2ResolveListener.java +51 -0
  42. package/android/src/main/jni/Android.mk +95 -0
  43. package/android/src/main/jni/Application.mk +3 -0
  44. package/android/src/main/jni/DNSSD.java.h +290 -0
  45. package/android/src/main/jni/JNISupport.c +1140 -0
  46. package/android/src/main/jni/mdnsresponder/Android.bp +215 -0
  47. package/android/src/main/jni/mdnsresponder/Clients/ClientCommon.c +75 -0
  48. package/android/src/main/jni/mdnsresponder/Clients/ClientCommon.h +41 -0
  49. package/android/src/main/jni/mdnsresponder/Clients/Makefile +54 -0
  50. package/android/src/main/jni/mdnsresponder/Clients/ReadMe.txt +25 -0
  51. package/android/src/main/jni/mdnsresponder/Clients/dns-sd.c +1351 -0
  52. package/android/src/main/jni/mdnsresponder/LICENSE +13 -0
  53. package/android/src/main/jni/mdnsresponder/MODULE_LICENSE_APACHE2 +0 -0
  54. package/android/src/main/jni/mdnsresponder/Makefile +41 -0
  55. package/android/src/main/jni/mdnsresponder/NOTICE +13 -0
  56. package/android/src/main/jni/mdnsresponder/PrivateDNS.txt +275 -0
  57. package/android/src/main/jni/mdnsresponder/README.txt +166 -0
  58. package/android/src/main/jni/mdnsresponder/README.version +3 -0
  59. package/android/src/main/jni/mdnsresponder/android/caseMapping/Iphlpapi.h +1 -0
  60. package/android/src/main/jni/mdnsresponder/android/caseMapping/README +3 -0
  61. package/android/src/main/jni/mdnsresponder/android/caseMapping/Resource.h +1 -0
  62. package/android/src/main/jni/mdnsresponder/android/caseMapping/Ws2tcpip.h +1 -0
  63. package/android/src/main/jni/mdnsresponder/android/caseMapping/ipExport.h +1 -0
  64. package/android/src/main/jni/mdnsresponder/android/windows_firewall_dummy.c +10 -0
  65. package/android/src/main/jni/mdnsresponder/mDNSCore/DNSCommon.c +3157 -0
  66. package/android/src/main/jni/mdnsresponder/mDNSCore/DNSCommon.h +292 -0
  67. package/android/src/main/jni/mdnsresponder/mDNSCore/DNSDigest.c +1579 -0
  68. package/android/src/main/jni/mdnsresponder/mDNSCore/Implementer Notes.txt +66 -0
  69. package/android/src/main/jni/mdnsresponder/mDNSCore/mDNS.c +11469 -0
  70. package/android/src/main/jni/mdnsresponder/mDNSCore/mDNSDebug.h +164 -0
  71. package/android/src/main/jni/mdnsresponder/mDNSCore/mDNSEmbeddedAPI.h +2974 -0
  72. package/android/src/main/jni/mdnsresponder/mDNSCore/uDNS.c +4969 -0
  73. package/android/src/main/jni/mdnsresponder/mDNSCore/uDNS.h +132 -0
  74. package/android/src/main/jni/mdnsresponder/mDNSPosix/Client.c +223 -0
  75. package/android/src/main/jni/mdnsresponder/mDNSPosix/ExampleClientApp.c +91 -0
  76. package/android/src/main/jni/mdnsresponder/mDNSPosix/ExampleClientApp.h +18 -0
  77. package/android/src/main/jni/mdnsresponder/mDNSPosix/Identify.c +378 -0
  78. package/android/src/main/jni/mdnsresponder/mDNSPosix/Makefile +520 -0
  79. package/android/src/main/jni/mdnsresponder/mDNSPosix/NetMonitor.c +1010 -0
  80. package/android/src/main/jni/mdnsresponder/mDNSPosix/PosixDaemon.c +329 -0
  81. package/android/src/main/jni/mdnsresponder/mDNSPosix/ProxyResponder.c +300 -0
  82. package/android/src/main/jni/mdnsresponder/mDNSPosix/ReadMe.txt +314 -0
  83. package/android/src/main/jni/mdnsresponder/mDNSPosix/Responder.c +792 -0
  84. package/android/src/main/jni/mdnsresponder/mDNSPosix/Services.txt +36 -0
  85. package/android/src/main/jni/mdnsresponder/mDNSPosix/libnss_mdns.8 +148 -0
  86. package/android/src/main/jni/mdnsresponder/mDNSPosix/mDNSPosix.c +1685 -0
  87. package/android/src/main/jni/mdnsresponder/mDNSPosix/mDNSPosix.h +88 -0
  88. package/android/src/main/jni/mdnsresponder/mDNSPosix/mDNSUNP.c +726 -0
  89. package/android/src/main/jni/mdnsresponder/mDNSPosix/mDNSUNP.h +130 -0
  90. package/android/src/main/jni/mdnsresponder/mDNSPosix/mdnsd.sh +73 -0
  91. package/android/src/main/jni/mdnsresponder/mDNSPosix/nss_ReadMe.txt +125 -0
  92. package/android/src/main/jni/mdnsresponder/mDNSPosix/nss_mdns.c +2723 -0
  93. package/android/src/main/jni/mdnsresponder/mDNSPosix/nss_mdns.conf +13 -0
  94. package/android/src/main/jni/mdnsresponder/mDNSPosix/nss_mdns.conf.5 +135 -0
  95. package/android/src/main/jni/mdnsresponder/mDNSPosix/parselog.py +247 -0
  96. package/android/src/main/jni/mdnsresponder/mDNSResponder.sln +400 -0
  97. package/android/src/main/jni/mdnsresponder/mDNSShared/CommonServices.h +1537 -0
  98. package/android/src/main/jni/mdnsresponder/mDNSShared/DebugServices.c +3075 -0
  99. package/android/src/main/jni/mdnsresponder/mDNSShared/DebugServices.h +1607 -0
  100. package/android/src/main/jni/mdnsresponder/mDNSShared/GenLinkedList.c +319 -0
  101. package/android/src/main/jni/mdnsresponder/mDNSShared/GenLinkedList.h +90 -0
  102. package/android/src/main/jni/mdnsresponder/mDNSShared/PlatformCommon.c +220 -0
  103. package/android/src/main/jni/mdnsresponder/mDNSShared/PlatformCommon.h +18 -0
  104. package/android/src/main/jni/mdnsresponder/mDNSShared/dns-sd.1 +194 -0
  105. package/android/src/main/jni/mdnsresponder/mDNSShared/dns_sd.h +2452 -0
  106. package/android/src/main/jni/mdnsresponder/mDNSShared/dnsextd.8 +69 -0
  107. package/android/src/main/jni/mdnsresponder/mDNSShared/dnsextd.c +3146 -0
  108. package/android/src/main/jni/mdnsresponder/mDNSShared/dnsextd.conf +60 -0
  109. package/android/src/main/jni/mdnsresponder/mDNSShared/dnsextd.h +163 -0
  110. package/android/src/main/jni/mdnsresponder/mDNSShared/dnsextd_lexer.l +84 -0
  111. package/android/src/main/jni/mdnsresponder/mDNSShared/dnsextd_parser.y +585 -0
  112. package/android/src/main/jni/mdnsresponder/mDNSShared/dnssd_clientlib.c +368 -0
  113. package/android/src/main/jni/mdnsresponder/mDNSShared/dnssd_clientshim.c +802 -0
  114. package/android/src/main/jni/mdnsresponder/mDNSShared/dnssd_clientstub.c +1988 -0
  115. package/android/src/main/jni/mdnsresponder/mDNSShared/dnssd_ipc.c +161 -0
  116. package/android/src/main/jni/mdnsresponder/mDNSShared/dnssd_ipc.h +219 -0
  117. package/android/src/main/jni/mdnsresponder/mDNSShared/mDNS.1 +198 -0
  118. package/android/src/main/jni/mdnsresponder/mDNSShared/mDNSDebug.c +93 -0
  119. package/android/src/main/jni/mdnsresponder/mDNSShared/mDNSResponder.8 +116 -0
  120. package/android/src/main/jni/mdnsresponder/mDNSShared/uds_daemon.c +4758 -0
  121. package/android/src/main/jni/mdnsresponder/mDNSShared/uds_daemon.h +80 -0
  122. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/BrowsingPage.cpp +441 -0
  123. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/BrowsingPage.h +156 -0
  124. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/ConfigDialog.cpp +59 -0
  125. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/ConfigDialog.h +48 -0
  126. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/ConfigPropertySheet.cpp +301 -0
  127. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/ConfigPropertySheet.h +105 -0
  128. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/ControlPanel.cpp +380 -0
  129. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/ControlPanel.def +20 -0
  130. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/ControlPanel.h +84 -0
  131. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/ControlPanel.rc +141 -0
  132. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/ControlPanel.vcproj +727 -0
  133. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/ControlPanelDll.rc +123 -0
  134. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/ControlPanelExe.cpp +373 -0
  135. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/ControlPanelExe.h +48 -0
  136. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/ControlPanelExe.rc +123 -0
  137. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/ControlPanelExe.vcproj +764 -0
  138. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/ControlPanelLocRes.rc +270 -0
  139. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/ControlPanelLocRes.vcproj +487 -0
  140. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/ControlPanelRes.rc +134 -0
  141. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/ControlPanelRes.vcproj +518 -0
  142. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/FourthPage.cpp +197 -0
  143. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/FourthPage.h +87 -0
  144. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/RegistrationPage.cpp +387 -0
  145. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/RegistrationPage.h +75 -0
  146. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/SecondPage.cpp +544 -0
  147. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/SecondPage.h +107 -0
  148. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/ServicesPage.cpp +273 -0
  149. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/ServicesPage.h +123 -0
  150. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/SharedSecret.cpp +115 -0
  151. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/SharedSecret.h +54 -0
  152. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/res/ControlPanel.dll.manifest +10 -0
  153. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/res/ControlPanel.exe.manifest +17 -0
  154. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/res/ControlPanel.manifest +17 -0
  155. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/res/ControlPanel.rc2 +13 -0
  156. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/res/ControlPanel64.manifest +17 -0
  157. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/res/EnergySaver.ico +0 -0
  158. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/res/controlpanel.ico +0 -0
  159. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/res/failure.ico +0 -0
  160. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/res/success.ico +0 -0
  161. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/resource.h +56 -0
  162. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/stdafx.cpp +20 -0
  163. package/android/src/main/jni/mdnsresponder/mDNSWindows/ControlPanel/stdafx.h +64 -0
  164. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLL/dll.aps +0 -0
  165. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLL/dll.rc +102 -0
  166. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLL/dllmain.c +112 -0
  167. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLL/dnssd.def +48 -0
  168. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLL/dnssd.vcproj +472 -0
  169. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLL/resource.h +27 -0
  170. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLL.NET/AssemblyInfo.cpp +84 -0
  171. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLL.NET/PString.h +70 -0
  172. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLL.NET/Stdafx.cpp +22 -0
  173. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLL.NET/Stdafx.h +33 -0
  174. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLL.NET/dnssd_NET.cpp +1234 -0
  175. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLL.NET/dnssd_NET.h +1392 -0
  176. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLL.NET/dnssd_NET.ico +0 -0
  177. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLL.NET/dnssd_NET.rc +113 -0
  178. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLL.NET/dnssd_NET.vcproj +446 -0
  179. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLL.NET/resource.h +3 -0
  180. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLStub/DLLStub.cpp +693 -0
  181. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLStub/DLLStub.h +52 -0
  182. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLStub/DLLStub.vcproj +324 -0
  183. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/DLLX.cpp +208 -0
  184. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/DLLX.def +35 -0
  185. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/DLLX.idl +491 -0
  186. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/DLLX.rc +126 -0
  187. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/DLLX.rgs +11 -0
  188. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/DLLX.vcproj +625 -0
  189. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/DNSSD.cpp +892 -0
  190. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/DNSSDEventManager.cpp +31 -0
  191. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/DNSSDEventManager.h +133 -0
  192. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/DNSSDEventManager.rgs +27 -0
  193. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/DNSSDRecord.cpp +101 -0
  194. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/DNSSDRecord.h +185 -0
  195. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/DNSSDRecord.rgs +27 -0
  196. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/DNSSDService.cpp +2095 -0
  197. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/DNSSDService.h +429 -0
  198. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/DNSSDService.rgs +27 -0
  199. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/StringServices.cpp +344 -0
  200. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/StringServices.h +102 -0
  201. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/TXTRecord.cpp +381 -0
  202. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/TXTRecord.h +203 -0
  203. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/TXTRecord.rgs +27 -0
  204. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/_IDNSSDEvents_CP.h +358 -0
  205. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/dlldatax.c +51 -0
  206. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/dlldatax.h +49 -0
  207. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/resource.h +30 -0
  208. package/android/src/main/jni/mdnsresponder/mDNSWindows/DLLX/stdafx.h +88 -0
  209. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/Windows/ApplicationVS2002.sln +21 -0
  210. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/Windows/ApplicationVS2002.vcproj +253 -0
  211. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/Windows/ApplicationVS2003.sln +21 -0
  212. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/Windows/ApplicationVS2003.vcproj +267 -0
  213. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/Windows/Resources/Application.ico +0 -0
  214. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/Windows/Resources/Application.rc +323 -0
  215. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/Windows/Resources/Application.rc2 +20 -0
  216. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/Windows/Resources/Resource.h +53 -0
  217. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/Windows/Sources/AboutDialog.cpp +71 -0
  218. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/Windows/Sources/AboutDialog.h +62 -0
  219. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/Windows/Sources/Application.cpp +111 -0
  220. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/Windows/Sources/Application.h +68 -0
  221. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/Windows/Sources/ChooserDialog.cpp +1426 -0
  222. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/Windows/Sources/ChooserDialog.h +131 -0
  223. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/Windows/Sources/LoginDialog.cpp +109 -0
  224. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/Windows/Sources/LoginDialog.h +53 -0
  225. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/Windows/Sources/StdAfx.cpp +18 -0
  226. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/Windows/Sources/StdAfx.h +48 -0
  227. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/WindowsCE/Application.vcc +37 -0
  228. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/WindowsCE/Application.vcp +868 -0
  229. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/WindowsCE/Application.vcw +29 -0
  230. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/WindowsCE/Resources/Application.ico +0 -0
  231. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/WindowsCE/Resources/Application.rc +194 -0
  232. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/WindowsCE/Resources/Application.rc2 +13 -0
  233. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/WindowsCE/Resources/newres.h +28 -0
  234. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/WindowsCE/Resources/resource.h +22 -0
  235. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/WindowsCE/Sources/Application.cpp +92 -0
  236. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/WindowsCE/Sources/Application.h +57 -0
  237. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/WindowsCE/Sources/BrowserDialog.cpp +394 -0
  238. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/WindowsCE/Sources/BrowserDialog.h +84 -0
  239. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/WindowsCE/Sources/StdAfx.cpp +18 -0
  240. package/android/src/main/jni/mdnsresponder/mDNSWindows/DNSServiceBrowser/WindowsCE/Sources/StdAfx.h +46 -0
  241. package/android/src/main/jni/mdnsresponder/mDNSWindows/Java/Java.vcproj +111 -0
  242. package/android/src/main/jni/mdnsresponder/mDNSWindows/Java/jdns_sd.rc +62 -0
  243. package/android/src/main/jni/mdnsresponder/mDNSWindows/Java/makefile +143 -0
  244. package/android/src/main/jni/mdnsresponder/mDNSWindows/Java/makefile64 +143 -0
  245. package/android/src/main/jni/mdnsresponder/mDNSWindows/NSPTool/NSPTool.aps +0 -0
  246. package/android/src/main/jni/mdnsresponder/mDNSWindows/NSPTool/NSPTool.c +581 -0
  247. package/android/src/main/jni/mdnsresponder/mDNSWindows/NSPTool/NSPTool.rc +103 -0
  248. package/android/src/main/jni/mdnsresponder/mDNSWindows/NSPTool/NSPTool.vcproj +409 -0
  249. package/android/src/main/jni/mdnsresponder/mDNSWindows/NSPTool/Prefix.h +28 -0
  250. package/android/src/main/jni/mdnsresponder/mDNSWindows/NSPTool/resource.h +27 -0
  251. package/android/src/main/jni/mdnsresponder/mDNSWindows/PosixCompat.c +128 -0
  252. package/android/src/main/jni/mdnsresponder/mDNSWindows/PosixCompat.h +70 -0
  253. package/android/src/main/jni/mdnsresponder/mDNSWindows/README.txt +85 -0
  254. package/android/src/main/jni/mdnsresponder/mDNSWindows/RegNames.h +57 -0
  255. package/android/src/main/jni/mdnsresponder/mDNSWindows/Secret.c +338 -0
  256. package/android/src/main/jni/mdnsresponder/mDNSWindows/Secret.h +42 -0
  257. package/android/src/main/jni/mdnsresponder/mDNSWindows/SystemService/EventLog.mc +11 -0
  258. package/android/src/main/jni/mdnsresponder/mDNSWindows/SystemService/EventLogMessages.bin +0 -0
  259. package/android/src/main/jni/mdnsresponder/mDNSWindows/SystemService/Firewall.cpp +484 -0
  260. package/android/src/main/jni/mdnsresponder/mDNSWindows/SystemService/Firewall.h +79 -0
  261. package/android/src/main/jni/mdnsresponder/mDNSWindows/SystemService/Prefix.h +30 -0
  262. package/android/src/main/jni/mdnsresponder/mDNSWindows/SystemService/Service.aps +0 -0
  263. package/android/src/main/jni/mdnsresponder/mDNSWindows/SystemService/Service.c +2669 -0
  264. package/android/src/main/jni/mdnsresponder/mDNSWindows/SystemService/Service.h +30 -0
  265. package/android/src/main/jni/mdnsresponder/mDNSWindows/SystemService/Service.mcp +0 -0
  266. package/android/src/main/jni/mdnsresponder/mDNSWindows/SystemService/Service.rc +114 -0
  267. package/android/src/main/jni/mdnsresponder/mDNSWindows/SystemService/Service.vcproj +562 -0
  268. package/android/src/main/jni/mdnsresponder/mDNSWindows/SystemService/main.c +32 -0
  269. package/android/src/main/jni/mdnsresponder/mDNSWindows/SystemService/res/mDNSResponder.manifest +12 -0
  270. package/android/src/main/jni/mdnsresponder/mDNSWindows/SystemService/res/mDNSResponder64.manifest +12 -0
  271. package/android/src/main/jni/mdnsresponder/mDNSWindows/SystemService/resource.h +17 -0
  272. package/android/src/main/jni/mdnsresponder/mDNSWindows/SystemService/resrc1.h +15 -0
  273. package/android/src/main/jni/mdnsresponder/mDNSWindows/VPCDetect.cpp +165 -0
  274. package/android/src/main/jni/mdnsresponder/mDNSWindows/VPCDetect.h +36 -0
  275. package/android/src/main/jni/mdnsresponder/mDNSWindows/WinServices.cpp +93 -0
  276. package/android/src/main/jni/mdnsresponder/mDNSWindows/WinServices.h +34 -0
  277. package/android/src/main/jni/mdnsresponder/mDNSWindows/WinVersRes.h +35 -0
  278. package/android/src/main/jni/mdnsresponder/mDNSWindows/isocode.h +135 -0
  279. package/android/src/main/jni/mdnsresponder/mDNSWindows/loclibrary.c +268 -0
  280. package/android/src/main/jni/mdnsresponder/mDNSWindows/loclibrary.h +54 -0
  281. package/android/src/main/jni/mdnsresponder/mDNSWindows/mDNSWin32.c +5200 -0
  282. package/android/src/main/jni/mdnsresponder/mDNSWindows/mDNSWin32.h +208 -0
  283. package/android/src/main/jni/mdnsresponder/mDNSWindows/mdnsNSP/ReadMe.txt +15 -0
  284. package/android/src/main/jni/mdnsresponder/mDNSWindows/mdnsNSP/mdnsNSP.aps +0 -0
  285. package/android/src/main/jni/mdnsresponder/mDNSWindows/mdnsNSP/mdnsNSP.c +2430 -0
  286. package/android/src/main/jni/mdnsresponder/mDNSWindows/mdnsNSP/mdnsNSP.def +24 -0
  287. package/android/src/main/jni/mdnsresponder/mDNSWindows/mdnsNSP/mdnsNSP.rc +104 -0
  288. package/android/src/main/jni/mdnsresponder/mDNSWindows/mdnsNSP/mdnsNSP.vcproj +457 -0
  289. package/android/src/main/jni/mdnsresponder/mDNSWindows/mdnsNSP/resource.h +27 -0
  290. package/android/src/main/jni/mdnsresponder/mdnsd.rc +7 -0
  291. package/android/src/main/jni/nameser.h +588 -0
  292. package/dist/index.js +148 -1
  293. package/package.json +23 -17
  294. package/src/index.js +166 -0
@@ -0,0 +1,870 @@
1
+ /* -*- Mode: Java; tab-width: 4 -*-
2
+ *
3
+ * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+
17
+ This file declares and implements DNSSD, the central Java factory class
18
+ for doing DNS Service Discovery. It includes the mostly-abstract public
19
+ interface, as well as the Apple* implementation subclasses.
20
+ */
21
+
22
+
23
+ package com.github.druk.dnssd;
24
+
25
+ // I don't want to change Apple source code
26
+ //CHECKSTYLE:OFF
27
+
28
+ /**
29
+ DNSSD provides access to DNS Service Discovery features of ZeroConf networking.<P>
30
+
31
+ It is a factory class that is used to invoke registration and discovery-related
32
+ operations. Most operations are non-blocking; clients are called back through an interface
33
+ with the result of an operation. Callbacks are made from a separate worker thread.<P>
34
+
35
+ For example, in this program<P>
36
+ <PRE><CODE>
37
+ class MyClient implements BrowseListener {
38
+ void lookForWebServers() {
39
+ myBrowser = DNSSD.browse("_http._tcp", this);
40
+ }
41
+
42
+ public void serviceFound(DNSSDService browser, int flags, int ifIndex,
43
+ String serviceName, String regType, String domain) {}
44
+ ...
45
+ }</CODE></PRE>
46
+ <CODE>MyClient.serviceFound()</CODE> would be called for every HTTP server discovered in the
47
+ default browse domain(s).
48
+ */
49
+
50
+ abstract class InternalDNSSD
51
+ {
52
+ /** Flag indicates to a {@link InternalBrowseListener} that another result is
53
+ queued. Applications should not update their UI to display browse
54
+ results if the MORE_COMING flag is set; they will be called at least once
55
+ more with the flag clear.
56
+ */
57
+ public static final int MORE_COMING = ( 1 << 0 );
58
+
59
+ /** If flag is set in a {@link InternalDomainListener} callback, indicates that the result is the default domain. */
60
+ public static final int DEFAULT = ( 1 << 2 );
61
+
62
+ /** If flag is set, a name conflict will trigger an exception when registering non-shared records.<P>
63
+ A name must be explicitly specified when registering a service if this bit is set
64
+ (i.e. the default name may not not be used).
65
+ */
66
+ public static final int NO_AUTO_RENAME = ( 1 << 3 );
67
+
68
+ /** If flag is set, allow multiple records with this name on the network (e.g. PTR records)
69
+ when registering individual records on a {@link DNSSDRegistration}.
70
+ */
71
+ public static final int SHARED = ( 1 << 4 );
72
+
73
+ /** If flag is set, records with this name must be unique on the network (e.g. SRV records). */
74
+ public static final int UNIQUE = ( 1 << 5 );
75
+
76
+ /** Set flag when calling enumerateDomains() to restrict results to domains recommended for browsing. */
77
+ public static final int BROWSE_DOMAINS = ( 1 << 6 );
78
+ /** Set flag when calling enumerateDomains() to restrict results to domains recommended for registration. */
79
+ public static final int REGISTRATION_DOMAINS = ( 1 << 7 );
80
+
81
+ /** Maximum length, in bytes, of a domain name represented as an escaped C-String. */
82
+ public static final int MAX_DOMAIN_NAME = 1009;
83
+
84
+ /** Pass for ifIndex to specify all available interfaces. */
85
+ public static final int ALL_INTERFACES = 0;
86
+
87
+ /** Pass for ifIndex to specify the localhost interface. */
88
+ public static final int LOCALHOST_ONLY = -1;
89
+
90
+ public static void init(String lib){
91
+ getInstance()._init(lib);
92
+ }
93
+
94
+ /** Browse for instances of a service.<P>
95
+
96
+ Note: browsing consumes network bandwidth. Call {@link DNSSDService#stop} when you have finished browsing.<P>
97
+
98
+ @param flags
99
+ Currently ignored, reserved for future use.
100
+ <P>
101
+ @param ifIndex
102
+ If non-zero, specifies the interface on which to browse for services
103
+ (the index for a given interface is determined via the if_nametoindex()
104
+ family of calls.) Most applications will pass 0 to browse on all available
105
+ interfaces. Pass -1 to only browse for services provided on the local host.
106
+ <P>
107
+ @param regType
108
+ The registration type being browsed for followed by the protocol, separated by a
109
+ dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
110
+ <P>
111
+ @param domain
112
+ If non-null, specifies the domain on which to browse for services.
113
+ Most applications will not specify a domain, instead browsing on the
114
+ default domain(s).
115
+ <P>
116
+ @param listener
117
+ This object will get called when instances of the service are discovered (or disappear).
118
+ <P>
119
+ @return A {@link DNSSDService} that represents the active browse operation.
120
+
121
+ @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
122
+ @see RuntimePermission
123
+ */
124
+ public static DNSSDService browse( int flags, int ifIndex, String regType, String domain, InternalBrowseListener listener)
125
+ throws DNSSDException
126
+ { return getInstance()._makeBrowser( flags, ifIndex, regType, domain, listener); }
127
+
128
+ /** Browse for instances of a service. Use default flags, ifIndex and domain.<P>
129
+
130
+ @param regType
131
+ The registration type being browsed for followed by the protocol, separated by a
132
+ dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
133
+ <P>
134
+ @param listener
135
+ This object will get called when instances of the service are discovered (or disappear).
136
+ <P>
137
+ @return A {@link DNSSDService} that represents the active browse operation.
138
+
139
+ @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
140
+ @see RuntimePermission
141
+ */
142
+ public static DNSSDService browse( String regType, InternalBrowseListener listener)
143
+ throws DNSSDException
144
+ { return browse( 0, 0, regType, "", listener); }
145
+
146
+ /** Resolve a service name discovered via browse() to a target host name, port number, and txt record.<P>
147
+
148
+ Note: Applications should NOT use resolve() solely for txt record monitoring - use
149
+ queryRecord() instead, as it is more efficient for this task.<P>
150
+
151
+ Note: When the desired results have been returned, the client MUST terminate the resolve by
152
+ calling {@link DNSSDService#stop}.<P>
153
+
154
+ Note: resolve() behaves correctly for typical services that have a single SRV record and
155
+ a single TXT record (the TXT record may be empty.) To resolve non-standard services with
156
+ multiple SRV or TXT records, use queryRecord().<P>
157
+
158
+ @param flags
159
+ Currently ignored, reserved for future use.
160
+ <P>
161
+ @param ifIndex
162
+ The interface on which to resolve the service. The client should
163
+ pass the interface on which the serviceName was discovered (i.e.
164
+ the ifIndex passed to the serviceFound() callback)
165
+ or 0 to resolve the named service on all available interfaces.
166
+ <P>
167
+ @param serviceName
168
+ The servicename to be resolved.
169
+ <P>
170
+ @param regType
171
+ The registration type being resolved followed by the protocol, separated by a
172
+ dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
173
+ <P>
174
+ @param domain
175
+ The domain on which the service is registered, i.e. the domain passed
176
+ to the serviceFound() callback.
177
+ <P>
178
+ @param listener
179
+ This object will get called when the service is resolved.
180
+ <P>
181
+ @return A {@link DNSSDService} that represents the active resolve operation.
182
+
183
+ @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
184
+ @see RuntimePermission
185
+ */
186
+ public static DNSSDService resolve( int flags, int ifIndex, String serviceName, String regType,
187
+ String domain, InternalResolveListener listener)
188
+ throws DNSSDException
189
+ { return getInstance()._resolve( flags, ifIndex, serviceName, regType, domain, listener); }
190
+
191
+ /** Register a service, to be discovered via browse() and resolve() calls.<P>
192
+ @param flags
193
+ Possible values are: NO_AUTO_RENAME.
194
+ <P>
195
+ @param ifIndex
196
+ If non-zero, specifies the interface on which to register the service
197
+ (the index for a given interface is determined via the if_nametoindex()
198
+ family of calls.) Most applications will pass 0 to register on all
199
+ available interfaces. Pass -1 to register a service only on the local
200
+ machine (service will not be visible to remote hosts).
201
+ <P>
202
+ @param serviceName
203
+ If non-null, specifies the service name to be registered.
204
+ Applications need not specify a name, in which case the
205
+ computer name is used (this name is communicated to the client via
206
+ the serviceRegistered() callback).
207
+ <P>
208
+ @param regType
209
+ The registration type being registered followed by the protocol, separated by a
210
+ dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
211
+ <P>
212
+ @param domain
213
+ If non-null, specifies the domain on which to advertise the service.
214
+ Most applications will not specify a domain, instead automatically
215
+ registering in the default domain(s).
216
+ <P>
217
+ @param host
218
+ If non-null, specifies the SRV target host name. Most applications
219
+ will not specify a host, instead automatically using the machine's
220
+ default host name(s). Note that specifying a non-null host does NOT
221
+ create an address record for that host - the application is responsible
222
+ for ensuring that the appropriate address record exists, or creating it
223
+ via {@link DNSSDRegistration#addRecord}.
224
+ <P>
225
+ @param port
226
+ The port on which the service accepts connections. Pass 0 for a
227
+ "placeholder" service (i.e. a service that will not be discovered by
228
+ browsing, but will cause a name conflict if another client tries to
229
+ register that same name.) Most clients will not use placeholder services.
230
+ <P>
231
+ @param txtRecord
232
+ The txt record rdata. May be null. Note that a non-null txtRecord
233
+ MUST be a properly formatted DNS TXT record, i.e. &lt;length byte&gt; &lt;data&gt;
234
+ &lt;length byte&gt; &lt;data&gt; ...
235
+ <P>
236
+ @param listener
237
+ This object will get called when the service is registered.
238
+ <P>
239
+ @return A {@link DNSSDRegistration} that controls the active registration.
240
+
241
+ @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
242
+ @see RuntimePermission
243
+ */
244
+ public static DNSSDRegistration register( int flags, int ifIndex, String serviceName, String regType,
245
+ String domain, String host, int port, TXTRecord txtRecord, InternalRegisterListener listener)
246
+ throws DNSSDException
247
+ { return getInstance()._register( flags, ifIndex, serviceName, regType, domain, host, port, txtRecord, listener); }
248
+
249
+ /** Register a service, to be discovered via browse() and resolve() calls. Use default flags, ifIndex, domain, host and txtRecord.<P>
250
+ @param serviceName
251
+ If non-null, specifies the service name to be registered.
252
+ Applications need not specify a name, in which case the
253
+ computer name is used (this name is communicated to the client via
254
+ the serviceRegistered() callback).
255
+ <P>
256
+ @param regType
257
+ The registration type being registered followed by the protocol, separated by a
258
+ dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
259
+ <P>
260
+ @param port
261
+ The port on which the service accepts connections. Pass 0 for a
262
+ "placeholder" service (i.e. a service that will not be discovered by
263
+ browsing, but will cause a name conflict if another client tries to
264
+ register that same name.) Most clients will not use placeholder services.
265
+ <P>
266
+ @param listener
267
+ This object will get called when the service is registered.
268
+ <P>
269
+ @return A {@link DNSSDRegistration} that controls the active registration.
270
+
271
+ @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
272
+ @see RuntimePermission
273
+ */
274
+ public static DNSSDRegistration register( String serviceName, String regType, int port, InternalRegisterListener listener)
275
+ throws DNSSDException
276
+ { return register( 0, 0, serviceName, regType, null, null, port, null, listener); }
277
+
278
+ /** Create a {@link DNSSDRecordRegistrar} allowing efficient registration of
279
+ multiple individual records.<P>
280
+ <P>
281
+ @return A {@link DNSSDRecordRegistrar} that can be used to register records.
282
+
283
+ @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
284
+ @see RuntimePermission
285
+ */
286
+ public static DNSSDRecordRegistrar createRecordRegistrar( RegisterRecordListener listener)
287
+ throws DNSSDException
288
+ { return getInstance()._createRecordRegistrar( listener); }
289
+
290
+ /** Query for an arbitrary DNS record.<P>
291
+ @param flags
292
+ Possible values are: MORE_COMING.
293
+ <P>
294
+ @param ifIndex
295
+ If non-zero, specifies the interface on which to issue the query
296
+ (the index for a given interface is determined via the if_nametoindex()
297
+ family of calls.) Passing 0 causes the name to be queried for on all
298
+ interfaces. Passing -1 causes the name to be queried for only on the
299
+ local host.
300
+ <P>
301
+ @param serviceName
302
+ The full domain name of the resource record to be queried for.
303
+ <P>
304
+ @param rrtype
305
+ The numerical type of the resource record to be queried for (e.g. PTR, SRV, etc)
306
+ as defined in nameser.h.
307
+ <P>
308
+ @param rrclass
309
+ The class of the resource record, as defined in nameser.h
310
+ (usually 1 for the Internet class).
311
+ <P>
312
+ @param listener
313
+ This object will get called when the query completes.
314
+ <P>
315
+ @return A {@link DNSSDService} that controls the active query.
316
+
317
+ @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
318
+ @see RuntimePermission
319
+ */
320
+ public static DNSSDService queryRecord( int flags, int ifIndex, String serviceName, int rrtype,
321
+ int rrclass, InternalQueryListener listener)
322
+ throws DNSSDException
323
+ { return getInstance()._queryRecord( flags, ifIndex, serviceName, rrtype, rrclass, listener); }
324
+
325
+ /** Asynchronously enumerate domains available for browsing and registration.<P>
326
+
327
+ Currently, the only domain returned is "local.", but other domains will be returned in future.<P>
328
+
329
+ The enumeration MUST be cancelled by calling {@link DNSSDService#stop} when no more domains
330
+ are to be found.<P>
331
+ @param flags
332
+ Possible values are: BROWSE_DOMAINS, REGISTRATION_DOMAINS.
333
+ <P>
334
+ @param ifIndex
335
+ If non-zero, specifies the interface on which to look for domains.
336
+ (the index for a given interface is determined via the if_nametoindex()
337
+ family of calls.) Most applications will pass 0 to enumerate domains on
338
+ all interfaces.
339
+ <P>
340
+ @param listener
341
+ This object will get called when domains are found.
342
+ <P>
343
+ @return A {@link DNSSDService} that controls the active enumeration.
344
+
345
+ @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
346
+ @see RuntimePermission
347
+ */
348
+ public static DNSSDService enumerateDomains( int flags, int ifIndex, InternalDomainListener listener)
349
+ throws DNSSDException
350
+ { return getInstance()._enumerateDomains( flags, ifIndex, listener); }
351
+
352
+ /** Concatenate a three-part domain name (as provided to the listeners) into a
353
+ properly-escaped full domain name. Note that strings passed to listeners are
354
+ ALREADY ESCAPED where necessary.<P>
355
+ @param serviceName
356
+ The service name - any dots or slashes must NOT be escaped.
357
+ May be null (to construct a PTR record name, e.g. "_ftp._tcp.apple.com").
358
+ <P>
359
+ @param regType
360
+ The registration type followed by the protocol, separated by a dot (e.g. "_ftp._tcp").
361
+ <P>
362
+ @param domain
363
+ The domain name, e.g. "apple.com". Any literal dots or backslashes must be escaped.
364
+ <P>
365
+ @return The full domain name.
366
+
367
+ @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
368
+ @see RuntimePermission
369
+ */
370
+ public static String constructFullName( String serviceName, String regType, String domain)
371
+ throws DNSSDException
372
+ { return getInstance()._constructFullName( serviceName, regType, domain); }
373
+
374
+ /** Instruct the daemon to verify the validity of a resource record that appears to
375
+ be out of date. (e.g. because tcp connection to a service's target failed.) <P>
376
+
377
+ Causes the record to be flushed from the daemon's cache (as well as all other
378
+ daemons' caches on the network) if the record is determined to be invalid.<P>
379
+ @param flags
380
+ Currently unused, reserved for future use.
381
+ <P>
382
+ @param ifIndex
383
+ If non-zero, specifies the interface on which to reconfirm the record
384
+ (the index for a given interface is determined via the if_nametoindex()
385
+ family of calls.) Passing 0 causes the name to be reconfirmed on all
386
+ interfaces. Passing -1 causes the name to be reconfirmed only on the
387
+ local host.
388
+ <P>
389
+ @param fullName
390
+ The resource record's full domain name.
391
+ <P>
392
+ @param rrtype
393
+ The resource record's type (e.g. PTR, SRV, etc) as defined in nameser.h.
394
+ <P>
395
+ @param rrclass
396
+ The class of the resource record, as defined in nameser.h (usually 1).
397
+ <P>
398
+ @param rdata
399
+ The raw rdata of the resource record.
400
+
401
+ @return Error DNSServiceErrorType
402
+
403
+ @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
404
+ @see RuntimePermission
405
+ */
406
+ public static int reconfirmRecord( int flags, int ifIndex, String fullName, int rrtype,
407
+ int rrclass, byte[] rdata)
408
+ { return getInstance()._reconfirmRecord( flags, ifIndex, fullName, rrtype, rrclass, rdata); }
409
+
410
+ /** Return the canonical name of a particular interface index.<P>
411
+ @param ifIndex
412
+ A valid interface index. Must not be ALL_INTERFACES.
413
+ <P>
414
+ @return The name of the interface, which should match java.net.NetworkInterface.getName().
415
+
416
+ @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
417
+ @see RuntimePermission
418
+ */
419
+ public static String getNameForIfIndex( int ifIndex)
420
+ { return getInstance()._getNameForIfIndex( ifIndex); }
421
+
422
+ /** Return the index of a named interface.<P>
423
+ @param ifName
424
+ A valid interface name. An example is java.net.NetworkInterface.getName().
425
+ <P>
426
+ @return The interface index.
427
+
428
+ @throws SecurityException If a security manager is present and denies <tt>RuntimePermission("getDNSSDInstance")</tt>.
429
+ @see RuntimePermission
430
+ */
431
+ public static int getIfIndexForName( String ifName)
432
+ { return getInstance()._getIfIndexForName( ifName); }
433
+
434
+ protected InternalDNSSD() {} // prevent direct instantiation
435
+
436
+ /** Return the single instance of DNSSD. */
437
+ static protected final InternalDNSSD getInstance()
438
+ {
439
+ SecurityManager sm = System.getSecurityManager();
440
+ if (sm != null)
441
+ sm.checkPermission( new RuntimePermission( "getDNSSDInstance"));
442
+ return fInstance;
443
+ }
444
+
445
+ abstract protected void _init(String lib);
446
+
447
+ abstract protected DNSSDService _makeBrowser( int flags, int ifIndex, String regType, String domain, InternalBrowseListener listener)
448
+ throws DNSSDException;
449
+
450
+ abstract protected DNSSDService _resolve( int flags, int ifIndex, String serviceName, String regType,
451
+ String domain, InternalResolveListener listener)
452
+ throws DNSSDException;
453
+
454
+ abstract protected DNSSDRegistration _register( int flags, int ifIndex, String serviceName, String regType,
455
+ String domain, String host, int port, TXTRecord txtRecord, InternalRegisterListener listener)
456
+ throws DNSSDException;
457
+
458
+ abstract protected DNSSDRecordRegistrar _createRecordRegistrar( RegisterRecordListener listener)
459
+ throws DNSSDException;
460
+
461
+ abstract protected DNSSDService _queryRecord( int flags, int ifIndex, String serviceName, int rrtype,
462
+ int rrclass, InternalQueryListener listener)
463
+ throws DNSSDException;
464
+
465
+ abstract protected DNSSDService _enumerateDomains( int flags, int ifIndex, InternalDomainListener listener)
466
+ throws DNSSDException;
467
+
468
+ abstract protected String _constructFullName( String serviceName, String regType, String domain)
469
+ throws DNSSDException;
470
+
471
+ abstract protected int _reconfirmRecord( int flags, int ifIndex, String fullName, int rrtype,
472
+ int rrclass, byte[] rdata);
473
+
474
+ abstract protected String _getNameForIfIndex( int ifIndex);
475
+
476
+ abstract protected int _getIfIndexForName( String ifName);
477
+
478
+ protected static InternalDNSSD fInstance;
479
+
480
+ static
481
+ {
482
+ try
483
+ {
484
+ String name = System.getProperty( "com.github.druk.dnssd.DNSSD" );
485
+ if (name == null)
486
+ name = "com.github.druk.dnssd.AppleDNSSD"; // Fall back to Apple-provided class.
487
+ fInstance = (InternalDNSSD) Class.forName(name).newInstance();
488
+ }
489
+ catch( Exception e )
490
+ {
491
+ throw new InternalError( "cannot instantiate DNSSD" + e );
492
+ }
493
+ }
494
+ }
495
+
496
+
497
+ // Concrete implementation of DNSSDException
498
+ class AppleDNSSDException extends DNSSDException
499
+ {
500
+ public AppleDNSSDException( int errorCode) { fErrorCode = errorCode; }
501
+
502
+ public int getErrorCode() { return fErrorCode; }
503
+
504
+ public String getMessage()
505
+ {
506
+ final String kMessages[] = { // should probably be put into a resource or something
507
+ "UNKNOWN",
508
+ "NO_SUCH_NAME",
509
+ "NO_MEMORY",
510
+ "BAD_PARAM",
511
+ "BAD_REFERENCE",
512
+ "BAD_STATE",
513
+ "BAD_FLAGS",
514
+ "UNSUPPORTED",
515
+ "NOT_INITIALIZED",
516
+ "NO_CACHE",
517
+ "ALREADY_REGISTERED",
518
+ "NAME_CONFLICT",
519
+ "INVALID",
520
+ "FIREWALL",
521
+ "INCOMPATIBLE",
522
+ "BAD_INTERFACE_INDEX",
523
+ "REFUSED",
524
+ "NOSUCHRECORD",
525
+ "NOAUTH",
526
+ "NOSUCHKEY",
527
+ "NATTRAVERSAL",
528
+ "DOUBLENAT",
529
+ "BADTIME",
530
+ "BADSIG",
531
+ "BADKEY",
532
+ "TRANSIENT",
533
+ "SERVICENOTRUNNING",
534
+ "NATPORTMAPPINGUNSUPPORTED",
535
+ "NATPORTMAPPINGDISABLED"
536
+ };
537
+
538
+ if (fErrorCode <= UNKNOWN && fErrorCode > ( UNKNOWN - kMessages.length))
539
+ {
540
+ return "DNS-SD Error " + String.valueOf( fErrorCode) + ": " + kMessages[ UNKNOWN - fErrorCode];
541
+ }
542
+ else
543
+ return super.getMessage() + "(" + String.valueOf( fErrorCode) + ")";
544
+ }
545
+
546
+ protected int fErrorCode;
547
+ }
548
+
549
+ // The concrete, default implementation.
550
+ class AppleDNSSD extends InternalDNSSD
551
+ {
552
+ protected void _init(String lib)
553
+ {
554
+ System.loadLibrary(lib);
555
+
556
+ int libInitResult = InitLibrary( 2); // Current version number (must be sync'd with jnilib version)
557
+
558
+ if (libInitResult != DNSSDException.NO_ERROR)
559
+ throw new InternalError( "cannot instantiate DNSSD: " + new AppleDNSSDException( libInitResult).getMessage());
560
+ }
561
+
562
+ static public boolean hasAutoCallbacks; // Set by InitLibrary() to value of AUTO_CALLBACKS
563
+
564
+ protected DNSSDService _makeBrowser( int flags, int ifIndex, String regType, String domain, InternalBrowseListener client)
565
+ throws DNSSDException
566
+ {
567
+ return new AppleBrowser( flags, ifIndex, regType, domain, client);
568
+ }
569
+
570
+ protected DNSSDService _resolve( int flags, int ifIndex, String serviceName, String regType,
571
+ String domain, InternalResolveListener client)
572
+ throws DNSSDException
573
+ {
574
+ return new AppleResolver( flags, ifIndex, serviceName, regType, domain, client);
575
+ }
576
+
577
+ protected DNSSDRegistration _register( int flags, int ifIndex, String serviceName, String regType,
578
+ String domain, String host, int port, TXTRecord txtRecord, InternalRegisterListener client)
579
+ throws DNSSDException
580
+ {
581
+ return new AppleRegistration( flags, ifIndex, serviceName, regType, domain, host, port,
582
+ ( txtRecord != null) ? txtRecord.getRawBytes() : null, client);
583
+ }
584
+
585
+ protected DNSSDRecordRegistrar _createRecordRegistrar( RegisterRecordListener listener)
586
+ throws DNSSDException
587
+ {
588
+ return new AppleRecordRegistrar( listener);
589
+ }
590
+
591
+ protected DNSSDService _queryRecord( int flags, int ifIndex, String serviceName, int rrtype,
592
+ int rrclass, InternalQueryListener client)
593
+ throws DNSSDException
594
+ {
595
+ return new AppleQuery( flags, ifIndex, serviceName, rrtype, rrclass, client);
596
+ }
597
+
598
+ protected DNSSDService _enumerateDomains( int flags, int ifIndex, InternalDomainListener listener)
599
+ throws DNSSDException
600
+ {
601
+ return new AppleDomainEnum( flags, ifIndex, listener);
602
+ }
603
+
604
+ protected String _constructFullName( String serviceName, String regType, String domain)
605
+ throws DNSSDException
606
+ {
607
+ String[] responseHolder = new String[1]; // lame maneuver to get around Java's lack of reference parameters
608
+
609
+ int rc = ConstructName( serviceName, regType, domain, responseHolder);
610
+ if (rc != 0)
611
+ throw new AppleDNSSDException( rc);
612
+
613
+ return responseHolder[0];
614
+ }
615
+
616
+ protected int _reconfirmRecord( int flags, int ifIndex, String fullName, int rrtype,
617
+ int rrclass, byte[] rdata)
618
+ {
619
+ return ReconfirmRecord( flags, ifIndex, fullName, rrtype, rrclass, rdata);
620
+ }
621
+
622
+ protected String _getNameForIfIndex( int ifIndex)
623
+ {
624
+ return new String(GetNameForIfIndex( ifIndex));
625
+ }
626
+
627
+ protected int _getIfIndexForName( String ifName)
628
+ {
629
+ return GetIfIndexForName( ifName);
630
+ }
631
+
632
+
633
+ protected native int ConstructName( String serviceName, String regType, String domain, String[] pOut);
634
+
635
+ protected native int ReconfirmRecord( int flags, int ifIndex, String fullName, int rrtype,
636
+ int rrclass, byte[] rdata);
637
+
638
+ protected native byte[] GetNameForIfIndex( int ifIndex);
639
+
640
+ protected native int GetIfIndexForName( String ifName);
641
+
642
+ protected static native int InitLibrary( int callerVersion);
643
+ }
644
+
645
+ class AppleService implements DNSSDService, Runnable
646
+ {
647
+ public AppleService(BaseListener listener) { fNativeContext = 0; fListener = listener; }
648
+
649
+ public void stop() { this.HaltOperation(); }
650
+
651
+ /* Block until data arrives, or one second passes. Returns 1 if data present, 0 otherwise. */
652
+ protected native int BlockForData();
653
+
654
+ /* Call ProcessResults when data appears on socket descriptor. */
655
+ protected native int ProcessResults();
656
+
657
+ protected synchronized native void HaltOperation();
658
+
659
+ protected void ThrowOnErr( int rc) throws DNSSDException
660
+ {
661
+ if (rc != 0)
662
+ throw new AppleDNSSDException( rc);
663
+ }
664
+
665
+ protected long /* warning */ fNativeContext; // Private storage for native side
666
+
667
+ public void run()
668
+ {
669
+ while ( true )
670
+ {
671
+ // Note: We want to allow our DNS-SD operation to be stopped from other threads, so we have to
672
+ // block waiting for data *outside* the synchronized section. Because we're doing this unsynchronized
673
+ // we have to write some careful code. Suppose our DNS-SD operation is stopped from some other thread,
674
+ // and then immediately afterwards that thread (or some third, unrelated thread) starts a new DNS-SD
675
+ // operation. The Unix kernel always allocates the lowest available file descriptor to a new socket,
676
+ // so the same file descriptor is highly likely to be reused for the new operation, and if our old
677
+ // stale ServiceThread accidentally consumes bytes off that new socket we'll get really messed up.
678
+ // To guard against that, before calling ProcessResults we check to ensure that our
679
+ // fNativeContext has not been deleted, which is a telltale sign that our operation was stopped.
680
+ // After calling ProcessResults we check again, because it's extremely common for callback
681
+ // functions to stop their own operation and start others. For example, a resolveListener callback
682
+ // may well stop the resolve and then start a QueryRecord call to monitor the TXT record.
683
+ //
684
+ // The remaining risk is that between our checking fNativeContext and calling ProcessResults(),
685
+ // some other thread could stop the operation and start a new one using same file descriptor, and
686
+ // we wouldn't know. To prevent this, the AppleService object's HaltOperation() routine is declared
687
+ // synchronized and we perform our checks synchronized on the AppleService object, which ensures
688
+ // that HaltOperation() can't execute while we're doing it. Because Java locks are re-entrant this
689
+ // locking DOESN'T prevent the callback routine from stopping its own operation, but DOES prevent
690
+ // any other thread from stopping it until after the callback has completed and returned to us here.
691
+
692
+ int result = BlockForData();
693
+ synchronized (this)
694
+ {
695
+ if (fNativeContext == 0) break; // Some other thread stopped our DNSSD operation; time to terminate this thread
696
+ if (result == 0) continue; // If BlockForData() said there was no data, go back and block again
697
+ result = ProcessResults();
698
+ if (fNativeContext == 0) break; // Event listener stopped its own DNSSD operation; terminate this thread
699
+ if (result != 0) { fListener.operationFailed(this, result); break; } // If error, notify listener
700
+ }
701
+ }
702
+ }
703
+
704
+ protected BaseListener fListener;
705
+ }
706
+
707
+
708
+ class AppleBrowser extends AppleService
709
+ {
710
+ public AppleBrowser( int flags, int ifIndex, String regType, String domain, InternalBrowseListener client)
711
+ throws DNSSDException
712
+ {
713
+ super(client);
714
+ this.ThrowOnErr( this.CreateBrowser( flags, ifIndex, regType, domain));
715
+ if (!AppleDNSSD.hasAutoCallbacks)
716
+ new Thread(this).start();
717
+ }
718
+
719
+ // Sets fNativeContext. Returns non-zero on error.
720
+ protected native int CreateBrowser( int flags, int ifIndex, String regType, String domain);
721
+ }
722
+
723
+ class AppleResolver extends AppleService
724
+ {
725
+ public AppleResolver( int flags, int ifIndex, String serviceName, String regType,
726
+ String domain, InternalResolveListener client)
727
+ throws DNSSDException
728
+ {
729
+ super(client);
730
+ this.ThrowOnErr( this.CreateResolver( flags, ifIndex, serviceName, regType, domain));
731
+ if (!AppleDNSSD.hasAutoCallbacks)
732
+ new Thread(this).start();
733
+ }
734
+
735
+ // Sets fNativeContext. Returns non-zero on error.
736
+ protected native int CreateResolver( int flags, int ifIndex, String serviceName, String regType,
737
+ String domain);
738
+ }
739
+
740
+ // An AppleDNSRecord is a simple wrapper around a dns_sd DNSRecord.
741
+ class AppleDNSRecord implements DNSRecord
742
+ {
743
+ public AppleDNSRecord( AppleService owner)
744
+ {
745
+ fOwner = owner;
746
+ fRecord = 0; // record always starts out empty
747
+ }
748
+
749
+ public void update( int flags, byte[] rData, int ttl)
750
+ throws DNSSDException
751
+ {
752
+ this.ThrowOnErr( this.Update( flags, rData, ttl));
753
+ }
754
+
755
+ public void remove()
756
+ throws DNSSDException
757
+ {
758
+ this.ThrowOnErr( this.Remove());
759
+ }
760
+
761
+ protected long fRecord; // Really a DNSRecord; sizeof(long) == sizeof(void*) ?
762
+ protected AppleService fOwner;
763
+
764
+ protected void ThrowOnErr( int rc) throws DNSSDException
765
+ {
766
+ if (rc != 0)
767
+ throw new AppleDNSSDException( rc);
768
+ }
769
+
770
+ protected native int Update( int flags, byte[] rData, int ttl);
771
+
772
+ protected native int Remove();
773
+ }
774
+
775
+ class AppleRegistration extends AppleService implements DNSSDRegistration
776
+ {
777
+ public AppleRegistration( int flags, int ifIndex, String serviceName, String regType, String domain,
778
+ String host, int port, byte[] txtRecord, InternalRegisterListener client)
779
+ throws DNSSDException
780
+ {
781
+ super(client);
782
+ this.ThrowOnErr( this.BeginRegister( ifIndex, flags, serviceName, regType, domain, host, port, txtRecord));
783
+ if (!AppleDNSSD.hasAutoCallbacks)
784
+ new Thread(this).start();
785
+ }
786
+
787
+ public DNSRecord addRecord( int flags, int rrType, byte[] rData, int ttl)
788
+ throws DNSSDException
789
+ {
790
+ AppleDNSRecord newRecord = new AppleDNSRecord( this);
791
+
792
+ this.ThrowOnErr( this.AddRecord( flags, rrType, rData, ttl, newRecord));
793
+ return newRecord;
794
+ }
795
+
796
+ public DNSRecord getTXTRecord()
797
+ throws DNSSDException
798
+ {
799
+ return new AppleDNSRecord( this); // A record with ref 0 is understood to be primary TXT record
800
+ }
801
+
802
+ // Sets fNativeContext. Returns non-zero on error.
803
+ protected native int BeginRegister( int ifIndex, int flags, String serviceName, String regType,
804
+ String domain, String host, int port, byte[] txtRecord);
805
+
806
+ // Sets fNativeContext. Returns non-zero on error.
807
+ protected native int AddRecord( int flags, int rrType, byte[] rData, int ttl, AppleDNSRecord destObj);
808
+ }
809
+
810
+ class AppleRecordRegistrar extends AppleService implements DNSSDRecordRegistrar
811
+ {
812
+ public AppleRecordRegistrar( RegisterRecordListener listener)
813
+ throws DNSSDException
814
+ {
815
+ super(listener);
816
+ this.ThrowOnErr( this.CreateConnection());
817
+ if (!AppleDNSSD.hasAutoCallbacks)
818
+ new Thread(this).start();
819
+ }
820
+
821
+ public DNSRecord registerRecord( int flags, int ifIndex, String fullname, int rrtype,
822
+ int rrclass, byte[] rdata, int ttl)
823
+ throws DNSSDException
824
+ {
825
+ AppleDNSRecord newRecord = new AppleDNSRecord( this);
826
+
827
+ this.ThrowOnErr( this.RegisterRecord( flags, ifIndex, fullname, rrtype, rrclass, rdata, ttl, newRecord));
828
+ return newRecord;
829
+ }
830
+
831
+ // Sets fNativeContext. Returns non-zero on error.
832
+ protected native int CreateConnection();
833
+
834
+ // Sets fNativeContext. Returns non-zero on error.
835
+ protected native int RegisterRecord( int flags, int ifIndex, String fullname, int rrtype,
836
+ int rrclass, byte[] rdata, int ttl, AppleDNSRecord destObj);
837
+ }
838
+
839
+ class AppleQuery extends AppleService
840
+ {
841
+ public AppleQuery( int flags, int ifIndex, String serviceName, int rrtype,
842
+ int rrclass, InternalQueryListener client)
843
+ throws DNSSDException
844
+ {
845
+ super(client);
846
+ this.ThrowOnErr( this.CreateQuery( flags, ifIndex, serviceName, rrtype, rrclass));
847
+ if (!AppleDNSSD.hasAutoCallbacks)
848
+ new Thread(this).start();
849
+ }
850
+
851
+ // Sets fNativeContext. Returns non-zero on error.
852
+ protected native int CreateQuery( int flags, int ifIndex, String serviceName, int rrtype, int rrclass);
853
+ }
854
+
855
+ class AppleDomainEnum extends AppleService
856
+ {
857
+ public AppleDomainEnum( int flags, int ifIndex, InternalDomainListener client)
858
+ throws DNSSDException
859
+ {
860
+ super(client);
861
+ this.ThrowOnErr( this.BeginEnum( flags, ifIndex));
862
+ if (!AppleDNSSD.hasAutoCallbacks)
863
+ new Thread(this).start();
864
+ }
865
+
866
+ // Sets fNativeContext. Returns non-zero on error.
867
+ protected native int BeginEnum( int flags, int ifIndex);
868
+ }
869
+
870
+ //CHECKSTYLE:ON