remailer 0.4.5 → 0.4.6

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.5
1
+ 0.4.6
@@ -221,6 +221,31 @@ class Remailer::Connection < EventMachine::Connection
221
221
  after_ready
222
222
  end
223
223
  end
224
+
225
+ # Tests the validity of an email address through the connection at the
226
+ # earliest opportunity. A callback block can be supplied that will be
227
+ # executed when the address has been tested, an unexpected result occurred,
228
+ # or the request timed out.
229
+ def test_email(from, to, &block)
230
+ if (block_given?)
231
+ self.class.warn_about_arguments(block, 1..2)
232
+ end
233
+
234
+ message = {
235
+ :from => from,
236
+ :to => to,
237
+ :test => true,
238
+ :callback => block
239
+ }
240
+
241
+ @messages << message
242
+
243
+ # If the connection is ready to send...
244
+ if (@interpreter and @interpreter.state == :ready)
245
+ # ...send the message right away.
246
+ after_ready
247
+ end
248
+ end
224
249
 
225
250
  # Reassigns the timeout which is specified in seconds. Values equal to
226
251
  # or less than zero are ignored and a default is used instead.
@@ -37,16 +37,23 @@ class Remailer::Connection::SmtpInterpreter < Remailer::Interpreter
37
37
  end
38
38
 
39
39
  state :initialized do
40
- interpret(220) do |message|
40
+ interpret(220) do |message, continues|
41
41
  message_parts = message.split(/\s+/)
42
42
  delegate.remote = message_parts.first
43
43
 
44
44
  if (message_parts.include?('ESMTP'))
45
45
  delegate.protocol = :esmtp
46
- enter_state(:ehlo)
47
46
  else
48
47
  delegate.protocol = :smtp
49
- enter_state(:helo)
48
+ end
49
+
50
+ unless (continues)
51
+ case (delegate.protocol)
52
+ when :esmtp
53
+ enter_state(:ehlo)
54
+ else
55
+ enter_state(:helo)
56
+ end
50
57
  end
51
58
  end
52
59
 
@@ -66,7 +73,11 @@ class Remailer::Connection::SmtpInterpreter < Remailer::Interpreter
66
73
  end
67
74
 
68
75
  interpret(250) do
69
- enter_state(:established)
76
+ if (delegate.requires_authentication?)
77
+ enter_state(:auth)
78
+ else
79
+ enter_state(:established)
80
+ end
70
81
  end
71
82
  end
72
83
 
@@ -181,6 +192,22 @@ class Remailer::Connection::SmtpInterpreter < Remailer::Interpreter
181
192
  interpret(250) do
182
193
  enter_state(:rcpt_to)
183
194
  end
195
+
196
+ interpret(503) do |message, continues|
197
+ if (message.match(/5\.5\.1/))
198
+ enter_state(:re_helo)
199
+ end
200
+ end
201
+ end
202
+
203
+ state :re_helo do
204
+ enter do
205
+ delegate.send_line("HELO #{delegate.hostname}")
206
+ end
207
+
208
+ interpret(250) do
209
+ enter_state(:mail_from)
210
+ end
184
211
  end
185
212
 
186
213
  state :rcpt_to do
@@ -194,7 +221,11 @@ class Remailer::Connection::SmtpInterpreter < Remailer::Interpreter
194
221
  end
195
222
 
196
223
  interpret(250) do
197
- enter_state(:data)
224
+ if (delegate.active_message[:test])
225
+ enter_state(:reset)
226
+ else
227
+ enter_state(:data)
228
+ end
198
229
  end
199
230
  end
200
231
 
@@ -44,13 +44,15 @@ class Remailer::Connection::Socks5Interpreter < Remailer::Interpreter
44
44
  enter do
45
45
  proxy_options = delegate.options[:proxy]
46
46
 
47
- delegate.debug_notification(:proxy, "Initiating proxy connection through #{proxy_options[:host]}")
48
-
49
47
  socks_methods = [ ]
50
48
 
51
49
  if (proxy_options[:username])
52
50
  socks_methods << SOCKS5_METHOD[:username_password]
53
51
  end
52
+
53
+ proxy_options[:port] ||= Remailer::Connection::SOCKS5_PORT
54
+
55
+ delegate.debug_notification(:proxy, "Initiating proxy connection through #{proxy_options[:host]}:#{proxy_options[:port]}")
54
56
 
55
57
  delegate.send_data(
56
58
  [
@@ -88,7 +90,7 @@ class Remailer::Connection::Socks5Interpreter < Remailer::Interpreter
88
90
 
89
91
  state :connect_through_proxy do
90
92
  enter do
91
- delegate.debug_notification(:proxy, "Sending proxy connection request to #{delegate.options[:host]}:#{delegate.options[:port]}")
93
+ delegate.debug_notification(:proxy, "Sending proxy connection request to #{@destination_address.unpack('CCCC').join('.')}:#{delegate.options[:port]}")
92
94
 
93
95
  if (@destination_address)
94
96
  delegate.send_data(
@@ -170,6 +172,7 @@ class Remailer::Connection::Socks5Interpreter < Remailer::Interpreter
170
172
  message = "Proxy server returned error code #{@reply}: #{SOCKS5_REPLY[@reply]}"
171
173
  delegate.debug_notification(:error, message)
172
174
  delegate.connect_notification(false, message)
175
+ delegate.error_notification("SOCKS5_#{@reply}", message)
173
176
  delegate.close_connection
174
177
  end
175
178
 
@@ -18,7 +18,19 @@ class Remailer::Interpreter::StateProxy
18
18
 
19
19
  def interpret(response, &block)
20
20
  @options[:interpret] ||= [ ]
21
- @options[:interpret] << [ response, block ]
21
+
22
+ handler =
23
+ case (block.arity)
24
+ when 0
25
+ # Specifying a block with no arguments will mean that it waits until
26
+ # all pieces are collected before transitioning to a new state,
27
+ # waiting until the continue flag is false.
28
+ Proc.new { |m,c| instance_exec(&block) unless (c) }
29
+ else
30
+ block
31
+ end
32
+
33
+ @options[:interpret] << [ response, handler ]
22
34
  end
23
35
 
24
36
  def default(&block)
data/remailer.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{remailer}
8
- s.version = "0.4.5"
8
+ s.version = "0.4.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Scott Tadman"]
12
- s.date = %q{2011-03-27}
12
+ s.date = %q{2011-05-13}
13
13
  s.description = %q{EventMachine SMTP Mail User Agent}
14
14
  s.email = %q{scott@twg.ca}
15
15
  s.extra_rdoc_files = [
@@ -38,7 +38,7 @@ Gem::Specification.new do |s|
38
38
  ]
39
39
  s.homepage = %q{http://github.com/twg/remailer}
40
40
  s.require_paths = ["lib"]
41
- s.rubygems_version = %q{1.5.3}
41
+ s.rubygems_version = %q{1.6.0}
42
42
  s.summary = %q{Reactor-Ready SMTP Mailer}
43
43
  s.test_files = [
44
44
  "test/config.example.rb",
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: remailer
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.5
5
+ version: 0.4.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Scott Tadman
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-27 00:00:00 -06:00
13
+ date: 2011-05-13 00:00:00 -04:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -76,7 +76,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  requirements: []
77
77
 
78
78
  rubyforge_project:
79
- rubygems_version: 1.5.3
79
+ rubygems_version: 1.6.0
80
80
  signing_key:
81
81
  specification_version: 3
82
82
  summary: Reactor-Ready SMTP Mailer