You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.2 KiB

  1. From af4824cb0b2c36a0eba4bc1590eb0737302e992e Mon Sep 17 00:00:00 2001
  2. From: Yawning Angel <yawning@schwanenlied.me>
  3. Date: Wed, 10 Jan 2018 15:11:44 +0000
  4. Subject: Bug 24793: Send the correct authorization HTTP header for basic auth.
  5. Apparently I didn't test the "connect via HTTP(s)" proxy with
  6. authentication at all when I added that functionality, so it has been
  7. broken for years.
  8. This should fix it now.
  9. ---
  10. obfs4proxy/proxy_http.go | 5 ++++-
  11. 1 file changed, 4 insertions(+), 1 deletion(-)
  12. diff --git a/obfs4proxy/proxy_http.go b/obfs4proxy/proxy_http.go
  13. index 6f11790..a5c2100 100644
  14. --- a/obfs4proxy/proxy_http.go
  15. +++ b/obfs4proxy/proxy_http.go
  16. @@ -29,6 +29,7 @@ package main
  17. import (
  18. "bufio"
  19. + "encoding/base64"
  20. "fmt"
  21. "net"
  22. "net/http"
  23. @@ -90,7 +91,9 @@ func (s *httpProxy) Dial(network, addr string) (net.Conn, error) {
  24. }
  25. req.Close = false
  26. if s.haveAuth {
  27. - req.SetBasicAuth(s.username, s.password)
  28. + // SetBasicAuth doesn't quite do what is appropriate, because
  29. + // the correct header is `Proxy-Authorization`.
  30. + req.Header.Set("Proxy-Authorization", base64.StdEncoding.EncodeToString([]byte(s.username + ":" + s.password)))
  31. }
  32. req.Header.Set("User-Agent", "")
  33. --
  34. cgit v1.1