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

Node 0.11.x support #99

Merged
merged 15 commits into from
Oct 25, 2014
Merged

Node 0.11.x support #99

merged 15 commits into from
Oct 25, 2014

Conversation

donpark
Copy link
Contributor

@donpark donpark commented Oct 19, 2014

With these changes, node_mdns builds and runs under Node 0.11.14 and nan 1.3 although I cannot say with certainty as amount of testing it received with these changes is too little.

@donpark
Copy link
Contributor Author

donpark commented Oct 19, 2014

This PR addresses issue #83

@agnat
Copy link
Owner

agnat commented Oct 19, 2014

Thanks for stepping up, @donpark.

It is a pretty involved change set, though. I'll review it and comment in-line.

@ronkorving, could you do/organize a little gang testing?

@donpark
Copy link
Contributor Author

donpark commented Oct 19, 2014

It is a pretty involved change set, though. I'll review it and comment in-line.

Absolutely. I would've been rather surprised and dismayed if my 'carpet-bombing' PR got merged as-is.
Please do as you see fit. I also don't mind if you only use my PR as hints showing areas affected by Node 0.11.x and use your own changes. Frankly, I think later approach could require less work.

@agnat
Copy link
Owner

agnat commented Oct 21, 2014

Uhu... I catch your drift. Thing is: Quite a while back I decided that I'm done with node. I'm done with it because of issues like this one. I'm fed up with the node teams attitude regarding native modules. So no, I won't fix another breakage caused by @joyent's inability or unwillingness to mitigate the consequences of their changes. I'm still trying to help people out but I won't do any active development. I'm sorry to do this but this is a spare time project and spare time should be fun.

However, I will review it and then we'll go from there. If you, @donpark, don't have the time to clean up the patch maybe someone else does.

cb(undefined, []);
} else {
cb(errnoException(errno, 'getaddrinfo'));
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate Code: The two versions of oncomplete are almost identical. The second version should call the first one and just inject the error argument.

@donpark
Copy link
Contributor Author

donpark commented Oct 21, 2014

NP. Felt the same frustration. I patched node_mdns for a prototype app using atomshell which saw the broadside of 0.11.x related nightmare. Yikes. But it's just a tool and this PR was requested by someone else. Let's just leave this as is for now. Anyone who needs it badly can use my fork.

result->Set(String::New(&*key.begin()),
value_ptr ?
String::New(static_cast<const char*>(value_ptr), value_length) :
Undefined());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My beautiful ternary operator! Gone. >:{

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha. ?: formatting fetish is bizarrely common.

@agnat
Copy link
Owner

agnat commented Oct 21, 2014

A'ight.

BTW, @ronkorving: If you and the users decide to merge it as is without further testing or clean-ups: I'm good with that.

@ronkorving
Copy link
Collaborator

Hey guys, thanks for the work and review. I've been traveling so I have some catching up to do left and right. I'll give this PR a pass.

@@ -55,5 +55,10 @@
, "github": "TobyEalden"
}
]
, "dependencies":
{ "bindings": "*"
, "nan": "*"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how @agnat feels about this, but I'm very much against asterisking dependencies.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm very much against dependencies.

Both of them are tightly coupled to node. In fact they are part of node but... oh well. Pinning a version does not seem right either. We want the latest round of nan compatibility hacks, no? What do you suggest? >=?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least ~. Changing a major version allows you to break all-the-things. We don't want to be hit by that at night when we're deploying our latest product, just because it coincided with a breaking release of a dependency (NAN) of a dependency (node-mdns).

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're much more experienced in actually running this kind of thing. So, it's up to you. As I said: I'm not ok with dependencies anyway. ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* was the reason the branch was named nan-latest. It should be fixed to a version after merge.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tilde (or that godawful caret) is good for NAN, we only do bug fixes in patch releases and promise not to break anything there. Minor versions are mostly safe as well, but stuff can get deprecated for good reasons. Major versions can do anything.

args[1] = Integer::New(flags);
args[2] = Integer::NewFromUnsigned(interfaceIndex);
args[3] = Integer::New(errorCode);
args[0] = NanNew(NanObjectWrapHandle(serviceRef));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be no need for the NanNew here, NanObjectWrapHandle returns a Local<Object>

@donpark
Copy link
Contributor Author

donpark commented Oct 23, 2014

But isn't it at least case preserving?

That would be my expectation too although all service types I've seen were lowercase.

Is that a linux box?

No, OS X Yosemite w/XCode 6.1.

NanObjectWrapHandle already returns a Local<Object>.
@donpark
Copy link
Contributor Author

donpark commented Oct 23, 2014

From page 5 of Bonjour Device Discovery.pdf:

(RFC 2782) Service Types: Short name of protocol, fourteen characters maximum, conforming to normal DNS host name rules: Only lower-case letters, digits, and hyphens; must begin and end with lower-case letter or digit.

Note this is not from RFC 2782 itself but just mentioned in DNS SRV-related slide created by two Apple engineer.

My theory: 1) Bonjour service type names are case insensitive and supports uppercase, but 2) DNS SRV record entry has to be lowercase, so 3) everyone used lowercase to avoid headaches.

