Open mdlawson opened 11 years ago
We need to look into something simliar for linux (cc @caolan) I think being able to edit /etc/hosts
and work with ports instead of custom dns is a fine way to get this done. We can always make it even nicer later.
And thanks for looking into the windows side! :)
unix /etc/hosts
is exactly the same structure, so my snippet should work if the value of HOSTS is swapped out, and the line endings are fixed to be cross platform. Its a bit messy, but I think its probably the safest way of doing things. Ill look into it, and see about integrating things up properly into a pull request.
IIRC there are modules for that too. Yay :)
On 10.04.2013, at 19:35, Michael Lawson notifications@github.com wrote:
unix /etc/hosts is exactly the same structure, so my snippet should work if the value of HOSTS is swapped out, and the line endings are fixed to be cross platform. Its a bit messy, but I think its probably the safest way of doing things. Ill look into it, and see about integrating things up properly into a pull request.
— Reply to this email directly or view it on GitHub.
Updated my gist with cross platform ready code, not entirely sure how to best do a pull request though, depends on if the dns trick is still going to be used on mac os or the hosts file can be used there as well.
strike that, got some bugs. Ill fix it up.
Panic over, os.EOF instead of os.EOL is a pretty stupid typo.
Working on more or less a rewrite on my fork https://github.com/mdlawson/local-tld on the crossplatform branch. Windows support, including a service, has been implemented so far. I will port over the existing mac service install soon, after I improve usability a bit. I plan on writing an init.d initscript and a systemd unit for linux as well. I added a CLI interface for managing the service, which I feel is better than using npm install/remove hooks.
xip.io support has been removed for now, ill add it as soon as I work out what the existing code even does, and how best to do it in windows.
wow, thanks so much for working on this @mdlawson. This is so awesome!
I've added mac os support in my fork, but I have no way of testing if it works. If someone could check it out, that would be awesome.
After cloning and npm install
ing, you should try: (needs root)
node lib/local-tld.js service install
followed by
node lib/local-tld.js service start
and then test if stop and remove work as well. Error reporting is really unfriendly right now, just throws errors if encountered.
It would also be a nice to test the service separately, even if the manager doesn't work, by running
node lib/service.js
Thanks!
Ok, I'm fairly sure my branch has all the existing features working on windows. I've just setup a mac vm for testing macOS, so i'll get that working soon.
One concern where it probably differs at the moment is the config file. What format is it supposed to be in? My branch currently reads/writes the format:
{
"myfancyprojectA": {
"port": 8000
},
"test": {
"port": 3000
}
}
After I've made sure everything works as expected on mac, perhaps my branch could be merged into a branch in this repo, pending merge into master? Not really sure how to contribute a rewrite.
We key by port because they need to be unique by system. I'd say we keep that format.
As for getting this merged, there is some work on hoodie-app by @caolan that is coming in soon and I'm happy to help to get it all integrated.
I'm wondering, would you be interested in getting hoodiehq/node-multicouch going on windows as well? :)
On 12.04.2013, at 16:34, Michael Lawson notifications@github.com wrote:
Ok, I'm fairly sure my branch has all the existing features working on windows. I've just setup a mac vm for testing macOS, so i'll get that working soon.
One concern where it probably differs at the moment is the config file. What format is it supposed to be in? My branch currently reads/writes the format:
{ "myfancyprojectA": { "port": 8000 }, "test": { "port": 3000 } }
After I've made sure everything works as expected on mac, perhaps my branch could be merged into a branch in this repo, pending merge into master? Not really sure how to contribute a rewrite.
— Reply to this email directly or view it on GitHub.
Just checked the readme and saw that new format. Doh! Should be trivial to switch over though. Took a quick look over node-multicouch, doesn't look like much work to fix up. Only obvious thing I saw was "/" directory separators in path compositions all over the place, which generally just need replacing with calls to path.join().
When I'm happy with local-tld, I'll move on to that.
Woot, yay, thanks :)
On 12.04.2013, at 16:48, Michael Lawson notifications@github.com wrote:
Just checked the readme and saw that new format. Doh! Should be trivial to switch over though. Took a quick look over node-multicouch, doesn't look like much work to fix up. Only obvious thing I saw was "/" directory separators in path compositions all over the place, which generally just need replacing with calls to path.join().
When I'm happy with local-tld, I'll move on to that.
— Reply to this email directly or view it on GitHub.
Just tested everything out on MacOS, by some miracle it all works ok. Not sure what to do about linux support really, since init systems vary by distro and its normally up to the package maintainers for the distro to sort it out. Might just leave linux with commands to start the service in the current terminal, with no daemonization. How does that sound to you?
On Apr 12, 2013, at 17:57 , Michael Lawson notifications@github.com wrote:
Just tested everything out on MacOS, by some miracle it all works ok. Not sure what to do about linux support really, since init systems vary by distro and its normally up to the package maintainers for the distro to sort it out. Might just leave linux with commands to start the service in the current terminal, with no daemonization. How does that sound to you?
I’ll have a closer look at all this when I get back from my current travels early next week, I hope that’s ok :)
I would like to see support for wildcards in local-tld on windows. I'm not sure how linux etc. handle wildcards in the hosts file but as far as I'm concerned Mac does support it. Sadly windows doesn't so we must use a local dns server for that.
I'm going to do some research but for now this is quite interesting: http://stackoverflow.com/questions/138162/wildcards-in-a-hosts-file
I've also seen some dns server written in raw node, so maybe one of these could be an option.
This could be ported to nodejs: https://code.google.com/p/marlon-tools/source/browse/tools/dnsproxy/dnsproxy.py
Really not sure on the whole "embedded dns server" thing. Using a binary dns server would mean embedding something for windows, and probably embedding dnsmasq or requesting its installation for linux users. Both of those then need configuring and managing. This just seems horribly messy, given the existing, reasonably unified codebase. Using a node dns server seems a bit irresponsible: A dns server needs to be totally bulletproof. Existing nodejs solutions don't look too solid, and I wouldn't feel comfortable making one that is any better. Then, in adition, we give ourselves the problem of changing the users dns server cross platform. This could be done by asking the user to do it (hardly "works out of the box") or doing automatically (seems like a horrible idea to change a system setting just for this, and would introduce lots of ugly platform specific code)
Just my thoughts on the issue.
loving the idea of being able to use this cross-platform... completely sidestepping question: would this work on windows if it has Bonjour installed on it? (comes with itunes, and certain adobe creative suit components)
loving the idea of being able to use this cross-platform... completely sidestepping question: would this work on windows if it has Bonjour installed on it? (comes with itunes, and certain adobe creative suit components)
Interesting. I'm not familiar with bonjour, but from a very brief delve into the bonjour dev stuff (https://developer.apple.com/bonjour/) It looks relevent. I'd be interested to hear how your envisage that working. I dont thing bonour on windows is generally well recieved by devs, but it may still be a more friendly option than changing nameservers, or messing with the users hosts file
I took "This uses a cool dynamic DNS system that is built into Mac OS X." to mean that is uses Bonjour, since that's the only dynamic DNS I know comes with OSX, so I figured having Bonjour available on other systems would go a long way to make things work =)
I haven't actually tried to see if it works, but I might try to see if I can get it to work tomorrow. We're using a multi-app setup using nodejs where we need to do some localhost testing with cookies and subdomains, cross-platform local-tld would be awesome.
I'm fairly sure that the current local-tld on Mac is doesn't use bonjour, unless the way it does it is actually powered by bonjour on the back end.
If you are interested in just local-tld standalone, my fork here: http://github.com/mdlawson/local-tld provides 2 working cross platform options, one that uses the hosts file and is simple to use, but can't do proper wildcard resolution on windows and Linux (the crossplatform branch), and one that requires the system DNS server to be changed to localhost, but will provide full wildcard support on all platforms. They are undocumented currently, and the latter one requires a different config file structure than normal local-tld, so if you want more info, just ask, maybe on the hoodie irc channel. On 1 May 2013 23:17, "Mike Kamermans" notifications@github.com wrote:
I took "This uses a cool dynamic DNS system that is built into Mac OS X." to mean that is uses Bonjour, since that's the only dynamic DNS I know comes with OSX, so I figured having Bonjour available on other systems would go a long way to make things work =)
I haven't actually tried to see if it works, but I might try to see if I can get it to work tomorrow. We're using a multi-app setup using nodejs where we need to do some localhost testing with cookies and subdomains, cross-platform local-tld would be awesome.
— Reply to this email directly or view it on GitHubhttps://github.com/hoodiehq/local-tld/issues/11#issuecomment-17310058 .
I'm not the guy who has build that, @janl did, but I know it was heavily inspired by pow.cx and its architecture
bonjour is irrelveant to this discussion.
Bonjour is for discovering network services, not for DNS resolution. (although that is kinda part of it).
Say local-tld creates a service on a host, one can use bonjour to find that service from other machines on the local network.
interesting. curious about the hinted-at OSX bit of dns coolness then, though: which component does local-tld hook into to get the job done?
man resolver
:)
I've been looking into how to get the whole hoodie setup working on windows, and my starting point has been local-tld, as its the least cross platform element currently, and just the concept seemed quite cool for other uses.
After researching a bit around window's host resolution system, it sadly seems the only way to implement local-tld's functionality is to use the hosts file. The only functionality that cant be replicated this way is the use of firewall rules to redirect traffic on port 80 to port 5999, where a http server runs, but I'm not sure what purpose this has, as listening on port 80 would be identical, right?
The only other piece of missing functionality once the dns resolution is dealt with is the service, which I'm pretty sure is easy to implement on windows thanks to [node-windows] https://github.com/coreybutler/node-windows
So, as for the ugly, modifying the hosts file job, I'm suggesting something like this, https://gist.github.com/mdlawson/5355459 (sorry for the coffeescript, I can quickly clean up the generated js as needed) which wraps up the modified section in an application specific tag, and doesn't touch the rest of the file.
Usage is like this at the moment, but easy enough to change:
produces output like:
at the end of the users hosts file
I'm aware that its a horrible solution, but short of replacing the users DNS server with a 3rd party one and then hacking up that instead, I cant see a better way.
Let me know what you think.