Просмотр исходного кода

Merge branch 'master' of https://github.com/Psiphon-Labs/psiphon-tunnel-core

Rod Hynes 9 лет назад
Родитель
Сommit
b39a00b785

+ 4 - 0
MobileLibrary/iOS/PsiphonTunnelController/PsiphonTunnelController/PsiphonTunnelController.h

@@ -50,3 +50,7 @@ FOUNDATION_EXPORT const unsigned char PsiphonMobileVersionString[];
 -(void) stopTunnel;
 
 @end
+
+@interface Psi : NSObject
++ (void)sendFeedback:(NSString*)configJson diagnostics: (NSString*)diagnosticsJson b64EncodedPublicKey: (NSString*) b64EncodedPublicKey uploadServer: (NSString*)uploadServer uploadPath: (NSString*) uploadPath uploadServerHeaders: (NSString*)uploadServerHeaders;
+@end

+ 5 - 0
MobileLibrary/iOS/PsiphonTunnelController/PsiphonTunnelController/PsiphonTunnelController.m

@@ -148,3 +148,8 @@
 
 @end
 
+@implementation Psi
++ (void)sendFeedback:(NSString*)configJson diagnostics: (NSString*)diagnosticsJson b64EncodedPublicKey: (NSString*) b64EncodedPublicKey uploadServer: (NSString*)uploadServer uploadPath: (NSString*) uploadPath uploadServerHeaders: (NSString*)uploadServerHeaders {
+    GoPsiSendFeedback(configJson, diagnosticsJson, b64EncodedPublicKey, uploadServer, uploadPath, uploadServerHeaders);
+}
+@end

+ 13 - 1
psiphon/upstreamproxy/proxy_http.go

@@ -153,7 +153,19 @@ func (pc *proxyConn) handshake(addr, username, password string) error {
 	req.Header.Set("User-Agent", "")
 
 	for k, s := range pc.customHeaders {
-		req.Header[k] = s
+		// handle special Host header case
+		if k == "Host" {
+			if len(s) > 0 {
+				// hack around 'CONNECT' special case:
+				// https://golang.org/src/net/http/request.go#L476
+				// using URL.Opaque, see URL.RequestURI() https://golang.org/src/net/url/url.go#L915
+				req.URL.Opaque = req.Host
+				req.URL.Path = " "
+				req.Host = s[0]
+			}
+		} else {
+			req.Header[k] = s
+		}
 	}
 
 	if pc.authState == HTTP_AUTH_STATE_CHALLENGED {

+ 14 - 1
psiphon/upstreamproxy/transport_proxy_auth.go

@@ -172,7 +172,20 @@ func cloneRequest(r *http.Request, ch http.Header) *http.Request {
 
 	//Add custom headers to the cloned request
 	for k, s := range ch {
-		r2.Header[k] = s
+		// handle special Host header case
+		if k == "Host" {
+			if len(s) > 0 {
+				// hack around special case when http proxy is used:
+				// https://golang.org/src/net/http/request.go#L474
+				// using URL.Opaque, see URL.RequestURI() https://golang.org/src/net/url/url.go#L915
+				if r2.URL.Opaque == "" {
+					r2.URL.Opaque = r2.URL.Scheme + "://" + r2.Host + r2.URL.RequestURI()
+				}
+				r2.Host = s[0]
+			}
+		} else {
+			r2.Header[k] = s
+		}
 	}
 
 	if r.Body != nil {