@donpark
Copy link
Contributor Author

donpark commented Oct 23, 2014

Re simple browsing assert failures, they fail on node_mdns version 2.2.1 also so doesn't appear to be caused by this PR.

@donpark
Copy link
Contributor Author

donpark commented Oct 23, 2014

Found a more definite source. From Apple's MCNearbyServiceBrowser doc:

[serviceType] Must be 1–15 characters long. Can contain only ASCII lowercase letters, numbers, and hyphens.

Note there are some confusions over how many hyphens are allowed. What a fine mess.

@agnat
Copy link
Owner

agnat commented Oct 23, 2014

Nice. You already found and fixed the char set. I guess newer versions just enforce lowercase service types. That would explain the test failures.

All tests pass on OS X 10.9 node v0.10.32.

Let's give other interested parties a couple of hours to run the tests and we're good to go.

agnat added a commit that referenced this pull request Oct 25, 2014
@agnat agnat merged commit 0bd4053 into agnat:master Oct 25, 2014
@agnat
Copy link
Owner

agnat commented Oct 25, 2014

Thanks everybody for this great PR: @kkoopa, @ronkorving, @y-lohse and most of all @donpark who did the work and pushed mdns to the future.

Great job.

@y-lohse
Copy link
Contributor

y-lohse commented Oct 27, 2014

I clearly did the biggest part.

Joke aside, I tested on windows this morning, works fine. The tests fail at some point but I never ran them before so it might not be related to this PR. Here's the log:

Browser
? Should retrieve interface name from cache when interface index is no longer va
lid  [4/4]

test_dns_sd
? DNSServiceRef                 [3/3]
? DNSServiceRegister()          [20/20]
? DNSServiceProcessResult()     [13/13]
? DNSServiceRefSockFD()         [6/6]
? DNSServiceBrowse()            [13/13]
? DNSServiceRefDeallocate()     [8/8]
? DNSServiceResolve()           [11/11]
? DNSServiceEnumerateDomains()  [13/13]
? DNSServiceGetAddrInfo         [1/1]
? TXTRecordRef                  [31/31]
? buildException()              [47/47]
? exportConstants()             [3/3]

test_functional
? simple browsing                                       [116/116]
? create ads                                            [8/8]
[SKIPPED] write better test for browseThemAll()
? browseThemAll()                                       [0/0]
? resolver sequence                                     [16/16]
C:\Users\caldera\Documents\jdf\node_modules\mdns\lib\network_interface.js:36
      index = dns_sd.if_nametoindex(networkInterface);
                     ^
Error: failed to convert interface alias to luid
    at Error (native)
    at Object.interfaceIndex (C:\Users\caldera\Documents\jdf\node_modules\mdns\l
ib\network_interface.js:36:22)
    at new Browser (C:\Users\caldera\Documents\jdf\node_modules\mdns\lib\browser
.js:15:23)
    at Object.create [as createBrowser] (C:\Users\caldera\Documents\jdf\node_mod
ules\mdns\lib\browser.js:104:10)
    at exports.local advertisement invisible on external interfaces (C:\Users\ca
ldera\Documents\jdf\node_modules\mdns\tests\test_functional.js:377:30)

Otherwise, thanks for the great job :)

@ronkorving
Copy link
Collaborator

Would you mind taking a closer look into that? Not to sound too stupid I hope, but what's an luid anyway?

