Class: SocksProxyPatch

Inherits:
Object
  • Object
show all
Defined in:
lib/train-winrm/socks_proxy_patch.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(socks_proxy:, socks_user:, socks_password:) ⇒ SocksProxyPatch

Returns a new instance of SocksProxyPatch.



25
26
27
28
29
# File 'lib/train-winrm/socks_proxy_patch.rb', line 25

def initialize(socks_proxy:, socks_user:, socks_password:)
  @socks_proxy = socks_proxy
  @socks_user = socks_user
  @socks_password = socks_password
end

Class Method Details

.apply(socks_proxy:, socks_user: nil, socks_password: nil) ⇒ Object

Applies the SOCKS proxy settings to ‘HTTPClient` and `TCPSocket`.

Examples:

SocksProxyPatch.apply(socks_proxy: "127.0.0.1:1080", socks_user: "user", socks_password: "pass")

Parameters:

  • socks_proxy (String)

    The SOCKS proxy address in the format ‘host:port`.

  • socks_user (String, nil) (defaults to: nil)

    Optional SOCKS proxy username.

  • socks_password (String, nil) (defaults to: nil)

    Optional SOCKS proxy password.



21
22
23
# File 'lib/train-winrm/socks_proxy_patch.rb', line 21

def self.apply(socks_proxy:, socks_user: nil, socks_password: nil)
  new(socks_proxy: socks_proxy, socks_user: socks_user, socks_password: socks_password).apply
end

Instance Method Details

#applyObject



31
32
33
34
35
# File 'lib/train-winrm/socks_proxy_patch.rb', line 31

def apply
  @proxy_host, @proxy_port = parse_and_validate_proxy(@socks_proxy)
  configure_socks
  patch_http_client
end