Skip to content

Commit

Permalink
Export SocksProxyEnvVar (#362)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjirewis authored Oct 2, 2024
1 parent a22af49 commit 73fb80d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions rpc/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ var (
// keepAliveTime is how often to establish Keepalive pings/expectations.
keepAliveTime = 10 * time.Second

// socksProxyEnvVar is the name of an environment variable used by SOCKS
// SocksProxyEnvVar is the name of an environment variable used by SOCKS
// proxies to indicate the address through which to route all network traffic
// via SOCKS5.
socksProxyEnvVar = "SOCKS_PROXY"
SocksProxyEnvVar = "SOCKS_PROXY"
)
2 changes: 1 addition & 1 deletion rpc/dialer.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ func dialDirectGRPC(ctx context.Context, address string, dOpts dialOptions, logg

// Use SOCKS proxy from environment as gRPC proxy dialer. Do not use
// if trying to connect to a local address.
if proxyAddr := os.Getenv(socksProxyEnvVar); proxyAddr != "" &&
if proxyAddr := os.Getenv(SocksProxyEnvVar); proxyAddr != "" &&
!(strings.HasPrefix(address, "[::]") || strings.HasPrefix(address, "localhost")) {
dialer, err := proxy.SOCKS5("tcp", proxyAddr, nil, proxy.Direct)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion rpc/wrtc_peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func newWebRTCAPI(isClient bool, logger utils.ZapCompatibleLogger) (*webrtc.API,
})

// Use SOCKS proxy from environment as ICE proxy dialer and net transport.
if proxyAddr := os.Getenv(socksProxyEnvVar); proxyAddr != "" {
if proxyAddr := os.Getenv(SocksProxyEnvVar); proxyAddr != "" {
logger.Info("behind SOCKS proxy; setting ICE proxy dialer")
dialer, err := proxy.SOCKS5("tcp4", proxyAddr, nil, proxy.Direct)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions rpc/wrtc_signaling_answerer.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func (ans *webrtcSignalingAnswerer) Start() {
timeout := answererConnectTimeout
// Bump timeout from 10 seconds to 1 minute if behind a SOCKS proxy. It
// may take longer to connect to the signaling server in that case.
if proxyAddr := os.Getenv(socksProxyEnvVar); proxyAddr != "" {
if proxyAddr := os.Getenv(SocksProxyEnvVar); proxyAddr != "" {
timeout = answererConnectTimeoutBehindProxy
}
setupCtx, timeoutCancel := context.WithTimeout(ans.closeCtx, timeout)
Expand Down Expand Up @@ -321,7 +321,7 @@ func (aa *answerAttempt) connect(ctx context.Context) (err error) {
// possible through extending the WebRTC config with a TURN URL (and
// associated username and password).
webrtcConfig := aa.webrtcConfig
if proxyAddr := os.Getenv(socksProxyEnvVar); proxyAddr != "" {
if proxyAddr := os.Getenv(SocksProxyEnvVar); proxyAddr != "" {
aa.logger.Info("behind SOCKS proxy; extending WebRTC config with TURN URL")
aa.connMu.Lock()
conn := aa.conn
Expand Down

0 comments on commit 73fb80d

Please sign in to comment.