Class: RSocks::Socks5ProxyParser
- Inherits:
-
Object
- Object
- RSocks::Socks5ProxyParser
- Defined in:
- lib/r_socks/socks5_proxy_parser.rb
Instance Attribute Summary collapse
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #call(data) ⇒ Object
-
#initialize(state_machine, config, client) ⇒ Socks5ProxyParser
constructor
A new instance of Socks5ProxyParser.
Constructor Details
#initialize(state_machine, config, client) ⇒ Socks5ProxyParser
Returns a new instance of Socks5ProxyParser.
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/r_socks/socks5_proxy_parser.rb', line 14 def initialize(state_machine, config, client) @state_machine = state_machine @auth_method = config.auth_method @default_user = ENV['RSOCKS_USER'] || 'default' @default_password = ENV['RSOCKS_PASSWORD'] || 'default' @authenticator = RSocks::Authenticator.new(config.auth_adaptor) @original_addr = nil @original_port = nil @config = config @adaptor = config.auth_adaptor @client = client end |
Instance Attribute Details
#password ⇒ Object (readonly)
Returns the value of attribute password.
12 13 14 |
# File 'lib/r_socks/socks5_proxy_parser.rb', line 12 def password @password end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
12 13 14 |
# File 'lib/r_socks/socks5_proxy_parser.rb', line 12 def username @username end |
Instance Method Details
#call(data) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/r_socks/socks5_proxy_parser.rb', line 28 def call(data) if @state_machine.handshake? init_handshake(data) return end if @state_machine.auth? passed = @authenticator.auth!(data) if passed send_data(RSocks::SUCCESS_RESPONSE) @state_machine.connect! return end send_data(RSocks::FAILED_RESPONSE) return end if @state_machine.connect? connect_request(data) @username = @authenticator.username @password = @authenticator.password return [@addr, @port] end return send_data(not_accept) unless @state_machine.start? end |