Class: RSocks::Authenticator

Inherits:
Object
  • Object
show all
Defined in:
lib/r_socks/authenticator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adaptor = nil) ⇒ Authenticator

Returns a new instance of Authenticator.



7
8
9
10
11
# File 'lib/r_socks/authenticator.rb', line 7

def initialize(adaptor = nil)
  @default_user = ENV['RSOCKS_USER'] || 'default'
  @default_password = ENV['RSOCKS_PASSWORD'] || 'default'
  @adaptor = adaptor
end

Instance Attribute Details

#passwordObject (readonly)

Returns the value of attribute password.



5
6
7
# File 'lib/r_socks/authenticator.rb', line 5

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



5
6
7
# File 'lib/r_socks/authenticator.rb', line 5

def username
  @username
end

Instance Method Details

#auth!(data) ⇒ Object



13
14
15
16
# File 'lib/r_socks/authenticator.rb', line 13

def auth!(data)
  return false if data.unpack('C')[0] != RSocks::AUTH_HEADER
  validate(data[1..-1])
end