-
Notifications
You must be signed in to change notification settings - Fork 2k
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 #395
Add Proxy support #395
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at [email protected]. Thanks! |
Signed GLA |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
} | ||
|
||
// get proxy setting from device setting | ||
-(void) configureProxy |
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.
Nit: Please match the overall style - aka - (void)_configureProxy
@oldshuren, than you so much for figuring out the CFNetwork approach to auto-proxy configuration. Also, if we could make the proxy configuration a self contained set of functions, or even a self contained class - that would be much better for code maintainability and reuse. |
I can verify that the patch works for the HTTPS connection through proxy that is set with the pac file URL in the device's WiFi settings. The corporate proxy does not support socks connections. Tested on iPhone 4S (iOS 9.3.1 build 13E283). |
I think we can make a class to handle the proxy configuration and BTW, if I make the change, do I need to submit a new pull request? Thanks, Dong On 5/31/16 2:31 PM, Nikita Lutsenko wrote:
|
Sounds great. Looking forward to this!
You can just force push the existing remote branch with |
Or create a class called NetSocket, which will handle proxy, open Dong On 5/31/16 2:31 PM, Nikita Lutsenko wrote:
|
I would say - we are good just by using a single class for proxy setup here, I wouldn't advise a big change, like NetSocket implementation just yet, since it's slightly out of scope of the intention here (http proxy handling). |
Hi, Would be possible to add SOCKS proxy support as well? Thanks, |
I guess it is possible, but you have to use PAC, because you can not I'll take a look after I finish the HTTP proxy. Cheers, Dong On 6/2/16 3:52 PM, Gabor Vass wrote:
|
you can add it on ios like this:
cheers, |
I pushed new update. Proxy handling was moved to ProxyConnect.{h|m} Socks support is added. It turns out Socks support is easier that HTTP, Apple's CFNetwork already have Socks support, you just need to configuration from system settings. |
@gaborvass I did it just like your suggestion, but on the NSStream. And the system configure only provide host, port, username and password. So I just ignore the version attribute. I tested it with the ssh Socks tunnel, it works perfectly. |
@oldshuren thanks a lot! |
@@ -0,0 +1,6 @@ | |||
#import <Foundation/Foundation.h> |
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.
This is missing the copyright declaration, which is required for all our source files.
Please copy it from SRError.h
@oldshuren, this looks good overall, few nits here and there (there is more but I skipped them for now). Overall notes:
As per more nits, styling, structuring: The minimum required changes to merge regardless of the path we take:
Let me know how I can support you here. |
Initially I had the stream running in the default Runloop, the normal You don't need to unschedule in the proxy handling code, but it requires I think I'll do the minimum necessary changes and let you change the Thanks, Dong On 6/3/16 2:35 PM, Nikita Lutsenko wrote:
|
On 6/3/16 2:35 PM, Nikita Lutsenko wrote:
The proxy code doesn't have access to the SRWebSocket's worker queue. So
So I think it should be fine. Dong |
One question, does the copyrights have to say Facebook? Thanks, Dong On 6/3/16 2:35 PM, Nikita Lutsenko wrote:
|
@oldshuren, yes, that's an explicit requirement. |
Ok Dong On 6/3/16 5:07 PM, Nikita Lutsenko wrote:
|
Perfect, than you for implementing this. |
@@ -1570,7 +1567,7 @@ - (NSOperationQueue *_Nullable)delegateOperationQueue | |||
|
|||
@end | |||
|
|||
//#define SR_ENABLE_LOG | |||
#define SR_ENABLE_LOG |
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.
Hi guys. Great work and apologies in advance for coming late to the party.
Did you mean to enable logging by default here for all builds?
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.
Should be disabled on the current master branch.
Let me know if it's not. Shouldn't be enabled by default.
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.
master branch is ok
(should have checked there first - sorry for the wasted time)
* Add Proxy support * move proxy to a class, add socks support * should use weakSelf * Move ProxyConnect to Internal/Proxy/SRProxyConnect
This pull request added support to use SocketRocket behind http proxy.
The proxy setting is read from the system configuration. PAC is also supported.
If there is proxy in the system configuration. Instead open network stream to the web socket server, the network stream to the proxy server is opened. Then we send HTTP CONNECT with the web socket server address to the proxy server. After receiving 200 OK status, it operates like normal network stream.