Giter Site home page Giter Site logo

Comments (13)

sebastianhaberey avatar sebastianhaberey commented on July 23, 2024 1

I haven't looked into this very deeply but my guess is, they'd have to use the method described above:

  1. Do discovery using special service type _services._dns-sd._udp
  2. Receive list of all service types in network
  3. Do discovery for each service type

That would give you a complete list of all service types and services in the network.

from nsd.

sebastianhaberey avatar sebastianhaberey commented on July 23, 2024

To my understanding, there's no wildcard in the DNS-SD specification.

On the plus side, chapter 9 about service type enumeration states that if you use the special type _services._dns-sd._udp, you should get an enumeration of service types. You could then start a query for each service type received, and get all the devices on your network.

Right now the plugin doesn't support this special type (the string doesn't pass the validation regex) but I will have a look at this because it could definitely be useful.

from nsd.

guyluz11 avatar guyluz11 commented on July 23, 2024

As I wrote on osociety/vernet#6 if there is an option to search for all services that start with TCP or search a list of known services this could also be a good start.

from nsd.

sebastianhaberey avatar sebastianhaberey commented on July 23, 2024

search for all services that start with TCP or search a list of known services

I believe that both of these options are not supported by the DNS-SD specification. Consequently, the platform APIs (NsdManager on Android, NetService on iOS / macOS) do not support this. Do correct me if I'm wrong.

from nsd.

guyluz11 avatar guyluz11 commented on July 23, 2024

Not that I know of.
But now I am curious how avahi-browse --all and mdns-scan do that on Linux.

And how does other apps on android do that like Network Scanner

from nsd.

sebastianhaberey avatar sebastianhaberey commented on July 23, 2024

I've implemented the above approach and it passes the integration test on Android / macOS / iOS. So in the new version (1.2.0) you can start a discovery like this:

final discovery = await startDiscovery('_services._dns-sd._udp', autoResolve: false);

The autoResolve flag is important because the results are not real services and cannot be resolved. The discovery.services list will then be populated with the answers. The answers look like this:

[MethodChannelNsdPlatform] [2022-01-21 12:19:56.941821] [calls] Callback: onServiceDiscovered {service.type: _tcp.local, service.host: null, service.name: _foo, handle: a353ff28-40dd-425d-a5a0-9966eea0c708}
[MethodChannelNsdPlatform] [2022-01-21 12:19:56.944118] [calls] Callback: onServiceDiscovered {service.type: _tcp.local, service.host: null, service.name: _bar, handle: a353ff28-40dd-425d-a5a0-9966eea0c708}

The first component of the service type (e.g. _foo) is contained in the service name attribute, the second component of the service type (e.g. _tcp) is contained in the service type attribute.

Even though using a service structure to represent a service type feels like a hack, it seems to be consistent on Android / macOS / iOS platform APIs. Since they are both doing it, I chose to adapt the same behavior for the plugin.

from nsd.

guyluz11 avatar guyluz11 commented on July 23, 2024

Testing it now looks good.

have a couple of questions

  • Host and Port are unknown. Is it a bug? is it a work in progress?.
  • Using the default service _googlecast._tcp the discover finds my MiBox, but I can't see it when using the new discover all that you just implemented. Have I found a bug?.
    Not sure if this is related, MIBOX show as Type _googlecast._tcp and using the new method the devices are shown as _tcp.local.
  • I think it will be good to change the default search in the example to search for all services
    final discovery = await startDiscovery(serviceType);

from nsd.

sebastianhaberey avatar sebastianhaberey commented on July 23, 2024
  1. A discovery of _services._dns-sd._udp does not find services, it finds service types. They don't have ports or hosts.
  2. The new feature is not a discover all. It finds service types. It should find the service type _googlecast._tcp in your case. You can then use the service type to find all services of the type.
  3. Good idea about updating the example, will put this on my backlog.

from nsd.

sebastianhaberey avatar sebastianhaberey commented on July 23, 2024

You can enable call logging using

enableLogging(LogTopic.calls);

If you post the log here, I'll have a look at it.

from nsd.

guyluz11 avatar guyluz11 commented on July 23, 2024

it finds service types.

Totally forgot about that, yes it finds _googlecast.tcp.local nice.

Thanks for solving that, can I get the device IP from the result by pinging by name or hostname?

from nsd.

sebastianhaberey avatar sebastianhaberey commented on July 23, 2024

IPs are not part of the plugin right now (see #7). So yes, for now you'd have to lookup the host name received using something like InternetAddress.lookup.

from nsd.

guyluz11 avatar guyluz11 commented on July 23, 2024

Ok thanks, will try InternetAddress.lookup for IP.

from nsd.

oguzhaninal avatar oguzhaninal commented on July 23, 2024
_services._dns-sd._udp

Hello, i'm trying to find service type by using '_services._dns-sd._udp' but i got Callback: onDiscoveryStartFailed {handle: 06ac4af5-1301-4b78-9460-6dc6c16078d0}. I added info.plist

<key>NSBonjourServices</key>
<array>
<string>_http._tcp</string>
<string>_services._dns-sd._udp</string>
<string>_googlecast._tcp</string>
</array>

Can you please help me? @sebastianhaberey

from nsd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.