commit 79e3e5ff285d698636d0ad4b797d89a3f56749e8
Author: David Fifield <da...@bamsoftware.com>
Date:   Sat May 24 23:39:23 2014 -0700

    Honor a socks4a proxy when roundtripping through the helper.
---
 meek-client/helper.go      |    7 ++++---
 meek-client/helper_test.go |    8 ++++++++
 meek-client/meek-client.go |   17 +++++++++++++----
 meek-client/proxy_test.go  |    1 +
 4 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/meek-client/helper.go b/meek-client/helper.go
index d85ac8d..d349ff7 100644
--- a/meek-client/helper.go
+++ b/meek-client/helper.go
@@ -58,9 +58,10 @@ func makeProxySpec(u *url.URL) (*ProxySpec, error) {
                return nil, errors.New("proxy URLs with a username or password 
can't be used with the helper")
        }
 
-       if u.Scheme == "http" {
-               spec.Type = "http"
-       } else {
+       switch u.Scheme {
+       case "http", "socks4a":
+               spec.Type = u.Scheme
+       default:
                return nil, errors.New("unknown scheme")
        }
 
diff --git a/meek-client/helper_test.go b/meek-client/helper_test.go
index 4a34e35..f33bb38 100644
--- a/meek-client/helper_test.go
+++ b/meek-client/helper_test.go
@@ -19,6 +19,10 @@ func TestMakeProxySpec(t *testing.T) {
                url.URL{Scheme: "http", User: url.UserPassword("username", 
"password"), Host: "localhost:8080"},
                url.URL{Scheme: "http", Host: "localhost:-1"},
                url.URL{Scheme: "http", Host: "localhost:65536"},
+               url.URL{Scheme: "socks4a", Host: ":"},
+               // "socks" and "socks4" are unknown types.
+               url.URL{Scheme: "socks", Host: "localhost:1080"},
+               url.URL{Scheme: "socks4", Host: "localhost:1080"},
                url.URL{Scheme: "unknown", Host: "localhost:9999"},
        }
        goodTests := [...]struct {
@@ -29,6 +33,10 @@ func TestMakeProxySpec(t *testing.T) {
                        url.URL{Scheme: "http", Host: "localhost:8080"},
                        ProxySpec{"http", "localhost", 8080},
                },
+               {
+                       url.URL{Scheme: "socks4a", Host: "localhost:1080"},
+                       ProxySpec{"socks4a", "localhost", 1080},
+               },
        }
 
        for _, input := range badTests {
diff --git a/meek-client/meek-client.go b/meek-client/meek-client.go
index 72e379f..b4f9dee 100644
--- a/meek-client/meek-client.go
+++ b/meek-client/meek-client.go
@@ -316,10 +316,19 @@ func acceptLoop(ln *pt.SocksListener) error {
 // Return an error if this proxy URL doesn't work with the rest of the
 // configuration.
 func checkProxyURL(u *url.URL) error {
-       if options.ProxyURL.Scheme != "http" {
-               return errors.New(fmt.Sprintf("don't understand proxy URL 
scheme %q", options.ProxyURL.Scheme))
-       }
-       if options.HelperAddr != nil {
+       if options.HelperAddr == nil {
+               // Without the helper we only support HTTP proxies.
+               if options.ProxyURL.Scheme != "http" {
+                       return errors.New(fmt.Sprintf("don't understand proxy 
URL scheme %q", options.ProxyURL.Scheme))
+               }
+       } else {
+               // With the helper we can use HTTP and SOCKS (because it is the
+               // browser that does the proxying, not us).
+               switch options.ProxyURL.Scheme {
+               case "http", "socks4a":
+               default:
+                       return errors.New(fmt.Sprintf("don't understand proxy 
URL scheme %q", options.ProxyURL.Scheme))
+               }
                if options.ProxyURL.User != nil {
                        return errors.New("a proxy URL with a username or 
password can't be used with --helper")
                }
diff --git a/meek-client/proxy_test.go b/meek-client/proxy_test.go
index 9565101..7ce206f 100644
--- a/meek-client/proxy_test.go
+++ b/meek-client/proxy_test.go
@@ -36,6 +36,7 @@ func TestGetProxyURL(t *testing.T) {
                {"http://localhost:8080/path";, "http://localhost:8080/path"},
                {"http://user@localhost:8080";, "http://user@localhost:8080"},
                {"http://user:password@localhost:8080";, 
"http://user:password@localhost:8080"},
+               {"socks4a://localhost:1080", "socks4a://localhost:1080"},
                {"unknown://localhost/whatever", 
"unknown://localhost/whatever"},
        }
 



_______________________________________________
tor-commits mailing list
tor-commits@lists.torproject.org
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits

Reply via email to