Skip to content

Commit 481d71a

Browse files
authored
Merge pull request #37 from MatrixAI/feature-remove-warning-2
Removed deprecation warning when accessing socket FD
2 parents eae3b34 + 419e00c commit 481d71a

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

.gitlab-ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ build:windows:
184184
- refreshenv
185185
- npm install --ignore-scripts
186186
- $env:Path = "$(npm root)\.bin;" + $env:Path
187-
- npm run prebuild --verbose;
187+
# - npm run prebuild --verbose;
188188
- npm test -- --ci --coverage
189189
artifacts:
190190
when: always
@@ -218,8 +218,8 @@ build:macos:
218218
- hash -r
219219
- npm install --ignore-scripts
220220
- export PATH="$(npm root)/.bin:$PATH"
221-
- npm run prebuild --verbose -- --arch x64
222-
- npm run prebuild --verbose -- --arch arm64
221+
# - npm run prebuild --verbose -- --arch x64
222+
# - npm run prebuild --verbose -- --arch arm64
223223
- npm test -- --ci --coverage
224224
artifacts:
225225
when: always

src/MDNS.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ class MDNS {
168168
* @param opts.hostname - The hostname to use for the MDNS stack. Defaults to the OS hostname.
169169
* @param opts.advertise - Allows MDNS to advertise it's hostnames. Defaults to true.
170170
* @param opts.id - The unique unsigned 16 bit integer ID used for all outgoing MDNS packets. Defaults to a random number.
171+
* @param opts.enableLinuxNativeSocketOptions - Enables Linux native code to disable `IP_MULTICAST_ALL` and `IPV6_MULTICAST_ALL` to lessen reliance on subnet filtering.
172+
* This will access a deprecated property on the socket to get the file descriptor. Defaults to false.
171173
* @throws {RangeError} - If `opts.groups` is empty.
172174
* @throws {ErrorMDNSSocketInvalidBindAddress} - If a socket cannot bind.
173175
* @throws {ErrorMDNSInterfaceRange} - If no valid interfaces have been found.
@@ -179,6 +181,7 @@ class MDNS {
179181
hostname = utils.getHostname(),
180182
advertise = true,
181183
id = utils.getRandomPacketId(),
184+
disableLinuxMulticastAllOption = false,
182185
}: {
183186
port?: number;
184187
ipv6Only?: boolean;
@@ -187,6 +190,7 @@ class MDNS {
187190
hostname?: string;
188191
advertise?: boolean;
189192
id?: number;
193+
disableLinuxMulticastAllOption?: boolean;
190194
}): Promise<void> {
191195
this.logger.info(`Start ${this.constructor.name}`);
192196

@@ -246,7 +250,7 @@ class MDNS {
246250
'::',
247251
);
248252
unicastSocketClose = close;
249-
if (platform === 'linux') {
253+
if (platform === 'linux' && disableLinuxMulticastAllOption) {
250254
socketUtils.disableSocketMulticastAll(
251255
(unicastSocket as any)._handle.fd,
252256
);
@@ -370,7 +374,7 @@ class MDNS {
370374
);
371375
try {
372376
await Promise.race([socketBindP, errorP]);
373-
if (platform === 'linux') {
377+
if (platform === 'linux' && disableLinuxMulticastAllOption) {
374378
socketUtils.disableSocketMulticastAll((socket as any)._handle.fd);
375379
}
376380
socket.setMulticastInterface(linkLocalSocketHost);

0 commit comments

Comments
 (0)