Releases: gibme-npm/multicast
Releases · gibme-npm/multicast
v22.0.1
What's Changed
Breaking changes
setTTLremoved —MulticastSocket.setTTL(ttl)is gone. The library hardcodesIP_MULTICAST_TTL = 255at bind so the RFC 6762 §11 outbound invariant cannot be silently broken at runtime.
RFC 6762 §11
- Multicast-destination exemption now honored — Packets received on the shared multicast socket are accepted regardless of source IP, per RFC 6762 §11's carve-out for multicast-destination packets. This fixes cross-subnet-overlay multicast traffic that was previously being dropped. Packets received on per-interface unicast sockets still receive the source-subnet check.
- README §RFC 6762 §11 rewritten — Crisp SHOULD/MUST mapping, multicast-destination exemption documented, explicit note that the
IP_RECVTTLgap in Node'sdgramis upstream and not worked around from userspace.
Input validation
multicastGroupvalidated upfront — A non-multicast address now throwsmulticastGroup X is not a multicast addressbefore any socket allocation, instead of surfacing as a lateaddMembership EADDRNOTAVAIL. Newis_multicasthelper is exported from@gibme/multicast/helpers.compare_IP_addressesthrows on mixed-family inputs — Previously returned a meaningless ordering when comparing IPv4 to IPv6.
IPv6 zone-id handling
fromSelfis now zone-id-tolerant — Node 22'sdgramdelivers IPv6 link-localrinfo.addresswith a%ifacesuffix; the prior exact-string match missed it.dispatch_messagenow strips the suffix before comparing against bound addresses.srcAddressandhostnormalized — The same zone-id strip is applied at the three sites that match against bound addresses (create()host check,send()unicast-path,send()multicast-path).
Helpers
get_addressesdedup fixed — Was[...new Set(addresses)]which deduped by object reference (a no-op for freshly-constructed instances); now aMapkeyed by.addressstring.get_addressesrequiresaddr.cidr— Throws ifos.networkInterfaces()returns an entry without it. Dead-codenetmask_to_prefixfallback (IPv4-only dotted-decimal parser) removed.is_on_local_linkIPv6 link-local comment — Rewritten to acknowledge both RFC 4291 §2.4 (FE80::/10 reserved prefix) and §2.5.6 (link-local format requires middle 54 bits zero), and explain why the wider /10 check is used for inbound filtering.
Documentation
- JSDoc on
send()andSend.Options.useMulticastSocket— Concurrency note: combininguseMulticastSocket: truewithsrcAddressmutates per-socket state on the shared multicast socket viasetMulticastInterface. Concurrent calls race; serialize them in the caller, or use the default per-interface unicast path (race-free). - JSDoc on
setMulticastLoopback— Explains that it only mutatesIP_MULTICAST_LOOPon the shared multicast socket and that the authoritative user-visible loopback gate is the check insidedispatch_message.
Tests
101/101 pass. Added 8 regression tests under a new input validation and dispatch hardening block covering all of the above.
Full Changelog: v22.0.0...v22.0.1
v22.0.0
What's Changed
- Node >=22 — Dropped Node 20 support, CI matrix now tests Node 22 and 24
- node:test migration — Replaced mocha/ts-node with node:test/tsx
- OIDC publishing — CI now uses npm trusted publishing instead of classic NPM_TOKEN
- GitHub Actions v4 — Bumped all workflow actions to latest
- TypeScript config cleanup — Removed deprecated
downlevelIteration,dom/scripthostlibs; addedrootDir - Fixed test race condition — Multi-interface multicast loopback could poison the multiple-messages test with leftover packets
- Improved README — Added badges, architecture overview, helper exports documentation, IPv6 and error handling examples
v20.02
Multisocket Socket Library
An abstract multicast socket library designed to handle some of the platform specific implementation details that
make it difficult to write a cross platform multicast socket library.
Documentation
https://gibme-npm.github.io/multicast
Features
- IPv4 and IPv6 Support
- Windows, Linux, and Mac OS X Support
- Cross Platform
- Asynchronous
- Non-Blocking
- Supports Multicast and Unicast Messages
- Supports Joining and Leaving Multicast Groups
- Proper handling of listening on all interfaces
- Creates a singular multicast socket for listening (or sending)
- Creates a separate unicast socket for each interface for receiving unicast replies and/or sending messages (to ensure it goes out on all interfaces when bound to all)
- Ability to listen on one interface (by IP or name)
- Supports dynamic TTL
- Loopback support
Sample Code
import { MulticastSocket } from '@gibme/multicast';
(async () => {
const socket = await MulticastSocket.create({
port: 5959,
multicastGroup: '224.0.0.251',
loopback: true
});
socket.on('message', (message, remote, fromSelf) => {
console.log({message, remote, fromSelf});
})
socket.send('Hello World');
});v20.0.1
Multisocket Socket Library
An abstract multicast socket library designed to handle some of the platform specific implementation details that
make it difficult to write a cross platform multicast socket library.
Documentation
https://gibme-npm.github.io/multicast
Features
- IPv4 and IPv6 Support
- Windows, Linux, and Mac OS X Support
- Cross Platform
- Asynchronous
- Non-Blocking
- Supports Multicast and Unicast Messages
- Supports Joining and Leaving Multicast Groups
- Proper handling of listening on all interfaces
- Creates a singular multicast socket for listening (or sending)
- Creates a separate unicast socket for each interface for receiving unicast replies and/or sending messages (to ensure it goes out on all interfaces when bound to all)
- Ability to listen on one interface (by IP or name)
- Supports dynamic TTL
- Loopback support
Sample Code
import { MulticastSocket } from '@gibme/multicast';
(async () => {
const socket = await MulticastSocket.create({
port: 5959,
multicastGroup: '224.0.0.251',
loopback: true
});
socket.on('message', (message, remote, fromSelf) => {
console.log({message, remote, fromSelf});
})
socket.send('Hello World');
});v20.0.0
Updated dependencies
v2.0.0: Massive overhaul of library
- We now open multiple sockets instead of a singular socket due to flakiness across platforms: - Actual Multicast socket opens to receive actual multicast messages. Can also be used for sending with some quirks in behavior as documented in send() comments - Individual sockets for each of the interfaces found and/or specified. These are used for listening for unicast replies which are used by multiple multicast protocols. - Added proper types for emitted events - Re-worked the `send()` logic to account for the changes in sockets from above - Renamed a number of properties
v1.0.0: - updated dependencies
- merged types into namespace
v0.0.1
initial commit