From a4ade798892b476f92bb6761aaa6d1ce85ec39cf Mon Sep 17 00:00:00 2001 From: Florian Demmer Date: Thu, 2 Apr 2026 16:13:49 +0100 Subject: [PATCH 01/10] add CI workflow to run on PRs --- .github/workflows/ci.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3b65024 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,30 @@ +name: CI + +on: + pull_request: + branches: + - master + +jobs: + test: + runs-on: ubuntu-latest + name: Test + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.6.1' + + - 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: Install dependencies + run: npm ci + + - name: Run tests + run: npm test From f771c9a6a8ddc8e28499e3995cb1d04d1457fd63 Mon Sep 17 00:00:00 2001 From: Florian Demmer Date: Thu, 2 Apr 2026 16:24:32 +0100 Subject: [PATCH 02/10] start up avahi as part of ci test run --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3b65024..e6b3eb8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,6 +23,9 @@ jobs: 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 avahi-daemon start + - name: Install dependencies run: npm ci From c09a4a54e32e92f4788db6be43b3087e9fdb3047 Mon Sep 17 00:00:00 2001 From: Florian Demmer Date: Thu, 2 Apr 2026 16:26:39 +0100 Subject: [PATCH 03/10] ensure avahi is actually running in CI workflow --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e6b3eb8..280abe6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,11 @@ jobs: 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 avahi-daemon start + 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 From d9df8b30d2408914e886d59d0cc4044e2b0b0cd8 Mon Sep 17 00:00:00 2001 From: Florian Demmer Date: Thu, 2 Apr 2026 16:37:22 +0100 Subject: [PATCH 04/10] replace usage of cares_wrap binding with dns --- lib/resolver_sequence_tasks.js | 51 +++++++++------------------------- tests/test_dns_sd.js | 2 +- 2 files changed, 14 insertions(+), 39 deletions(-) diff --git a/lib/resolver_sequence_tasks.js b/lib/resolver_sequence_tasks.js index f017038..a6bc3e7 100644 --- a/lib/resolver_sequence_tasks.js +++ b/lib/resolver_sequence_tasks.js @@ -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) { diff --git a/tests/test_dns_sd.js b/tests/test_dns_sd.js index 0fe6708..48d5e7d 100755 --- a/tests/test_dns_sd.js +++ b/tests/test_dns_sd.js @@ -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') From 70e21b76f3b90078a8d376f6bf14ef22398099ee Mon Sep 17 00:00:00 2001 From: Florian Demmer Date: Thu, 2 Apr 2026 16:50:51 +0100 Subject: [PATCH 05/10] improved binary upload workflow and build targets for macos and linux target using matrix Window for now remains a tbc --- .github/workflows/upload_binaries.yml | 29 ++++++++++++++++++--------- utils/build.sh | 2 -- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.github/workflows/upload_binaries.yml b/.github/workflows/upload_binaries.yml index bac27d2..ffdd6a2 100644 --- a/.github/workflows/upload_binaries.yml +++ b/.github/workflows/upload_binaries.yml @@ -2,9 +2,14 @@ name: Upload pre-built binaries on: workflow_dispatch jobs: - linux: - runs-on: ubuntu-latest - name: Build and Upload mdns binding + build: + name: Build and Upload (${{ matrix.os }}, node-${{ matrix.node-version }}) + runs-on: ${{ matrix.os }} + 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 @@ -12,15 +17,19 @@ jobs: - name: Use Node.js uses: actions/setup-node@v4 with: - node-version: '20.6.1' - - - name: Install MDNS tools + 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 - run: | - echo "AWS_ACCESS_KEY_ID=${{ secrets.NODE_PRE_GYP_AWS_ID }}" >> .env - echo "AWS_SECRET_ACCESS_KEY=${{ secrets.NODE_PRE_GYP_AWS_KEY }}" >> .env - npm run build \ No newline at end of file + 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 diff --git a/utils/build.sh b/utils/build.sh index 657f6d1..e8ddfa5 100644 --- a/utils/build.sh +++ b/utils/build.sh @@ -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; From b9a28d08da6bfe2e24d7e903457b823a697fc0d5 Mon Sep 17 00:00:00 2001 From: Florian Demmer Date: Thu, 2 Apr 2026 16:53:29 +0100 Subject: [PATCH 06/10] extend CI to cover same node version matrix. --- .github/workflows/ci.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 280abe6..942803d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,8 +7,11 @@ on: jobs: test: + name: Test (node-${{ matrix.node-version }}) runs-on: ubuntu-latest - name: Test + strategy: + matrix: + node-version: ['16.x', '20.6.1', '22.18.0'] steps: - name: Checkout repository uses: actions/checkout@v4 @@ -16,7 +19,7 @@ jobs: - name: Use Node.js uses: actions/setup-node@v4 with: - node-version: '20.6.1' + node-version: ${{ matrix.node-version }} - name: Install MDNS tools run: | From f8a626e3921b5e36cab28b8f498c847027c993a0 Mon Sep 17 00:00:00 2001 From: Florian Demmer Date: Thu, 2 Apr 2026 17:02:22 +0100 Subject: [PATCH 07/10] limit binary upload to release environment --- .github/workflows/upload_binaries.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/upload_binaries.yml b/.github/workflows/upload_binaries.yml index ffdd6a2..7142f68 100644 --- a/.github/workflows/upload_binaries.yml +++ b/.github/workflows/upload_binaries.yml @@ -5,6 +5,7 @@ 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] From bd9a2e4c25f871e28b3a0c2b9a950a6eff066501 Mon Sep 17 00:00:00 2001 From: Florian Demmer Date: Thu, 2 Apr 2026 17:18:00 +0100 Subject: [PATCH 08/10] new release workflow --- .../{upload_binaries.yml => release.yml} | 27 +++++++++++++++++-- .npmignore | 17 ++++++++++++ README.md | 26 ++++++++++++++++++ 3 files changed, 68 insertions(+), 2 deletions(-) rename .github/workflows/{upload_binaries.yml => release.yml} (66%) diff --git a/.github/workflows/upload_binaries.yml b/.github/workflows/release.yml similarity index 66% rename from .github/workflows/upload_binaries.yml rename to .github/workflows/release.yml index 7142f68..1a29a7c 100644 --- a/.github/workflows/upload_binaries.yml +++ b/.github/workflows/release.yml @@ -1,5 +1,9 @@ -name: Upload pre-built binaries -on: workflow_dispatch +name: Release +on: + push: + tags: + - 'v*.*.*' + workflow_dispatch: jobs: build: @@ -34,3 +38,22 @@ jobs: 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 }} diff --git a/.npmignore b/.npmignore index c2713c4..74ece37 100644 --- a/.npmignore +++ b/.npmignore @@ -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 diff --git a/README.md b/README.md index 455610b..d7163e4 100644 --- a/README.md +++ b/README.md @@ -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 && 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 From e1d8913167029e3960aafd95de652acce7a5cbb4 Mon Sep 17 00:00:00 2001 From: Florian Demmer Date: Thu, 2 Apr 2026 17:22:35 +0100 Subject: [PATCH 09/10] version bump to 2.7.4 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index f67fa27..2d8d78f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@cycling74/mdns", - "version": "2.7.3", + "version": "2.7.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@cycling74/mdns", - "version": "2.7.3", + "version": "2.7.4", "hasInstallScript": true, "dependencies": { "@mapbox/node-pre-gyp": "^1.0.11", diff --git a/package.json b/package.json index 18607f8..6924941 100644 --- a/package.json +++ b/package.json @@ -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", From c627e5e095347e826b15cee055547f59973ab254 Mon Sep 17 00:00:00 2001 From: Florian Demmer Date: Thu, 2 Apr 2026 17:32:01 +0100 Subject: [PATCH 10/10] upgrade nan dependencis --- package-lock.json | 15 ++++++++------- package.json | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2d8d78f..5b159f2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@mapbox/node-pre-gyp": "^1.0.11", "bindings": "^1.5.0", - "nan": "^2.18.0" + "nan": "^2.26.2" }, "devDependencies": { "aws-sdk": "^2.1062.0", @@ -983,9 +983,10 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "node_modules/nan": { - "version": "2.18.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.18.0.tgz", - "integrity": "sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w==" + "version": "2.26.2", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.26.2.tgz", + "integrity": "sha512-0tTvBTYkt3tdGw22nrAy50x7gpbGCCFH3AFcyS5WiUu7Eu4vWlri1woE6qHBSfy11vksDqkiwjOnlR7WV8G1Hw==", + "license": "MIT" }, "node_modules/ncp": { "version": "2.0.0", @@ -2343,9 +2344,9 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, "nan": { - "version": "2.18.0", - "resolved": "https://registry.npmjs.org/nan/-/nan-2.18.0.tgz", - "integrity": "sha512-W7tfG7vMOGtD30sHoZSSc/JVYiyDPEyQVso/Zz+/uQd0B0L46gtC+pHha5FFMRpil6fm/AoEcRWyOVi4+E/f8w==" + "version": "2.26.2", + "resolved": "https://registry.npmjs.org/nan/-/nan-2.26.2.tgz", + "integrity": "sha512-0tTvBTYkt3tdGw22nrAy50x7gpbGCCFH3AFcyS5WiUu7Eu4vWlri1woE6qHBSfy11vksDqkiwjOnlR7WV8G1Hw==" }, "ncp": { "version": "2.0.0", diff --git a/package.json b/package.json index 6924941..f6c7c21 100644 --- a/package.json +++ b/package.json @@ -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",