dnsmadeeasy_verify 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +10 -0
- data/lib/dnsmadeeasy_verify/dnsmadeeasy_api.rb +31 -0
- data/lib/dnsmadeeasy_verify/domain.rb +53 -0
- data/lib/dnsmadeeasy_verify/version.rb +3 -0
- data/lib/dnsmadeeasy_verify.rb +60 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0b1927202b5ef94ed9e95b759bd95dad69a491a1
|
4
|
+
data.tar.gz: 73a6dc2bb46b8440a902b6f5ce4596631b23fd18
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 10c26119527b67df4465f5e97650dd170e530ae1f209904219e55ac0d5f861f14947ebaf31b0fd5457330697efa07663ba5f0a8384574112e23393b00dbfe7f7
|
7
|
+
data.tar.gz: 6739b7a8a669590face4a20526373220a90920a65689c6fe48e8c67efda513344c6fcc40b1a8e9327d5148352b610833d65751a36aca29109ce03cfe7802e642
|
data/Gemfile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'time'
|
2
|
+
require 'base64'
|
3
|
+
require 'cgi'
|
4
|
+
require 'openssl'
|
5
|
+
|
6
|
+
module Dnsmadeeasy_verify
|
7
|
+
@base_uri = 'https://api.dnsmadeeasy.com'
|
8
|
+
|
9
|
+
private
|
10
|
+
def self.hmac_sha1(data, secret)
|
11
|
+
hmac = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new('sha1'), secret.encode("ASCII"), data.encode("ASCII"))
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def self.get_auth_headers(api_key, api_secret)
|
16
|
+
date_of_request = Time.now().httpdate
|
17
|
+
|
18
|
+
headers = {
|
19
|
+
'x-dnsme-apiKey' => api_key,
|
20
|
+
'x-dnsme-requestDate' => date_of_request,
|
21
|
+
'x-dnsme-hmac' => hmac_sha1(date_of_request,api_secret)
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.get_all_domains(api_key, api_secret)
|
26
|
+
faraday = Faraday.new(:url => @base_uri)
|
27
|
+
faraday.headers = get_auth_headers(api_key, api_secret)
|
28
|
+
faraday.get '/V2.0/dns/managed/'
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'dnsruby'
|
2
|
+
|
3
|
+
module Dnsmadeeasy_verify
|
4
|
+
|
5
|
+
class Domain
|
6
|
+
include Dnsruby
|
7
|
+
|
8
|
+
attr_accessor :name
|
9
|
+
|
10
|
+
def initialize(name)
|
11
|
+
@name = name
|
12
|
+
end
|
13
|
+
|
14
|
+
def available
|
15
|
+
@whois ||= Whois.whois(@name)
|
16
|
+
@whois.available?
|
17
|
+
end
|
18
|
+
|
19
|
+
def registered
|
20
|
+
@whois ||= Whois.whois(@name)
|
21
|
+
@whois.registered?
|
22
|
+
end
|
23
|
+
|
24
|
+
def do_name_servers_contain(domain)
|
25
|
+
name_servers = get_name_servers
|
26
|
+
return name_servers.any?{ |s| s.downcase().include?(domain) }
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_name_servers
|
30
|
+
ns = []
|
31
|
+
res = Dnsruby::Resolver.new
|
32
|
+
res.retry_times=(2)
|
33
|
+
ns_req = nil
|
34
|
+
begin
|
35
|
+
ns_req = res.query(@name, "NS")
|
36
|
+
rescue Exception => e
|
37
|
+
return []
|
38
|
+
end
|
39
|
+
if (ns_req.header.ancount == 0)
|
40
|
+
return []
|
41
|
+
end
|
42
|
+
|
43
|
+
ns_req = res.query(@name, "NS")
|
44
|
+
(ns_req.answer.select {|r| r.type == "NS"}).each do |nsrr|
|
45
|
+
ns << nsrr.domainname.to_s
|
46
|
+
end
|
47
|
+
|
48
|
+
ns
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'whois'
|
3
|
+
require 'json'
|
4
|
+
require 'dnsruby'
|
5
|
+
require 'dnsmadeeasy_verify/Domain'
|
6
|
+
require 'dnsmadeeasy_verify/Dnsmadeeasy_api'
|
7
|
+
|
8
|
+
module Dnsmadeeasy_verify
|
9
|
+
|
10
|
+
# Returns all domains from DNS Made Easy
|
11
|
+
def self.list_domains
|
12
|
+
domains = Hash.new
|
13
|
+
response = get_all_domains(Dnsmadeeasy_verify.configuration.dnsmadeeasy_api_key, Dnsmadeeasy_verify.configuration.dnsmadeeasy_api_secret)
|
14
|
+
case response.status
|
15
|
+
when 200
|
16
|
+
data = JSON.parse(response.body)
|
17
|
+
|
18
|
+
data['data'].each do |child|
|
19
|
+
domains[child["name"]] = Domain.new(child["name"])
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
domains
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns all domains that are not correctly setup on DNS Made Easy
|
28
|
+
def self.domains_not_on_dnsmadeeasy()
|
29
|
+
domains = self.list_domains
|
30
|
+
domains_not_on_dnsmadeeasy = Hash.new
|
31
|
+
domains.each do |k, v|
|
32
|
+
domains_not_on_dnsmadeeasy[k] = v unless v.do_name_servers_contain("dnsmadeeasy.com")
|
33
|
+
end
|
34
|
+
domains_not_on_dnsmadeeasy
|
35
|
+
end
|
36
|
+
|
37
|
+
class << self
|
38
|
+
attr_accessor :configuration
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.configuration
|
42
|
+
@configuration ||= Configuration.new
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.configure
|
46
|
+
self.configuration ||= Configuration.new
|
47
|
+
yield(configuration)
|
48
|
+
end
|
49
|
+
|
50
|
+
class Configuration
|
51
|
+
attr_accessor :dnsmadeeasy_api_key
|
52
|
+
attr_accessor :dnsmadeeasy_api_secret
|
53
|
+
|
54
|
+
def initialize
|
55
|
+
@dnsmadeeasy_api_key = ''
|
56
|
+
@dnsmadeeasy_api_secret = ''
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dnsmadeeasy_verify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tom Holder
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.9.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: whois
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.5.8
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.5.8
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dnsruby
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.57.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.57.0
|
55
|
+
description: Uses DNS Made Easy as the domain source list to ns lookup name servers
|
56
|
+
and verify.
|
57
|
+
email: tom@simpleweb.co.uk
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- lib/dnsmadeeasy_verify/dnsmadeeasy_api.rb
|
63
|
+
- lib/dnsmadeeasy_verify/domain.rb
|
64
|
+
- lib/dnsmadeeasy_verify/version.rb
|
65
|
+
- lib/dnsmadeeasy_verify.rb
|
66
|
+
- Gemfile
|
67
|
+
homepage: https://github.com/simpleweb/dnsmadeeasy-verify
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.0.0
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: DNS Made Easy is a name server provider. This gem verifys domains match.
|
91
|
+
test_files: []
|