react-native-zeroconf 0.16.1 → 0.17.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 (44) hide show
  1. package/NOTICE +0 -3
  2. package/README.md +1 -1
  3. package/android/build.gradle +0 -3
  4. package/android/src/main/java/com/balthazargronon/RCTZeroconf/ZeroConfImplFactory.java +1 -1
  5. package/android/src/main/java/com/balthazargronon/RCTZeroconf/Zeroconf.java +12 -2
  6. package/android/src/main/java/com/balthazargronon/RCTZeroconf/ZeroconfModule.java +129 -4
  7. package/android/src/main/java/com/balthazargronon/RCTZeroconf/ZeroconfOptions.java +72 -0
  8. package/android/src/main/java/com/balthazargronon/RCTZeroconf/dnssd/DnssdImpl.java +633 -0
  9. package/android/src/main/java/com/balthazargronon/RCTZeroconf/nsd/NsdServiceImpl.java +331 -34
  10. package/android/src/main/java/com/balthazargronon/RCTZeroconf/nsd/ServiceTypesQuery.java +296 -0
  11. package/android/src/main/java/com/github/druk/dnssd/DNSSDEmbedded.java +1 -1
  12. package/android/src/main/jni/mdnsresponder/mDNSShared/dnssd_clientshim.c +59 -22
  13. package/dist/index.js +234 -48
  14. package/index.d.ts +101 -6
  15. package/ios/RNZeroconf/RNZeroconf.m +285 -22
  16. package/package.json +28 -4
  17. package/src/index.js +214 -44
  18. package/windows/ExperimentalFeatures.props +33 -0
  19. package/windows/NuGet.config +11 -0
  20. package/windows/RNZeroconf/RNZeroconf.cpp +227 -0
  21. package/windows/RNZeroconf/RNZeroconf.def +3 -0
  22. package/windows/RNZeroconf/RNZeroconf.h +70 -0
  23. package/windows/RNZeroconf/RNZeroconf.rc +0 -0
  24. package/windows/RNZeroconf/RNZeroconf.vcxproj +150 -0
  25. package/windows/RNZeroconf/RNZeroconf.vcxproj.filters +50 -0
  26. package/windows/RNZeroconf/ReactPackageProvider.cpp +20 -0
  27. package/windows/RNZeroconf/ReactPackageProvider.h +24 -0
  28. package/windows/RNZeroconf/ReactPackageProvider.idl +9 -0
  29. package/windows/RNZeroconf/ZeroconfCore.cpp +1042 -0
  30. package/windows/RNZeroconf/ZeroconfCore.h +165 -0
  31. package/windows/RNZeroconf/pch.cpp +1 -0
  32. package/windows/RNZeroconf/pch.h +30 -0
  33. package/windows/RNZeroconf/resource.h +5 -0
  34. package/windows/RNZeroconf/targetver.h +8 -0
  35. package/windows/RNZeroconf.sln +43 -0
  36. package/android/src/main/java/com/balthazargronon/RCTZeroconf/rx2dnssd/DnssdImpl.java +0 -305
  37. package/android/src/main/java/com/github/druk/rx2dnssd/BonjourService.java +0 -400
  38. package/android/src/main/java/com/github/druk/rx2dnssd/Rx2BrowseListener.java +0 -55
  39. package/android/src/main/java/com/github/druk/rx2dnssd/Rx2Dnssd.java +0 -127
  40. package/android/src/main/java/com/github/druk/rx2dnssd/Rx2DnssdCommon.java +0 -280
  41. package/android/src/main/java/com/github/druk/rx2dnssd/Rx2DnssdEmbedded.java +0 -31
  42. package/android/src/main/java/com/github/druk/rx2dnssd/Rx2QueryListener.java +0 -70
  43. package/android/src/main/java/com/github/druk/rx2dnssd/Rx2RegisterListener.java +0 -47
  44. package/android/src/main/java/com/github/druk/rx2dnssd/Rx2ResolveListener.java +0 -51
