Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong hostname under certain conditions #29

Open
ddaf opened this issue Dec 31, 2014 · 4 comments
Open

Wrong hostname under certain conditions #29

ddaf opened this issue Dec 31, 2014 · 4 comments
Assignees
Labels

Comments

@ddaf
Copy link

ddaf commented Dec 31, 2014

I found a case of mdns-js reporting the wrong hostname of my device.

When parsing the "additional" packet segments it gets obj.host from the A record, but on Chromecast, that record seems to be incorrect when there's a period in the name of the device. Here are the 3 additionals being parsed:

PARSE: additional #0
 { name: 'Chromecast.Bedroom._googlecast._tcp.local',
  type: 33,
  class: 1,
  ttl: 10,
  isQD: false,
  typeName: [Getter],
  className: [Getter],
  flag: [Getter],
  priority: 0,
  weight: 0,
  port: 8009,
  target: 'Chromecast.local' }
PARSE: additional #1
 { name: 'Chromecast.Bedroom._googlecast._tcp.local',
  type: 16,
  class: 1,
  ttl: 10,
  isQD: false,
  typeName: [Getter],
  className: [Getter],
  flag: [Getter],
  data:
   [ 'id=39dc44f5af0f3dd4f370a392d5050f5d',
     've=02',
     'md=Chromecast',
     'ic=/setup/icon.png',
     'fn=Chromecast.Bedroom',
     'ca=5',
     'st=0' ] }
PARSE: additional #2
 { name: 'Chromecast.local',
  type: 1,
  class: 1,
  ttl: 10,
  isQD: false,
  typeName: [Getter],
  className: [Getter],
  flag: [Getter],
  address: '192.168.1.222' }
RETURNED data.host = Chromecast.local

As you see the name is correct in the first 2 additionals but cut at the first period in the last one. I was also wondering if it would be possible to return a "pure" hostname without the .local part appended. Thanks in advance.

Oh and I know you like packet dumps:

0000840000010001000000030b5f676f6f676c6563617374045f746370056c6f63616c00000c0001c00c000c00010000000a0015124368726f6d65636173742e426564726f6f6dc00cc034002100010000000a0013000000001f490a4368726f6d6563617374c01dc034001000010000000a006b2369643d33396463343466356166306633646434663337306133393264353035306635640576653d30320d6d643d4368726f6d65636173741269633d2f73657475702f69636f6e2e706e6715666e3d4368726f6d65636173742e426564726f6f6d0463613d350473743d30c05b000100010000000a0004c0a801de

Happy new year 😄

@kmpm kmpm added the invalid label Jan 1, 2015
@kmpm kmpm self-assigned this Jan 1, 2015
@kmpm
Copy link
Collaborator

kmpm commented Jan 1, 2015

Happy New Year to you too!

This is kind of strange. The packet dump you provided (kudos for that one by the way) actually have exactly what you describe. If i import it into wireshark I will get the same result, the last answer is "Cromecast.local".

It looks as if chromecast messes with the host name if it contains dots. And it really should, dots are not allowed "within" the name, just as separators.

The first answer, class 33/SRV, clearly show that the service Chromecast.Bedroom._googlecast._tcp.local points to a target with the name Chromecast.local.
The last record just confirms the same thing, Chromecast.local have an IP address of 192.168.1.222.

So, everything adds up as it should but I agree that it's sort of inconvenient.
Your Chromecast truncates the host name at the dot and mdns-js or in this case actually mdns-js-packet parses what's sent correctly.

I can imagine this will create some issues if you have several devices which all begins with the same thing and then a dot in the name. The service names will differ but the host/target name would end up being the same but pointing to 2 different IPs.

After some googeling I found a forum thread where the name is mentioned.
https://productforums.google.com/forum/#!topic/chromecast/NlVXLBXZWGo

Make sure the Chromecast device name does not contain any special characters.
Special characters in the Chromecast name (like Emoji or apostrophes) will prevent it from being seen by apps.

This might be a special case of that.

Anyway, I am seriously thinking about just closing this issue since it isn't a error. It correctly shows what the Chromecast device wants to show.

  • Service: Chromecast.Bedroom._googlecast._tcp.local
  • DNS A hostname: Chromecast.local

I can add some cosmetics to hide this fact but I still fear that one would end up with issues when there are 2 or more devices that end up with the same A name.

kmpm added a commit to mdns-js/node-dns-js that referenced this issue Jan 1, 2015
@ddaf
Copy link
Author

ddaf commented Jan 1, 2015

Thank you, this makes sense. Strangely though, in Chrome the name is shown correctly and not fooled by my apparent misuse of dots. I agree that you can close this issue since it is not directly the fault of mdns-js.

Quick question. If I wanted to always get just the name of the device, could I use the service-name and cut it when '._googlecast' is met reliably? I seem to remember in an earlier mdns-js version there was a field with just the name.

@kmpm kmpm added question and removed invalid labels Sep 3, 2015
@bfree-github
Copy link

I've encountered the same issue - TXT records with '.' in them are truncated. This is particularly problematic for A records, which have IP addresses in them. In our case we're also providing an info URL, which has a '.' in the file extension. This would also be problematic for your server example where version numbers have a '.' in them.

This works correctly in the mDNS and mdns modules, but not your mdns-js module.

@kmpm
Copy link
Collaborator

kmpm commented Jan 6, 2016

@bfree-github please file as a separate issue, and please provide a dump of the message if possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants