-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Add Proxy Support #2814
Add Proxy Support #2814
Conversation
c1a18b3
to
bc04202
Compare
a very reasonable offer. If you will start please inform |
What is required beyond this pull request and the new command line flag to help with testing? |
would be great! |
|
||
import protos.RpcEnum_pb2 as RpcEnum | ||
import protos.RpcEnvelope_pb2 as RpcEnvelope | ||
|
||
class RpcApi: | ||
|
||
def __init__(self, auth_provider): | ||
def __init__(self, auth_provider, use_tor=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm seeing an issue where use_tor
is always set to false despite config['USE_TOR']
being set to true in get_args()
. As a result, login never goes through the socks proxy.
Seems like this could be any kind of proxy, not specifically tor, no? |
Yeah I suppose so. I can make it more generic. Regarding config['USE_TOR'] if you set -ut when you launch the app it definitely is working for me. So, let me know what you tried that isn't going through the proxy. Edit: I see you are saying login isn't going through the proxy. That is possible I will look into this. I was trying to figure out how to get the settings passed through to the api and there wasn't a great way to do this. The API is created in the top of Search.py on line 35 before the args are parsed. So it is very possible some initial connections won't go through the proxy. I will see what I can do. |
How to use this args ? |
Usage: You need to have tor running in the background listening on port 9050 and control port open at 9051 with a password. Here is an example torrc file that configures this:
Use |
I am currently resetting the tor IP connection on each new search pass this is the Tor specific stuff in this pull request, but I can split that and the proxy config so any socks proxy can be used. |
And for heroku ? |
I have no idea if this will work for Heroku. I also have never used heroku. The reason I am doing this is to guard my own ip and it seems to keep my rate limit higher. I was able to run with 3 threads for the last 12 hours with no errors something I have not been able to do without this code. |
http://stackoverflow.com/questions/10691188/use-proxy-or-tor-within-heroku-rails-app-to-hide-ip It sounds like you would have to host tor elsewhere which would limit slow requests down in general, so I don't recommend this with Heroku. |
I'm really conflicted about this. While this is a great solution to the recent changes, I'd like to not overwhelm the Tor network with pokemon maps without giving back. Journalists, activists, and a lot of normal people use Tor to protect themselves online in dangerous places and this would almost certainly increase latency for them for the sake of allowing us to enjoy our game more. Please consider running your own Tor relay if you do use this solution. I'd like to hear from everyone what they think about this. |
I think this is a good feature to add but as you said, it would be recommended to also run your own relay. |
I think need to add work with proxy, across you own server with squid. |
@AHAAAAAAA If that is the global feeling I can remove the tor portion. I re-implemented this more as a proxy option. It works with tor, but again I can easily remove that portion. |
@tim95030 yeah I think that would be the best way. There are other services not as resource strapped as Tor that we could use. |
Would really like to see this merged. I have reason to believe my IP is being throttled. Being able to use a proxy would be great. |
does it work?? |
It works with socks proxies. I haven't tried it with any other proxy types however. |
This has my +1, rebase and we can merge when another +1 comes through. |
Any documentation on how to get this to work? I'd gladly test it |
I didn't get around to adding that. I will try to today. Here is how you use it though: Pre-reqsA running socks proxy server Config.ini MethodAdd a new entry for proxy: and enter the proxy address
Command Line MethodUse either -px or --proxy with the proxy address |
Just tested on Heroku and it works. Thanks a lot @tim95030 👍 |
Added config.ini.example entry |
Not sure if I screwed something up on my side but, when I try this with Tor; |
Can this support proxies with authentication. On Monday, 1 August 2016, CtrlAltDefeat94 notifications@github.com wrote:
Dominic Grieco |
Currently this is for open proxies. I will look into authentication in a different pull request. |
@CtrlAltDefeat94 not sure what you are doing it's saying some port is in use on the db connection. My change doesn't touch that. |
@tim95030 I start tor on a free port(tested with curl through tor that it works) and then I start the map on a free port, then I get this error :/ |
@joelcogen can you confirm how you tested this on heroku. I get exceptions with parsing the proxy flag i.e.
|
@xzyfer tested with |
I tried long and short flag. Also with single, double, and no quotes. It On 3 Aug 2016 1:21 AM, "Joel Cogen" notifications@github.com wrote: @xzyfer /~https://github.com/xzyfer tested with -px socks5://ip:port only, — |
Nevermind (the comment I am replacing) I had a previous instance running which is what causes the cannot bind error. As such @CtrlAltDefeat94 run ps -ef | grep python and make sure nothing is running before you try starting the server. Everybody else I am not sure what to say I have it working with a proxy both with -px and --proxy both with ' and ". I am on Mac. |
One thing I can say is whatever proxy you are using must support https as all the calls in this api are over https |
Here is my output:
|
After some further investigation, this is unrelated to the problem I was having, but i would still like to see it implemented. |
@tim95030 after killing all python instances, the error stopped occuring(weird as none of them were using that port) Is it somehow possible to still run more than one instance, as it's quite a big range that I'd like to scan |
I am running the hex generator setting proxy: setting in the config ini and having no problem running them all concurrently. There have been some other changes around the threading as it's one account per thread now I believe. Though I haven't tried this feature. My change literally just makes all requests through the proxy it's a very simple change that has no affect on how many processes, etc. All of those things are from other features added to the project. |
Configuration error on my end, but got it working now. +1 from me |
+1 works nicely |
This needs to be reverted. We shouldn't be touching pgoapi. |
An idea to support socks using only environment variables in heroku: According to my limited knowledge, SOCKS5 support was added to requests in 2.10. Simply changing the Unfortunately it fails for more than one thread. |
@tim95030 How to contact you? I have a question about how to use your proxy code. |
@jerry317 It was reverted. I have a pull request to the pgoapi since we no longer use it natively. Currently there is no way. @pheiberg I in fact switched my logic in the PR for pgoapi to use request[socks] when I found out they added socks support. In theory you should be able to use what you mentioned, but you need to set two variables: |
@tim95030 check your personal Facebook messages, it's important |
Description
In order to better prevent IP blocking I have implemented Proxy support for requests. It is off by default, but can be enabled by providing a proxy url such as socks5://127.0.0.1:9050. Other proxies should work as well.
Motivation and Context
Recent IP issues from Niantic
How Has This Been Tested?
The code seems to be working well at least on my Mac.
Screenshots (if appropriate):
Types of changes
Checklist: