tuktuk 0.2.3 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tuktuk.rb +1 -1
- data/lib/tuktuk/dns.rb +39 -0
- data/lib/tuktuk/tuktuk.rb +5 -12
- data/lib/tuktuk/version.rb +2 -2
- metadata +68 -87
data/lib/tuktuk.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require 'tuktuk/tuktuk'
|
1
|
+
require './lib/tuktuk/tuktuk'
|
data/lib/tuktuk/dns.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
begin
|
2
|
+
require 'resolv'
|
3
|
+
rescue
|
4
|
+
require 'net/dns/resolve'
|
5
|
+
end
|
6
|
+
|
7
|
+
module DNS
|
8
|
+
|
9
|
+
class << self
|
10
|
+
|
11
|
+
def get_mx(host)
|
12
|
+
if defined?(Resolv::DNS)
|
13
|
+
get_using_resolve(host)
|
14
|
+
else
|
15
|
+
get_using_net_dns(host)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_using_resolve(host)
|
20
|
+
Resolv::DNS.open do |dns|
|
21
|
+
if res = dns.getresources(host, Resolv::DNS::Resource::IN::MX)
|
22
|
+
sort_mx(res)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_using_net_dns(host)
|
28
|
+
if res = Net::DNS::Resolver.new.mx(host)
|
29
|
+
sort_mx(res)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def sort_mx(res)
|
34
|
+
res.sort {|x,y| x.preference <=> y.preference}.map { |rr| rr.exchange.to_s }
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/lib/tuktuk/tuktuk.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'net/smtp'
|
2
|
-
require 'net/dns/resolver'
|
3
2
|
require 'dkim'
|
4
3
|
require 'logger'
|
5
|
-
require
|
6
|
-
require 'tuktuk/
|
4
|
+
%w(package cache dns).each { |lib| require "./lib/tuktuk/#{lib}" }
|
5
|
+
require './lib/tuktuk/version' unless defined?(Tuktuk::VERSION)
|
7
6
|
|
8
7
|
DEFAULTS = {
|
9
8
|
:retry_sleep => 10,
|
@@ -81,21 +80,15 @@ module Tuktuk
|
|
81
80
|
|
82
81
|
def smtp_servers_for_domain(domain)
|
83
82
|
unless servers = cache.get(domain)
|
84
|
-
if servers =
|
83
|
+
if servers = DNS.get_mx(domain) and servers.any?
|
85
84
|
cache.set(domain, servers)
|
85
|
+
else
|
86
|
+
raise DNSError, "No MX records found for domain #{domain}."
|
86
87
|
end
|
87
88
|
end
|
88
89
|
servers
|
89
90
|
end
|
90
91
|
|
91
|
-
def lookup_smtp_servers(domain)
|
92
|
-
if mx = Net::DNS::Resolver.new.mx(domain)
|
93
|
-
mx.sort {|x,y| x.preference <=> y.preference}.map {|rr| rr.exchange}
|
94
|
-
else
|
95
|
-
raise DNSError, "No MX records found for domain #{domain}."
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
92
|
def lookup_and_deliver(mail, attempt = 1)
|
100
93
|
raise MissingFieldsError, "No destinations found! You need to pass a :to field." if mail.destinations.empty?
|
101
94
|
|
data/lib/tuktuk/version.rb
CHANGED
metadata
CHANGED
@@ -1,139 +1,120 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: tuktuk
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 3
|
10
|
-
version: 0.2.3
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
-
|
7
|
+
authors:
|
8
|
+
- Tomás Pollak
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-10-31 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: bundler
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 23
|
29
|
-
segments:
|
30
|
-
- 1
|
31
|
-
- 0
|
32
|
-
- 0
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
33
21
|
version: 1.0.0
|
34
22
|
type: :development
|
35
|
-
version_requirements: *id001
|
36
|
-
- !ruby/object:Gem::Dependency
|
37
|
-
name: net-dns
|
38
23
|
prerelease: false
|
39
|
-
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.0.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: net-dns
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
40
33
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
hash: 5
|
45
|
-
segments:
|
46
|
-
- 0
|
47
|
-
- 6
|
48
|
-
- 1
|
34
|
+
requirements:
|
35
|
+
- - '='
|
36
|
+
- !ruby/object:Gem::Version
|
49
37
|
version: 0.6.1
|
50
38
|
type: :runtime
|
51
|
-
version_requirements: *id002
|
52
|
-
- !ruby/object:Gem::Dependency
|
53
|
-
name: mail
|
54
39
|
prerelease: false
|
55
|
-
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - '='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.6.1
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: mail
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
56
49
|
none: false
|
57
|
-
requirements:
|
50
|
+
requirements:
|
58
51
|
- - ~>
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
|
61
|
-
segments:
|
62
|
-
- 2
|
63
|
-
- 3
|
64
|
-
version: "2.3"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.3'
|
65
54
|
type: :runtime
|
66
|
-
version_requirements: *id003
|
67
|
-
- !ruby/object:Gem::Dependency
|
68
|
-
name: dkim
|
69
55
|
prerelease: false
|
70
|
-
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.3'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: dkim
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
71
65
|
none: false
|
72
|
-
requirements:
|
66
|
+
requirements:
|
73
67
|
- - ~>
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
hash: 27
|
76
|
-
segments:
|
77
|
-
- 0
|
78
|
-
- 0
|
79
|
-
- 2
|
68
|
+
- !ruby/object:Gem::Version
|
80
69
|
version: 0.0.2
|
81
70
|
type: :runtime
|
82
|
-
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.0.2
|
83
78
|
description: Easy way of sending DKIM-signed emails from Ruby, no dependencies needed.
|
84
|
-
email:
|
79
|
+
email:
|
85
80
|
- tomas@forkhq.com
|
86
81
|
executables: []
|
87
|
-
|
88
82
|
extensions: []
|
89
|
-
|
90
83
|
extra_rdoc_files: []
|
91
|
-
|
92
|
-
files:
|
84
|
+
files:
|
93
85
|
- .gitignore
|
94
86
|
- Gemfile
|
95
87
|
- README.md
|
96
88
|
- Rakefile
|
97
89
|
- lib/tuktuk.rb
|
98
90
|
- lib/tuktuk/cache.rb
|
91
|
+
- lib/tuktuk/dns.rb
|
99
92
|
- lib/tuktuk/package.rb
|
100
93
|
- lib/tuktuk/tuktuk.rb
|
101
94
|
- lib/tuktuk/version.rb
|
102
95
|
- tuktuk.gemspec
|
103
96
|
homepage: https://github.com/tomas/tuktuk
|
104
97
|
licenses: []
|
105
|
-
|
106
98
|
post_install_message:
|
107
99
|
rdoc_options: []
|
108
|
-
|
109
|
-
require_paths:
|
100
|
+
require_paths:
|
110
101
|
- lib
|
111
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
103
|
none: false
|
113
|
-
requirements:
|
114
|
-
- -
|
115
|
-
- !ruby/object:Gem::Version
|
116
|
-
|
117
|
-
|
118
|
-
- 0
|
119
|
-
version: "0"
|
120
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ! '>='
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
121
109
|
none: false
|
122
|
-
requirements:
|
123
|
-
- -
|
124
|
-
- !ruby/object:Gem::Version
|
125
|
-
hash: 23
|
126
|
-
segments:
|
127
|
-
- 1
|
128
|
-
- 3
|
129
|
-
- 6
|
110
|
+
requirements:
|
111
|
+
- - ! '>='
|
112
|
+
- !ruby/object:Gem::Version
|
130
113
|
version: 1.3.6
|
131
114
|
requirements: []
|
132
|
-
|
133
115
|
rubyforge_project: tuktuk
|
134
|
-
rubygems_version: 1.8.
|
116
|
+
rubygems_version: 1.8.23
|
135
117
|
signing_key:
|
136
118
|
specification_version: 3
|
137
119
|
summary: SMTP client for Ruby with DKIM support.
|
138
120
|
test_files: []
|
139
|
-
|