Skip to content

Commit

Permalink
add support for http proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
thewoolleyman committed Oct 24, 2017
1 parent fe8fe9b commit c09e5bb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 (!).
Expand Down Expand Up @@ -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
18 changes: 18 additions & 0 deletions bin/enom.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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!
Expand Down
3 changes: 2 additions & 1 deletion lib/enom/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit c09e5bb

Please sign in to comment.