@agnat
Copy link
Owner

agnat commented Oct 27, 2014

ludicrous identifier... or something.

@ronkorving
Copy link
Collaborator

I knew it was something super duper technical. I'm not cut out for this.

@kkoopa
Copy link

kkoopa commented Oct 27, 2014

I was going to debug it, but don't have a Crapple ID or the necessary SDK, so screw that. Mac sucks.

@agnat
Copy link
Owner

agnat commented Oct 27, 2014

IIRC, windows interface names are subject to i18n and admins can change them. The luid is an internal identifier to keep track of things.

Could be an actual bug or just another weak test, though...

@agnat
Copy link
Owner

agnat commented Oct 27, 2014

I guess luid are locally unique. They are carefully crafted to collide across systems. Think id++... just much more
complicated.

@y-lohse
Copy link
Contributor

y-lohse commented Oct 27, 2014

I'm completely clueless regarding c++, I don't even know how to log an error… so i'm afraid I won't be able to help a lot.
In network_interface.js:36, networkInterface's value is Connexion au réseau local 3, which is the name of my network interface. Not sure how well the accent fares in there.

@donpark
Copy link
Contributor Author

donpark commented Oct 27, 2014

LUID is a 64-bit locally unique identifier returned by Windows IP Helper API function ConvertInterfaceAliasToLuid failure of which is mapped to "failed to convert interface alias to luid" error in network_interface.cpp.

This may have something to do with deprecation warning above error throwing call to dns_sd.if_nameToIndex:

 console.warn("WARNING: 'interfaceIndex' is deprecated and will be " +
      "removed. Please use 'networkInterface' instead and see the " +
      "documentation on why it's cool.");

@agnat
Copy link
Owner

agnat commented Oct 27, 2014

Pretty sure the warning is unrelated. It's about an, uh, upcoming API change in node_mdns. Although the code tries to handle unicode names this never has been stress tested. So, blaming the accent seems like a good guess.

@agnat
Copy link
Owner

agnat commented Oct 27, 2014

@y-lohse, could you paste the results of test_network_interface.js? Embarrassingly, the easiest way to do that seems to be renaming test_functional.js to dont_test_functional.js or some such. Then run npm test.

@y-lohse
Copy link
Contributor

y-lohse commented Oct 27, 2014

Sure thing:

`test_network_interface
C:\Users\caldera\Documents\jdf\node_modules\mdns\tests\test_network_interface.js
:25
      var index = dns_sd.if_nametoindex(name);
                         ^
Error: failed to convert interface alias to luid
    at Error (native)
    at exports.if_nametoindex <-> if_indextoname (C:\Users\caldera\Documents\jdf
\node_modules\mdns\tests\test_network_interface.js:25:26)
    at run_testcase (C:\Users\caldera\Documents\jdf\node_modules\mdns\utils\test
run:191:3)
    at Array.<anonymous> (C:\Users\caldera\Documents\jdf\node_modules\mdns\node_
modules\slide\lib\bind-actor.js:15:8)
    at LOOP (C:\Users\caldera\Documents\jdf\node_modules\mdns\node_modules\slide
\lib\chain.js:15:14)
    at chain (C:\Users\caldera\Documents\jdf\node_modules\mdns\node_modules\slid
e\lib\chain.js:20:5)
    at run_group (C:\Users\caldera\Documents\jdf\node_modules\mdns\utils\testrun
:171:5)
    at Array.<anonymous> (C:\Users\caldera\Documents\jdf\node_modules\mdns\node_
modules\slide\lib\bind-actor.js:15:8)
    at LOOP (C:\Users\caldera\Documents\jdf\node_modules\mdns\node_modules\slide
\lib\chain.js:15:14)
    at C:\Users\caldera\Documents\jdf\node_modules\mdns\node_modules\slide\lib\c
hain.js:18:7

Out of curiosity, I commented the failing test out and the rest of them pass.

@agnat
Copy link
Owner

agnat commented Oct 27, 2014

Let's create a new issue for this one...

@donpark
Copy link
Contributor Author

donpark commented Oct 27, 2014

@agnat What I meant by related was the need for deprecation warning which points to changing environment, new code, and so on. Sorry, I tend to go meta at wrong times.

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

Successfully merging this pull request may close these issues.

5 participants