Code Monkey home page Code Monkey logo

Comments (14)

kjagiello avatar kjagiello commented on July 19, 2024

I've just made a pull request with updated docs #10

from focus.

amoffat avatar amoffat commented on July 19, 2024

I'll post the question here (that I put on #10):

focus.py reads in the nameservers from /etc/resolv.conf, so that it knows which one to forward certain requests to. If Mac doesn't use resolv.conf, can you think of a good way for focus to know about the other nameservers?

from focus.

kjagiello avatar kjagiello commented on July 19, 2024

As we have confirmed that it /etc/resolv.conf exists both on Mac OS X and Linux, should we remove the Mac OS X specific installation instructions from the readme?

from focus.

cdetrio avatar cdetrio commented on July 19, 2024

I tried to explain the issue better on #10. Please keep the OS X instructions in the readme unless a solution other than the System Preferences dialogue can be found.

from focus.

amoffat avatar amoffat commented on July 19, 2024

@cdetrio I'm copying your comment in here, just so everything can be in one place...

The problem isn't focus.py being able to use /etc/resolv.conf. It is that the web browser (eg Chrome) does not resolve domains using resolv.conf ("most processes" as mentioned in the header), so even if 127.0.0.1 is in resolv.conf, the domain name requests made by the web browser never route to 127.0.0.1 (unless it is added to the DNS servers in the Mac system preferences) and therefore never to focus.py.

from focus.

amoffat avatar amoffat commented on July 19, 2024

Let me see if I understand correctly...

On the Mac, nothing actively uses resolv.conf. But when you update DNS servers in the system preferences, OS X updates resolv.conf with those new nameservers? So resolv.conf is basically just a record of what nameservers are being used (possibly for legacy apps)?

So if you add 127.0.0.1, this appears then in resolv.conf no? Or you have to add it to both? If you have to add it manually, where do the nameservers in resolv.conf come from then, if OSX isn't updating it?

from focus.

cdetrio avatar cdetrio commented on July 19, 2024

@amoffat just did some testing and it appears you are right. Yes, adding 127.0.0.1 through system preferences, it then appears in resolv.conf ("manually generated", probably for legacy apps as you mention). And focus.py works, but the web browser ("most processes") is not using resolv.conf. I can remove the line "nameserver 127.0.0.1" from resolv.conf, and focus.py continues to work (the web browser is getting its nameservers from somewhere else, not resolv.conf).

from focus.

amoffat avatar amoffat commented on July 19, 2024

@cdetrio interesting. I think what is happening might be desired. Most processes, including web browsers, don't use resolv.conf directly. They do their DNS lookups by asking the operating system directly, and the OS replies by doing the lookups using the nameservers it knows about.

So if you start focus.py without 127.0.0.1 in resolv.conf, it shouldn't start at all (it should complain at you). If you don't have another nameserver besides 127.0.0.1 in resolv.conf, it should complain at you also. But after focus.py is started, you can change resolv.conf and it won't effect focus. If you remove 127.0.0.1 for example, OSX might not care, if resolv.conf is just a (possibly incorrect) record. In other words, OSX might not "forget" about 127.0.0.1 unless you remove it through system preferences...not through resolv.conf. Focus won't forget about nameservers in resolv.conf either, if it was edited after it was started.

Does this sound like it might be accurate?

from focus.

ergelo avatar ergelo commented on July 19, 2024

That is accurate in my experience. focus.py will not start unless there are other nameservers in the preference pane (and thus in the resolv.conf), and it will likewise not start if 127.0.0.1 is not specified as a nameserver.

from focus.

davidxia avatar davidxia commented on July 19, 2024

@amoffat I'm using Mac Lion and this is true:

So if you start focus.py without 127.0.0.1 in resolv.conf, it shouldn't start at all (it should complain at you). If you don't have another nameserver besides 127.0.0.1 in resolv.conf, it should complain at you also.

In System Prefs > Network > DNS, the name server IPs seem to be detected automatically. So when I ran into the 2nd problem of focus.py complaining that there weren't other nameservers, I manually added the IPs that were originally there.

But it's annoying to have to do this, and when I moved to another wireless network, the old IPs no longer worked. I had to remove all the IPs, get the dynamically picked up IPs, add back 127.0.0.1 and these IPs, and then restart focus.py. Is there a way to have focus.py not conflict with this default Mac Lion behavior that detects the appropriate nameserver IPs (i.e. not have to specify any other nameserver besides 127.0.0.1)?

from focus.

amoffat avatar amoffat commented on July 19, 2024

@davidxia I'm confused now. @cdetrio said that when he added an IP through the system preferences, it appeared in resolv.conf automatically. But from what you said, it sounds like resolv.conf isn't updated automatically when the system moves networks (and changes its nameservers). Can you confirm this?

I don't have access to a Mac, so this will be hard for me to understand and work up a solution. Essentially focus.py needs 2 things: to know about an existing nameserver, and for the OS to use 127.0.0.1 as a nameserver. The whole dance focus does with resolv.conf is to achieve these 2 things. But if Mac is not making it easy to do these 2 things, can you think of a way that might be easier?

from focus.

cdetrio avatar cdetrio commented on July 19, 2024

I noticed the same issue as davidxia. I neglected to mention it since it seemed an idiosyncracy of OS X and not of focus.py. Eg, if you kill focus.py then you need to go to system preferences again and remove 127.0.0.1 for the browsers to work. Or alternatively, manually add the local router - then you wont have to come back to system preferences to add 127.0.0.1 for focus.py. Of course, that only works until you switch networks.

I don't know of an easier way than tinkering in system preferences. But its easy enough; this is now a meta-issue which distracts from utilizing and maintaining focus. closing issue.

from focus.

cdetrio avatar cdetrio commented on July 19, 2024

@davidxia, There's a better workaround which is working for me: add 127.0.0.1, and then 8.8.8.8 (google's public DNS). 8.8.8.8 will work across different networks, so there shouldn't be a need go back into system preferences whenever you switch networks.

from focus.

davidxia avatar davidxia commented on July 19, 2024

@cdetrio Yea, I actually found this out a little while ago. Thanks.

from focus.

Related Issues (10)

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.