-
Notifications
You must be signed in to change notification settings - Fork 85
Allow option to set the listening host #38
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
base: master
Are you sure you want to change the base?
Conversation
* Use the -o or --host option to set the host to listen on, in cases where the correct IP cannot be determined.
On my machine I have a lot of different ethernet addresses so being able to override it is helpful. I was getting exceptions thrown preventing it form running in some cases. |
Thanks for the pull. I would rather do a :
As for the GUI, we could just make the ip field user-editable. |
That works, too. In the GUI, it still uses get_external_ip but it causes a thrown exception if it can't find the IP so that GUI can't even start. |
Ah ok, I hadn't understood that. In that case, it needs to be fixed but not by forcing a -o option. Can you show me the exception you get and the result of the various stages in get_external_ip so we can track down why it can't find your IP ? |
There's actually two issues I'm facing:
|
Any way this sort of feature can get pushed upstream? I'll update my PR with the code. Not having to maintain a local branch would be nice. |
the issues you were facing should be corrected by now. |
Yeah my PR was from a previous version. I pulled the latest code and I still have an issue. I'll fix it up. |
Many people are reporting that sw picks the wrong IP address. I guess this feature can help them |
Yeah, but also, WHY is it picking the wrong IP.. it didn't do that before.. I think the change to auto-detect ip in a "reliable" way somehow screwed things up. |
during the 0.98 release, some people reported that problem. I opened an issue #48 and checked what have changed since 0.97 and found this change ffa2ff11c760784624d36cd97b1073804e8440cd which seems to be an evolution from the previous code to fix something. What was fixed ? Instead of reversing the change I decided to move forward and exclude all invalid ip and order the list putting common local ips on top. Lots of people reported that the change fixed their problems then I closed the issue. Maybe the old code also had some problems (I don't know why it was changed) and we didn't notice that earlier because we had few mac users before. |
@kakaroto @lstern checkout the branch/PR I pushed, it enables a --ipdetect2 option, can you guys test? It requires netifaces plugin, but should be cross platform. Since it seems like a better defined solution (if it works) perhaps we can chuck out all the current IP method detection in favor of using this? let me know what you think |
Oh yeah, I remember what the issue is...
If I run the first line (without selecting the internal value from it), I get this :
If I run that second metod, I get this :
And it looks like that gethostname() just gives whatever hostname is set in /etc/hosts (on linux/mac) so the final code basically merges those two lists, then skips the 127.* ip addresses, and in my case, we end up with just the 192.168.x address. In some other people's case, you may end up with whatever other local hostname gives you.. people with some kind of VPN app get something else, etc.. and in general, it all becomes a mess... |
There's no guarantee that old code will select the correct interface. Not sure if code was broke to someone but made a pull request with a hybrid from old and new version but instead of merging the socket.gethostbyname_ex list, it just order and filter the existing interface list. While writing this code, I found 1 error on current one, code was filtering 192.168.0.0/12 (I did this mistake while trying to fix the code) |
Well, filtering 192.168.0.0/12 might be why people were having issues :p Either way, yes, there is actually a guarantee that the old code will select the correct interface, because we create an outgoing socket that connects to 8.8.8.8 (google's DNS server FYI) so whatever IP it gives us, it's on the interface which has external connection routing. So basically, any of the virtual machines, or loopback interfaces would not get used because they wouldn't be able to connect to 8.8.8.8. |
Yeah, I realized that and closed my request.
|
hey guys; this issue is directly related to simply adding an option to set --host 10.0.2.4 or whatever; I think we should move IP detection alg talk into a relevant issue/PR. Can we just get custom host setter code merged in? seems like a small change, I can submit it in a fresh pull request if you'd like (or attach it to my ip-detect-2 branch) |
The code was broken before the 192.168.0.0/12 filter was implemented it
didn't break sw proxy for me (my local ip begins with 192.168) and somehow
fixed sw proxy for some people(those who motivated me to implement the
"fix") but might have broken SW Proxy for some others :p
|
I agree, i would still like the ability to set a host manually along with the detection fix. I have certain situations where two NICs may be able to access 8.8.8.8 for DNS routing but one NIC doesn't actually have full internet access. The if host / else detect would be great. |
for the record, I do run a "more than one network interface with its own valid routing to the internet" @kakaroto |
Oh yes, of course having the ability to set it manually is wanted, that's why this issue isn't closed, but those who understand what an IP address is and know how to set it are a minority of the users. We need to fix the detection for everyone else. And for those who are multi-homed, like @azrethos, those can set the host manually and that's it. |
I committed this to the swproxy plugins repo - should be applicable Nightreaver/SWProxy-plugins@b29ac72 I also think "host" is misleading, as the proxy will always run locally but on different interfaces |
@Nightreaver those look good, if you send a pull request with those commits, I can get it merged. |
done #165 |
where the correct IP cannot be determined.