Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI

on:
pull_request:
branches:
- master

jobs:
test:
name: Test (node-${{ matrix.node-version }})
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['16.x', '20.6.1', '22.18.0']
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install MDNS tools
run: |
sudo apt-get update
sudo apt-get -y install avahi-daemon avahi-discover avahi-utils libnss-mdns mdns-scan libavahi-compat-libdnssd-dev

- name: Start avahi daemon
run: |
sudo service dbus start
sudo service avahi-daemon start
# Wait until avahi is ready to accept connections
timeout 10 sh -c 'until avahi-daemon --check; do sleep 0.5; done'

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test
59 changes: 59 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Release
on:
push:
tags:
- 'v*.*.*'
workflow_dispatch:

jobs:
build:
name: Build and Upload (${{ matrix.os }}, node-${{ matrix.node-version }})
runs-on: ${{ matrix.os }}
environment: release
strategy:
matrix:
os: [macos-14, macos-13, ubuntu-latest]
node-version: ['16.x', '20.6.1', '22.18.0']

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Install MDNS tools (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get -y install avahi-daemon avahi-discover avahi-utils libnss-mdns mdns-scan libavahi-compat-libdnssd-dev

- name: Install dependencies
run: npm ci --ignore-scripts

- name: Build and upload
env:
AWS_ACCESS_KEY_ID: ${{ secrets.NODE_PRE_GYP_AWS_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.NODE_PRE_GYP_AWS_KEY }}
run: sh ./utils/build.sh

publish:
name: Publish to registry
runs-on: ubuntu-latest
environment: release
needs: build
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: '22.18.0'
registry-url: ${{ secrets.REGISTRY_URL }}

- run: npm ci --ignore-scripts

- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
26 changes: 0 additions & 26 deletions .github/workflows/upload_binaries.yml

This file was deleted.

17 changes: 17 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,19 @@
# credentials and local config
.env
.env.*

# development and CI
.github
tests
utils
examples
doc

# build artifacts
build
out

# legacy build tooling
Makefile
wscript
node-waf.bat
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,32 @@ mdns adds multicast DNS service discovery, also known as zeroconf or bonjour to

This is a fork of the `node_mdns` package with additional infrastructure changes to integrate it into Cycling '74's worfklow.

## Contributing and releasing

### Making changes

1. Create a branch, make your changes, bump the version in `package.json`:
```
npm version patch --no-git-tag-version
```
2. Open a PR against `master` — CI will run tests across Node 16, 20, and 22
3. Once reviewed and merged, a maintainer cuts the release by tagging `master`:
```
git pull && git tag v<version> && git push --follow-tags
```

### Publishing

Pushing a `v*.*.*` tag triggers the **Release** workflow, which requires maintainer approval and then:

1. Builds native binaries for `darwin-arm64`, `darwin-x64`, and `linux-x64` across Node 16, 20, and 22 and uploads them to S3
2. Publishes the package to the internal npm registry

To install from the internal registry:
```
npm install @cycling74/mdns
```

## Synopsis

```js
Expand Down
51 changes: 13 additions & 38 deletions lib/resolver_sequence_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,45 +100,20 @@ exports.DNSServiceGetAddrInfo = function DNSServiceGetAddrInfo(options) {
}
}

var _getaddrinfo;
try {
var cares = process.binding('cares_wrap');
function getaddrinfo_complete(err, addresses, cb) {
if (addresses) {
cb(undefined, addresses);
} else if (err === 'ENOENT') {
cb(undefined, []);
} else {
cb(errnoException(err, 'getaddrinfo'));
}
}
function getaddrinfo_0_11(host, family, cb) {
var req = new cares.GetAddrInfoReqWrap()
, err = cares.getaddrinfo(req, host, family, 0, false)
;
req.oncomplete = function oncomplete(err, addresses) {
getaddrinfo_complete(err, addresses, cb);
}
if (err) throw errnoException(err, 'getaddrinfo', host);
}
function getaddrinfo_0_10(host, family, cb) {
var wrap = cares.getaddrinfo(host, family);
if ( ! wrap) {
throw errnoException(process._errno || global.errno, 'getaddrinfo');
}
wrap.oncomplete = function (addresses) {
getaddrinfo_complete((process._errno || global.errno), addresses, cb);
var dns = require('dns');
function _getaddrinfo(host, family, cb) {
dns.lookup(host, { family: family, all: true }, function(err, addresses) {
if (err) {
if (err.code === 'ENOENT' || err.code === 'ENOTFOUND') {
cb(undefined, []);
} else {
cb(err);
}
return;
}
}
// node 0.11+ cares.getaddrinfo function uses request object.
// use appropriate version based on node version number
if (Number(process.version.match(/^v(\d+\.\d+)/)[1]) > 0.1) {
_getaddrinfo = getaddrinfo_0_11;
} else {
_getaddrinfo = getaddrinfo_0_10;
}
} catch (ex) {
_getaddrinfo = process.binding('net').getaddrinfo;
var addrs = addresses || [];
cb(undefined, addrs.map(function(a) { return a.address; }));
});
}

exports.getaddrinfo = function getaddrinfo(options) {
Expand Down
19 changes: 10 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cycling74/mdns",
"version": "2.7.3",
"version": "2.7.4",
"description": "multicast DNS service discovery",
"main": "./lib/mdns.js",
"types": "./index.d.ts",
Expand Down Expand Up @@ -85,7 +85,7 @@
"dependencies": {
"@mapbox/node-pre-gyp": "^1.0.11",
"bindings": "^1.5.0",
"nan": "^2.18.0"
"nan": "^2.26.2"
},
"binary": {
"module_name": "dns_sd_bindings",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_dns_sd.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ exports['DNSServiceRegister()'] = function(t) {
, iface = 0
, name = 'My sh4red stuff'
, type = service_type
, domain = 'somedomain'
, domain = null /* avahi rejects non-.local domains */
, host = null /* avahi throws 'bad param'*/
, port = test_port
, txtRec = Buffer.from('\0')
Expand Down
2 changes: 0 additions & 2 deletions utils/build.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env bash
set -e -u

# test installing from source
echo "building binaries for publishing";
npm install --build-from-source;

node-pre-gyp configure;
node-pre-gyp build;
Expand Down
Loading