proxy.go 909 B

12345678910111213141516171819202122232425262728
  1. package sockets
  2. import (
  3. "net"
  4. "os"
  5. "strings"
  6. )
  7. // GetProxyEnv allows access to the uppercase and the lowercase forms of
  8. // proxy-related variables. See the Go specification for details on these
  9. // variables. https://golang.org/pkg/net/http/
  10. func GetProxyEnv(key string) string {
  11. proxyValue := os.Getenv(strings.ToUpper(key))
  12. if proxyValue == "" {
  13. return os.Getenv(strings.ToLower(key))
  14. }
  15. return proxyValue
  16. }
  17. // DialerFromEnvironment was previously used to configure a net.Dialer to route
  18. // connections through a SOCKS proxy.
  19. // DEPRECATED: SOCKS proxies are now supported by configuring only
  20. // http.Transport.Proxy, and no longer require changing http.Transport.Dial.
  21. // Therefore, only sockets.ConfigureTransport() needs to be called, and any
  22. // sockets.DialerFromEnvironment() calls can be dropped.
  23. func DialerFromEnvironment(direct *net.Dialer) (*net.Dialer, error) {
  24. return direct, nil
  25. }