Class: Inwx::DomainRobot

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(address, username = false, password = false, language = 'en', secure = false) ⇒ DomainRobot

Returns a new instance of DomainRobot.



94
95
96
97
98
99
100
# File 'lib/inwx.rb', line 94

def initialize(address, username = false, password = false, language = 'en', secure = false)
  @address = address
  @username = username
  @password = password
  @language = language
  @secure = secure
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



92
93
94
# File 'lib/inwx.rb', line 92

def address
  @address
end

#languageObject

Returns the value of attribute language.



92
93
94
# File 'lib/inwx.rb', line 92

def language
  @language
end

#passwordObject

Returns the value of attribute password.



92
93
94
# File 'lib/inwx.rb', line 92

def password
  @password
end

#secureObject

Returns the value of attribute secure.



92
93
94
# File 'lib/inwx.rb', line 92

def secure
  @secure
end

#usernameObject

Returns the value of attribute username.



92
93
94
# File 'lib/inwx.rb', line 92

def username
  @username
end

Instance Method Details

#call(object, method, params = {}) ⇒ Object



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/inwx.rb', line 102

def call(object, method, params = {})
  if self.secure 
    # Get a one-time-"random" nonce
    nonce = Time.now.to_f
    
    # Generate hash from nonce and password.
    hash = Digest::SHA2.new(bitlen = 256) << nonce.to_s + self.password.to_s
    
    # Merge both into params
    params.merge! :pass => hash.to_s        
  else               
    params.merge! :pass => self.password
  end
  
  # Merge username into params
  params.merge! :user => self.username
 
  # Create a new client instance
  client = XMLRPC::Client.new(self.address, "/xmlrpc/", "443", nil, nil, nil, nil, true, 900)
  
  # Call the remote method
  client.call(object+"."+method, params)
end