diff --git a/README.md b/README.md index 24164d9..9679e49 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ Enom::Client.username = "foo" Enom::Client.password = "bar" Enom::Client.test = true # Declaring test mode is optional, defaults to false (production) -# Test mode will run commands on Enom's reseller test platform +# Test mode will run commands on Enom's resellertest.enom.com test platform ``` Once these are set, subsequent commands will make calls to the API using your credentials (HTTPS). Any methods in the library that charge or refund the account in any way end with a bang (!). @@ -102,6 +102,18 @@ d.renew! d.renew!(:years => 3) ``` +## Host Override and Proxy/Tunnel Support + +If you want to use an HTTP proxy server to avoid having to add an IP to the Enom IP whitelist +(which has been known to be slow/flaky to recognize new IPs), you can set the +`proxyaddr` client option to point to your proxy server: + +``` +Enom::Client.proxyaddr = 'enom-proxy.example.com' +``` + +You can also optionally set `proxyport`, `proxyuser`, and `proxypass`. + ## Copyright Copyright (c) 2011-2013 James Miller diff --git a/bin/enom.rb b/bin/enom.rb index 65650b9..5bb605c 100644 --- a/bin/enom.rb +++ b/bin/enom.rb @@ -24,6 +24,12 @@ def usage You can run commands from the test interface with the -t flag: enom -u username -p password -t command +You can set an http proxy host with the --proxyaddr flag, e.g. to use a proxy +server with an already-whitelisted IP. You can also optionally specify +the proxy port, user, and password. + +enom -u username -p password --proxyaddr enom-proxy.example.com --proxyport 1080 --proxyuser user --proxypass pass + == Commands All commands are executed as enom [options] command [command-options] args @@ -55,6 +61,18 @@ def usage opts.on("-t") do Enom::Client.test = true end + opts.on("--proxyaddr [ARG]") do |proxyaddr| + Enom::Client.proxyaddr = proxyaddr + end + opts.on("--proxyport [ARG]") do |proxyport| + Enom::Client.proxyport = proxyport + end + opts.on("--proxyuser [ARG]") do |proxyuser| + Enom::Client.proxyuser = proxyuser + end + opts.on("--proxypass [ARG]") do |proxypass| + Enom::Client.proxypass = proxypass + end end global.order! diff --git a/lib/enom/client.rb b/lib/enom/client.rb index 887c33b..fb40b15 100644 --- a/lib/enom/client.rb +++ b/lib/enom/client.rb @@ -4,7 +4,7 @@ class Client include HTTParty class << self - attr_accessor :username, :password, :test + attr_accessor :username, :password, :test, :proxyaddr, :proxyport, :proxyuser, :proxypass alias_method :test?, :test # All requests must contain the UID, PW, and ResponseType query parameters @@ -24,6 +24,7 @@ def base_uri # or other helpful statuses -- everything comes back as a 200. def request(params = {}) params.merge!(default_params) + http_proxy(proxyaddr, proxyport, proxyuser, proxypass) response = get(base_uri, :query => params) case response.code when 200