@@ -1,400 +0,0 @@
1
- /*
2
- * Copyright (C) 2016 Andriy Druk
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- package com.github.druk.rx2dnssd;
17
-
18
- import android.os.Parcel;
19
- import android.os.Parcelable;
20
- import androidx.annotation.NonNull;
21
- import androidx.annotation.Nullable;
22
-
23
- import java.net.Inet4Address;
24
- import java.net.Inet6Address;
25
- import java.net.InetAddress;
26
- import java.util.ArrayList;
27
- import java.util.Collections;
28
- import java.util.HashMap;
29
- import java.util.List;
30
- import java.util.Map;
31
-
32
- /**
33
- * A class representing bonjour service
34
- */
35
- //I don't wanna split this class and its builder
36
- @SuppressWarnings("PMD.GodClass")
37
- public class BonjourService implements Parcelable {
38
-
39
- /**
40
- * Flag that indicate that Bonjour service was lost
41
- */
42
- public static final int LOST = 1 << 8;
43
- public static final Creator<BonjourService> CREATOR = new Creator<BonjourService>() {
44
- @NonNull
45
- public BonjourService createFromParcel(@NonNull Parcel source) {
46
- return new BonjourService(source);
47
- }
48
-
49
- @NonNull
50
- public BonjourService[] newArray(int size) {
51
- return new BonjourService[size];
52
- }
53
- };
54
-
55
- private final int flags;
56
- private final String serviceName;
57
- private final String regType;
58
- private final String domain;
59
- private final List<InetAddress> inetAddresses;
60
- private final Map<String, String> dnsRecords;
61
- private final int ifIndex;
62
- private final String hostname;
63
- private final int port;
64
-
65
- protected BonjourService(@NonNull Builder builder) {
66
- this.flags = builder.flags;
67
- this.serviceName = builder.serviceName;
68
- this.regType = builder.regType;
69
- this.domain = builder.domain;
70
- this.ifIndex = builder.ifIndex;
71
- this.inetAddresses = Collections.unmodifiableList(builder.inetAddresses);
72
- this.dnsRecords = Collections.unmodifiableMap(builder.dnsRecords);
73
- this.hostname = builder.hostname;
74
- this.port = builder.port;
75
- }
76
-
77
- protected BonjourService(@NonNull Parcel in) {
78
- this.flags = in.readInt();
79
- this.serviceName = in.readString();
80
- this.regType = in.readString();
81
- this.domain = in.readString();
82
- this.dnsRecords = readMap(in);
83
- this.inetAddresses = readAddresses(in);
84
- this.ifIndex = in.readInt();
85
- this.hostname = in.readString();
86
- this.port = in.readInt();
87
- }
88
-
89
- private static void writeAddresses(Parcel dest, List<InetAddress> val) {
90
- if (val == null) {
91
- dest.writeInt(-1);
92
- return;
93
- }
94
- int n = val.size();
95
- dest.writeInt(n);
96
- for (InetAddress address : val) {
97
- dest.writeSerializable(address);
98
- }
99
- }
100
-
101
- private static List<InetAddress> readAddresses(Parcel in) {
102
- int n = in.readInt();
103
- if (n < 0) {
104
- return null;
105
- }
106
- List<InetAddress> result = new ArrayList<>();
107
- for (int i = 0; i < n; i++) {
108
- result.add((InetAddress) in.readSerializable());
109
- }
110
- return Collections.unmodifiableList(result);
111
- }
112
-
113
- private static void writeMap(Parcel dest, Map<String, String> val) {
114
- if (val == null) {
115
- dest.writeInt(-1);
116
- return;
117
- }
118
- int n = val.size();
119
- dest.writeInt(n);
120
- for (Map.Entry<String, String> entry : val.entrySet()) {
121
- dest.writeString(entry.getKey());
122
- dest.writeString(entry.getValue());
123
- }
124
- }
125
-
126
- private static Map<String, String> readMap(Parcel in) {
127
- int n = in.readInt();
128
- if (n < 0) {
129
- return null;
130
- }
131
- Map<String, String> result = new HashMap<>();
132
- for (int i = 0; i < n; i++) {
133
- String key = in.readString();
134
- String value = in.readString();
135
- if (key != null && value != null) {
136
- result.put(key, value);
137
- }
138
- }
139
- return Collections.unmodifiableMap(result);
140
- }
141
-
142
- /** Get flags */
143
- public int getFlags() {
144
- return flags;
145
- }
146
-
147
- /** Get the service name */
148
- @NonNull
149
- public String getServiceName() {
150
- return serviceName;
151
- }
152
-
153
- /** Get reg type */
154
- @NonNull
155
- public String getRegType() {
156
- return regType;
157
- }
158
-
159
- /** Get domain */
160
- @Nullable
161
- public String getDomain() {
162
- return domain;
163
- }
164
-
165
- /** Get if index */
166
- public int getIfIndex() {
167
- return ifIndex;
168
- }
169
-
170
- /** Get hostname */
171
- @Nullable
172
- public String getHostname() {
173
- return hostname;
174
- }
175
-
176
- /** Get port */
177
- public int getPort() {
178
- return port;
179
- }
180
-
181
- /** Get TXT records */
182
- @NonNull
183
- public Map<String, String> getTxtRecords() {
184
- return dnsRecords;
185
- }
186
-
187
- /** Get ipv4 address */
188
- @Nullable
189
- public Inet4Address getInet4Address() {
190
- for (InetAddress inetAddress : inetAddresses) {
191
- if (inetAddress instanceof Inet4Address) {
192
- return (Inet4Address) inetAddress;
193
- }
194
- }
195
- return null;
196
- }
197
-
198
- /** Get ipv6 address */
199
- @Nullable
200
- public Inet6Address getInet6Address() {
201
- for (InetAddress inetAddress : inetAddresses) {
202
- if (inetAddress instanceof Inet6Address) {
203
- return (Inet6Address) inetAddress;
204
- }
205
- }
206
- return null;
207
- }
208
-
209
- public List<InetAddress> getInetAddresses() {
210
- return inetAddresses;
211
- }
212
-
213
- /**
214
- * Get status of bonjour service
215
- *
216
- * @return true if service was lost
217
- */
218
- public boolean isLost() {
219
- return (flags & LOST) == LOST;
220
- }
221
-
222
- @Override
223
- //This code was generated by IDEA, and I don't wanna make it less readable
224
- @SuppressWarnings({"PMD.IfStmtsMustUseBraces", "PMD.SimplifyBooleanReturns"})
225
- public boolean equals(Object o) {
226
- if (this == o) return true;
227
- if (!(o instanceof BonjourService)) return false;
228
-
229
- BonjourService that = (BonjourService) o;
230
-
231
- if (ifIndex != that.ifIndex) return false;
232
- if (serviceName != null ? !serviceName.equals(that.serviceName) : that.serviceName != null) return false;
233
- if (regType != null ? !regType.equals(that.regType) : that.regType != null) return false;
234
- return !(domain != null ? !domain.equals(that.domain) : that.domain != null);
235
-
236
- }
237
-
238
- @Override
239
- public int hashCode() {
240
- int result = serviceName != null ? serviceName.hashCode() : 0;
241
- result = 31 * result + (regType != null ? regType.hashCode() : 0);
242
- result = 31 * result + (domain != null ? domain.hashCode() : 0);
243
- result = 31 * result + ifIndex;
244
- return result;
245
- }
246
-
247
- @Override
248
- public int describeContents() {
249
- return 0;
250
- }
251
-
252
- @Override
253
- public void writeToParcel(@NonNull Parcel dest, int flags) {
254
- dest.writeInt(this.flags);
255
- dest.writeString(this.serviceName);
256
- dest.writeString(this.regType);
257
- dest.writeString(this.domain);
258
- writeMap(dest, this.dnsRecords);
259
- writeAddresses(dest, this.inetAddresses);
260
- dest.writeInt(this.ifIndex);
261
- dest.writeString(this.hostname);
262
- dest.writeInt(this.port);
263
- }
264
-
265
- @NonNull
266
- @Override
267
- public String toString() {
268
- return "BonjourService{"
269
- + "flags=" + flags
270
- + ", domain='" + domain + '\''
271
- + ", regType='" + regType + '\''
272
- + ", serviceName='" + serviceName + '\''
273
- + ", dnsRecords=" + dnsRecords
274
- + ", ifIndex=" + ifIndex
275
- + ", hostname='" + hostname + '\''
276
- + ", port=" + port
277
- + '}';
278
- }
279
-
280
- public static class Builder {
281
- private final int flags;
282
- private final String serviceName;
283
- private final String regType;
284
- private final String domain;
285
- private final int ifIndex;
286
- private List<InetAddress> inetAddresses = new ArrayList<>();
287
- //mutable version
288
- private Map<String, String> dnsRecords = new HashMap<>();
289
- private String hostname;
290
- private int port;
291
-
292
- /**
293
- * Constructs a builder initialized to input parameters
294
- *
295
- * @param flags flags of BonjourService.
296
- * @param ifIndex ifIndex of BonjourService.
297
- * @param serviceName serviceName of BonjourService.
298
- * @param regType regType of BonjourService.
299
- * @param domain domain of BonjourService.
300
- */
301
- public Builder(int flags, int ifIndex, @NonNull String serviceName, @NonNull String regType, String domain) {
302
- this.flags = flags;
303
- this.serviceName = serviceName;
304
- this.regType = regType;
305
- this.domain = domain;
306
- this.ifIndex = ifIndex;
307
- }
308
-
309
- /**
310
- * Constructs a builder initialized to the contents of existed BonjourService object
311
- *
312
- * @param service the initial contents of the object.
313
- */
314
- public Builder(@NonNull BonjourService service) {
315
- this.flags = service.flags;
316
- this.serviceName = service.serviceName;
317
- this.regType = service.regType;
318
- this.domain = service.domain;
319
- this.ifIndex = service.ifIndex;
320
- this.dnsRecords = new HashMap<>(service.dnsRecords);
321
- this.inetAddresses = new ArrayList<>(service.inetAddresses);
322
- this.hostname = service.hostname;
323
- this.port = service.port;
324
- }
325
-
326
- /**
327
- * Appends hostname of service
328
- *
329
- * @param hostname the hostname of service.
330
- * @return this builder.
331
- */
332
- @NonNull
333
- public Builder hostname(String hostname) {
334
- this.hostname = hostname;
335
- return this;
336
- }
337
-
338
- /**
339
- * Appends port
340
- *
341
- * @param port the port of service.
342
- * @return this builder.
343
- */
344
- @NonNull
345
- public Builder port(int port) {
346
- this.port = port;
347
- return this;
348
- }
349
-
350
- /**
351
- * Appends TXT records of service
352
- *
353
- * @param dnsRecords map of TXT records.
354
- * @return this builder.
355
- */
356
- @NonNull
357
- public Builder dnsRecords(Map<String, String> dnsRecords) {
358
- this.dnsRecords = dnsRecords;
359
- return this;
360
- }
361
-
362
- /**
363
- * Appends ipv4 address
364
- *
365
- * @param inet4Address ipv4 address of service.
366
- * @return this builder.
367
- */
368
- @NonNull
369
- public Builder inet4Address(Inet4Address inet4Address) {
370
- this.inetAddresses.add(inet4Address);
371
- return this;
372
- }
373
-
374
- /**
375
- * Appends ipv6 address
376
- *
377
- * @param inet6Address ipv6 address of service.
378
- * @return this builder.
379
- */
380
- @NonNull
381
- public Builder inet6Address(Inet6Address inet6Address) {
382
- this.inetAddresses.add(inet6Address);
383
- return this;
384
- }
385
-
386
- /**
387
- * Constructs a BonjourService object
388
- *
389
- * @return new BonjourService object.
390
- */
391
- @NonNull
392
- public BonjourService build() {
393
- return new BonjourService(this);
394
- }
395
-
396
- public void inetAddress(InetAddress inetAddress) {
397
- this.inetAddresses.add(inetAddress);
398
- }
399
- }
400
- }
@@ -1,55 +0,0 @@
1
- /*
2
- * Copyright (C) 2016 Andriy Druk
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- package com.github.druk.rx2dnssd;
17
-
18
- import com.github.druk.dnssd.BrowseListener;
19
- import com.github.druk.dnssd.DNSSDService;
20
-
21
- import io.reactivex.FlowableEmitter;
22
-
23
- class Rx2BrowseListener implements BrowseListener {
24
- private final FlowableEmitter<? super BonjourService> emitter;
25
-
26
- Rx2BrowseListener(FlowableEmitter<? super BonjourService> emitter) {
27
- this.emitter = emitter;
28
- }
29
-
30
- @Override
31
- public void serviceFound(DNSSDService browser, int flags, int ifIndex, String serviceName, String regType, String domain) {
32
- if (emitter.isCancelled()) {
33
- return;
34
- }
35
- BonjourService service = new BonjourService.Builder(flags, ifIndex, serviceName, regType, domain).build();
36
- emitter.onNext(service);
37
- }
38
-
39
- @Override
40
- public void serviceLost(DNSSDService browser, int flags, int ifIndex, String serviceName, String regType, String domain) {
41
- if (emitter.isCancelled()) {
42
- return;
43
- }
44
- BonjourService service = new BonjourService.Builder(flags | BonjourService.LOST, ifIndex, serviceName, regType, domain).build();
45
- emitter.onNext(service);
46
- }
47
-
48
- @Override
49
- public void operationFailed(DNSSDService service, int errorCode) {
50
- if (emitter.isCancelled()) {
51
- return;
52
- }
53
- emitter.onError(new RuntimeException("DNSSD browse error: " + errorCode));
54
- }
55
- }
@@ -1,127 +0,0 @@
1
- /*
2
- * Copyright (C) 2016 Andriy Druk
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- package com.github.druk.rx2dnssd;
17
-
18
- import androidx.annotation.NonNull;
19
-
20
- import com.github.druk.dnssd.DNSSD;
21
-
22
- import io.reactivex.Flowable;
23
- import io.reactivex.FlowableTransformer;
24
-
25
- /**
26
- * RxDnssd is reactive wrapper for {@link DNSSD}
27
- */
28
- public interface Rx2Dnssd {
29
-
30
- /**
31
- * Browse for instances of a service.<P>
32
- *
33
- * @param regType The registration type being browsed for followed by the protocol, separated by a
34
- * dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
35
- * <p>
36
- * @param domain If non-null, specifies the domain on which to browse for services.
37
- * Most applications will not specify a domain, instead browsing on the
38
- * default domain(s).
39
- * <p>
40
- * @return A {@link Flowable} that represents the active browse operation.
41
- */
42
- @NonNull
43
- Flowable<BonjourService> browse(@NonNull final String regType, @NonNull final String domain);
44
-
45
- /**
46
- * Resolve a {@link Flowable} to a target host name, port number, and txt record.<P>
47
- * <p>
48
- * Note: Applications should NOT use resolve() solely for txt record monitoring - use
49
- * queryRecord() instead, as it is more efficient for this task.<P>
50
- * <p>
51
- * Note: resolve() behaves correctly for typical services that have a single SRV record and
52
- * a single TXT record (the TXT record may be empty.) To resolve non-standard services with
53
- * multiple SRV or TXT records, use queryRecord().<P>
54
- *
55
- * @return A {@link FlowableTransformer} that transform not resolved object to resolved.
56
- */
57
- @NonNull
58
- FlowableTransformer<BonjourService, BonjourService> resolve();
59
-
60
- /**
61
- * Query ipv4 and ipv6 addresses
62
- *
63
- * @return A {@link FlowableTransformer} that transform object without addresses to object with addresses.
64
- */
65
- @NonNull
66
- @Deprecated //renamed: queryIPRecords
67
- FlowableTransformer<BonjourService, BonjourService> queryRecords();
68
-
69
- /**
70
- * Query ipv4 and ipv6 addresses
71
- *
72
- * @return A {@link FlowableTransformer} that transform object without addresses to object with addresses.
73
- */
74
- @NonNull
75
- FlowableTransformer<BonjourService, BonjourService> queryIPRecords();
76
-
77
- /**
78
- * Query ipv4 address
79
- *
80
- * @return A {@link FlowableTransformer} that transform object without address to object with address.
81
- */
82
- @NonNull
83
- FlowableTransformer<BonjourService, BonjourService> queryIPV4Records();
84
-
85
- /**
86
- * Query ipv6 address
87
- *
88
- * @return A {@link FlowableTransformer} that transform object without address to object with address.
89
- */
90
- @NonNull
91
- FlowableTransformer<BonjourService, BonjourService> queryIPV6Records();
92
-
93
- /**
94
- * Query ipv4 and ipv6 addresses
95
- *
96
- * @return A {@link Flowable} with ip addresses
97
- */
98
- @NonNull
99
- Flowable<BonjourService> queryIPRecords(BonjourService bs);
100
-
101
- /**
102
- * Query ipv4 address
103
- *
104
- * @return A {@link Flowable}
105
- */
106
- @NonNull
107
- Flowable<BonjourService> queryIPV4Records(BonjourService bs);
108
-
109
- /**
110
- * Query ipv6 address
111
- *
112
- * @return A {@link Flowable}
113
- */
114
- @NonNull
115
- Flowable<BonjourService> queryIPV6Records(BonjourService bs);
116
-
117
- /**
118
- * Query ipv6 address
119
- *
120
- * @return A {@link Flowable}
121
- */
122
- @NonNull
123
- Flowable<BonjourService> queryTXTRecords(BonjourService bs);
124
-
125
- @NonNull
126
- Flowable<BonjourService> register(@NonNull final BonjourService bs);
127
- }