mdns_responder 0.0.2 copy "mdns_responder: ^0.0.2" to clipboard
mdns_responder: ^0.0.2 copied to clipboard

A Flutter plugin for publishing mDNS (Multicast DNS) services on Android and iOS

๐Ÿ›ฐ๏ธ mdns_responder #

A Flutter plugin for publishing mDNS (Multicast DNS) services on Android and iOS, with support for advanced features like TXT records, host addresses, subtypes, and libp2p compatibility.

โœ… Supports NetService (Bonjour) on iOS

โœ… Uses NsdManager on Android

โœ… Compatible with libp2p, IPFS, and other P2P service discovery protocols


โœจ Features #

  • Publish mDNS services with:
  • Service name, type, and port
  • Host IP addresses (Android only)
  • TXT record attributes (key-value pairs)
  • Subtypes (Android 14+ only)
  • Network identifier (Android only)
  • Fully asynchronous Dart API
  • Platform channel implementation
  • Tested with dns-sd and avahi-browse

๐Ÿš€ Getting Started #

1. Add to pubspec.yaml #

dependencies:
  mdns_responder:
    git:
    url: https://github.com/eelco2k/mdns_responder.git

2. Platform Setup #

โœ… Android

Add the following to your AndroidManifest.xml:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

Subtypes require Android 14+ (API 34).

โœ… iOS

Add Bonjour service types to Info.plist:

<key>NSBonjourServices</key>
<array>
    <string>_p2p._udp</string>
</array>

โœ… Usage #

Import the plugin #

import 'package:mdns_responder/mdns_responder.dart';
import 'package:mdns_responder/models/mdns_service.dart';

Publish a service #

final service = MdnsService(
name: 'peer-abc123',
type: '_p2p._udp',
port: 4001,
hostAddresses: ['192.168.1.42'], // Android only
attributes: {
'id': 'QmPeerID',
'proto': 'libp2p',
},
subtypes: ['_libp2p'], // Android 14+ only
);
await MdnsResponder().publishService(service);

Stop the service #

await MdnsResponder().stopService();

๐Ÿงช Testing #

Unit tests #

flutter test

Includes tests for:

  • MdnsService serialization
  • Mock platform interface
  • Method channel communication

Integration test (example app) #

flutter drive \
--driver integration_test/driver.dart \
--target integration_test/mdns_test.dart

You can also test manually using dns-sd or avahi-browse on the same network.


๐Ÿ” Service Discovery #

To verify your service is visible:

On macOS #

dns-sd -B _p2p._udp

On Linux #

avahi-browse -a

You should see your peer-abc123 service appear.


๐Ÿ“ฆ API Reference #

MdnsService Fields #

Field Type Description
name String Instance name of the service
type String Service type (e.g. _http._tcp)
port int Port number
hostAddresses List IP addresses (Android only)
attributes Map<String, String>? TXT record key-value pairs
subtypes List Subtypes (Android 14+ only)
network String? Network ID (Android only)

๐Ÿ› ๏ธ Roadmap #

  • โŒ Windows / Linux support via FFI or CLI
  • โŒ libp2p TXT record helpers
  • โŒ Subtypes for iOS

๐Ÿ‘ฅ Contributing #

Pull requests are welcome! Please include tests and follow the existing code style.


๐Ÿ“„ License #

MIT License ยฉ 2025 Syzygy interactive media

0
likes
160
points
1
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for publishing mDNS (Multicast DNS) services on Android and iOS

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on mdns_responder

Packages that implement mdns_responder