remailer 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
 - data/lib/remailer/abstract_connection.rb +3 -7
 - data/lib/remailer/smtp/client.rb +0 -68
 - data/lib/remailer/smtp/server/interpreter.rb +3 -3
 - data/remailer.gemspec +3 -3
 - data/test/helper.rb +3 -1
 - data/test/unit/remailer_imap_client_test.rb +1 -1
 - data/test/unit/remailer_smtp_server_test.rb +4 -4
 - metadata +10 -5
 
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0.5. 
     | 
| 
      
 1 
     | 
    
         
            +
            0.5.2
         
     | 
| 
         @@ -209,6 +209,8 @@ class Remailer::AbstractConnection < EventMachine::Connection 
     | 
|
| 
       209 
209 
     | 
    
         
             
              def unbind
         
     | 
| 
       210 
210 
     | 
    
         
             
                return if (@unbound)
         
     | 
| 
       211 
211 
     | 
    
         | 
| 
      
 212 
     | 
    
         
            +
                self.cancel_timer!
         
     | 
| 
      
 213 
     | 
    
         
            +
             
     | 
| 
       212 
214 
     | 
    
         
             
                self.after_unbind
         
     | 
| 
       213 
215 
     | 
    
         | 
| 
       214 
216 
     | 
    
         
             
                @unbound = true
         
     | 
| 
         @@ -249,12 +251,6 @@ class Remailer::AbstractConnection < EventMachine::Connection 
     | 
|
| 
       249 
251 
     | 
    
         
             
                self.set_timer!
         
     | 
| 
       250 
252 
     | 
    
         
             
              end
         
     | 
| 
       251 
253 
     | 
    
         | 
| 
       252 
     | 
    
         
            -
              def detach
         
     | 
| 
       253 
     | 
    
         
            -
                self.cancel_timer!
         
     | 
| 
       254 
     | 
    
         
            -
             
     | 
| 
       255 
     | 
    
         
            -
                super
         
     | 
| 
       256 
     | 
    
         
            -
              end
         
     | 
| 
       257 
     | 
    
         
            -
              
         
     | 
| 
       258 
254 
     | 
    
         
             
              # Returns the current state of the active interpreter, or nil if no state
         
     | 
| 
       259 
255 
     | 
    
         
             
              # is assigned.
         
     | 
| 
       260 
256 
     | 
    
         
             
              def state
         
     | 
| 
         @@ -335,7 +331,7 @@ class Remailer::AbstractConnection < EventMachine::Connection 
     | 
|
| 
       335 
331 
     | 
    
         
             
                  remote_options = @options
         
     | 
| 
       336 
332 
     | 
    
         
             
                  interpreter = @interpreter
         
     | 
| 
       337 
333 
     | 
    
         | 
| 
       338 
     | 
    
         
            -
                  if ( 
     | 
| 
      
 334 
     | 
    
         
            +
                  if (self.proxy_connection_initiated?)
         
     | 
| 
       339 
335 
     | 
    
         
             
                    remote_options = @options[:proxy]
         
     | 
| 
       340 
336 
     | 
    
         
             
                  end
         
     | 
| 
       341 
337 
     | 
    
         | 
    
        data/lib/remailer/smtp/client.rb
    CHANGED
    
    | 
         @@ -163,18 +163,6 @@ class Remailer::SMTP::Client < Remailer::AbstractConnection 
     | 
|
| 
       163 
163 
     | 
    
         
             
                  error_notification(:out_of_band, "Receiving data before a protocol has been established.")
         
     | 
| 
       164 
164 
     | 
    
         
             
                end
         
     | 
| 
       165 
165 
     | 
    
         
             
              end
         
     | 
| 
       166 
     | 
    
         
            -
             
     | 
| 
       167 
     | 
    
         
            -
              def post_init
         
     | 
| 
       168 
     | 
    
         
            -
                @timer = EventMachine.add_periodic_timer(1) do
         
     | 
| 
       169 
     | 
    
         
            -
                  check_for_timeouts!
         
     | 
| 
       170 
     | 
    
         
            -
                end
         
     | 
| 
       171 
     | 
    
         
            -
              end
         
     | 
| 
       172 
     | 
    
         
            -
              
         
     | 
| 
       173 
     | 
    
         
            -
              #
         
     | 
| 
       174 
     | 
    
         
            -
              def detach
         
     | 
| 
       175 
     | 
    
         
            -
                @timer.cancel
         
     | 
| 
       176 
     | 
    
         
            -
                super
         
     | 
| 
       177 
     | 
    
         
            -
              end
         
     | 
| 
       178 
166 
     | 
    
         | 
| 
       179 
167 
     | 
    
         
             
              # Returns the current state of the active interpreter, or nil if no state
         
     | 
| 
       180 
168 
     | 
    
         
             
              # is assigned.
         
     | 
| 
         @@ -214,62 +202,6 @@ class Remailer::SMTP::Client < Remailer::AbstractConnection 
     | 
|
| 
       214 
202 
     | 
    
         
             
              rescue
         
     | 
| 
       215 
203 
     | 
    
         
             
                nil
         
     | 
| 
       216 
204 
     | 
    
         
             
              end
         
     | 
| 
       217 
     | 
    
         
            -
             
     | 
| 
       218 
     | 
    
         
            -
              # Resets the timeout time. Returns the time at which a timeout will occur.
         
     | 
| 
       219 
     | 
    
         
            -
              def reset_timeout!
         
     | 
| 
       220 
     | 
    
         
            -
                @timeout_at = Time.now + @timeout
         
     | 
| 
       221 
     | 
    
         
            -
              end
         
     | 
| 
       222 
     | 
    
         
            -
              
         
     | 
| 
       223 
     | 
    
         
            -
              # Returns the number of seconds remaining until a timeout will occur, or
         
     | 
| 
       224 
     | 
    
         
            -
              # nil if no time-out is pending.
         
     | 
| 
       225 
     | 
    
         
            -
              def time_remaning
         
     | 
| 
       226 
     | 
    
         
            -
                @timeout_at and (@timeout_at.to_i - Time.now.to_i)
         
     | 
| 
       227 
     | 
    
         
            -
              end
         
     | 
| 
       228 
     | 
    
         
            -
              
         
     | 
| 
       229 
     | 
    
         
            -
              # Checks for a timeout condition, and if one is detected, will close the
         
     | 
| 
       230 
     | 
    
         
            -
              # connection and send appropriate callbacks.
         
     | 
| 
       231 
     | 
    
         
            -
              def check_for_timeouts!
         
     | 
| 
       232 
     | 
    
         
            -
                return if (!@timeout_at or Time.now < @timeout_at or @timed_out)
         
     | 
| 
       233 
     | 
    
         
            -
             
     | 
| 
       234 
     | 
    
         
            -
                @timed_out = true
         
     | 
| 
       235 
     | 
    
         
            -
                @timeout_at = nil
         
     | 
| 
       236 
     | 
    
         
            -
             
     | 
| 
       237 
     | 
    
         
            -
                if (@connected and @active_message)
         
     | 
| 
       238 
     | 
    
         
            -
                  message_callback(:timeout, "Response timed out before send could complete")
         
     | 
| 
       239 
     | 
    
         
            -
                  error_notification(:timeout, "Response timed out")
         
     | 
| 
       240 
     | 
    
         
            -
                  debug_notification(:timeout, "Response timed out")
         
     | 
| 
       241 
     | 
    
         
            -
                  send_callback(:on_error)
         
     | 
| 
       242 
     | 
    
         
            -
                elsif (!@connected)
         
     | 
| 
       243 
     | 
    
         
            -
                  remote_options = @options
         
     | 
| 
       244 
     | 
    
         
            -
                  interpreter = @interpreter
         
     | 
| 
       245 
     | 
    
         
            -
                  
         
     | 
| 
       246 
     | 
    
         
            -
                  if (self.proxy_connection_initiated?)
         
     | 
| 
       247 
     | 
    
         
            -
                    remote_options = @options[:proxy]
         
     | 
| 
       248 
     | 
    
         
            -
                  end
         
     | 
| 
       249 
     | 
    
         
            -
                  
         
     | 
| 
       250 
     | 
    
         
            -
                  message = "Timed out before a connection could be established to #{remote_options[:host]}:#{remote_options[:port]}"
         
     | 
| 
       251 
     | 
    
         
            -
                  
         
     | 
| 
       252 
     | 
    
         
            -
                  if (interpreter)
         
     | 
| 
       253 
     | 
    
         
            -
                    message << " using #{interpreter.label}"
         
     | 
| 
       254 
     | 
    
         
            -
                  end
         
     | 
| 
       255 
     | 
    
         
            -
                  
         
     | 
| 
       256 
     | 
    
         
            -
                  connect_notification(false, message)
         
     | 
| 
       257 
     | 
    
         
            -
                  debug_notification(:timeout, message)
         
     | 
| 
       258 
     | 
    
         
            -
                  error_notification(:timeout, message)
         
     | 
| 
       259 
     | 
    
         
            -
             
     | 
| 
       260 
     | 
    
         
            -
                  send_callback(:on_error)
         
     | 
| 
       261 
     | 
    
         
            -
                else
         
     | 
| 
       262 
     | 
    
         
            -
                  interpreter = @interpreter
         
     | 
| 
       263 
     | 
    
         
            -
             
     | 
| 
       264 
     | 
    
         
            -
                  if (interpreter and interpreter.respond_to?(:close))
         
     | 
| 
       265 
     | 
    
         
            -
                    interpreter.close
         
     | 
| 
       266 
     | 
    
         
            -
                  else
         
     | 
| 
       267 
     | 
    
         
            -
                    send_callback(:on_disconnect)
         
     | 
| 
       268 
     | 
    
         
            -
                  end
         
     | 
| 
       269 
     | 
    
         
            -
                end
         
     | 
| 
       270 
     | 
    
         
            -
             
     | 
| 
       271 
     | 
    
         
            -
                close_connection
         
     | 
| 
       272 
     | 
    
         
            -
              end
         
     | 
| 
       273 
205 
     | 
    
         | 
| 
       274 
206 
     | 
    
         
             
              # Returns true if pipelining support has been detected on the connection,
         
     | 
| 
       275 
207 
     | 
    
         
             
              # false otherwise.
         
     | 
| 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class Remailer::SMTP::Server::Interpreter < Remailer::Interpreter
         
     | 
| 
       2 
2 
     | 
    
         
             
              # == State Definitions ====================================================
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
       4 
4 
     | 
    
         
             
              default do |error|
         
     | 
| 
       5 
5 
     | 
    
         
             
                delegate.send_line("500 Invalid command")
         
     | 
| 
       6 
6 
     | 
    
         
             
              end
         
     | 
| 
         @@ -159,8 +159,8 @@ class Remailer::SMTP::Server::Interpreter < Remailer::Interpreter 
     | 
|
| 
       159 
159 
     | 
    
         | 
| 
       160 
160 
     | 
    
         
             
                default do |line|
         
     | 
| 
       161 
161 
     | 
    
         
             
                  # RFC5321 4.5.2 - Leading dot is removed if line has content
         
     | 
| 
       162 
     | 
    
         
            -
             
     | 
| 
       163 
     | 
    
         
            -
                  @transaction.data << (line.sub(/^\./, '')  
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
                  @transaction.data << (line.sub(/^\./, '') << Remailer::Constants::CRLF)
         
     | 
| 
       164 
164 
     | 
    
         
             
                end
         
     | 
| 
       165 
165 
     | 
    
         
             
              end
         
     | 
| 
       166 
166 
     | 
    
         | 
    
        data/remailer.gemspec
    CHANGED
    
    | 
         @@ -5,11 +5,11 @@ 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       7 
7 
     | 
    
         
             
              s.name = "remailer"
         
     | 
| 
       8 
     | 
    
         
            -
              s.version = "0.5. 
     | 
| 
      
 8 
     | 
    
         
            +
              s.version = "0.5.2"
         
     | 
| 
       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 = "2012- 
     | 
| 
      
 12 
     | 
    
         
            +
              s.date = "2012-11-30"
         
     | 
| 
       13 
13 
     | 
    
         
             
              s.description = "EventMachine SMTP Mail User Agent"
         
     | 
| 
       14 
14 
     | 
    
         
             
              s.email = "scott@twg.ca"
         
     | 
| 
       15 
15 
     | 
    
         
             
              s.extra_rdoc_files = [
         
     | 
| 
         @@ -56,7 +56,7 @@ Gem::Specification.new do |s| 
     | 
|
| 
       56 
56 
     | 
    
         
             
              ]
         
     | 
| 
       57 
57 
     | 
    
         
             
              s.homepage = "http://github.com/twg/remailer"
         
     | 
| 
       58 
58 
     | 
    
         
             
              s.require_paths = ["lib"]
         
     | 
| 
       59 
     | 
    
         
            -
              s.rubygems_version = "1.8. 
     | 
| 
      
 59 
     | 
    
         
            +
              s.rubygems_version = "1.8.24"
         
     | 
| 
       60 
60 
     | 
    
         
             
              s.summary = "Reactor-Ready SMTP Mailer"
         
     | 
| 
       61 
61 
     | 
    
         | 
| 
       62 
62 
     | 
    
         
             
              if s.respond_to? :specification_version then
         
     | 
    
        data/test/helper.rb
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'rubygems'
         
     | 
| 
       2 
2 
     | 
    
         
             
            require 'test/unit'
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
            $LOAD_PATH.unshift(File.expand_path( 
     | 
| 
      
 4 
     | 
    
         
            +
            $LOAD_PATH.unshift(File.expand_path('../lib', File.dirname(__FILE__)))
         
     | 
| 
       5 
5 
     | 
    
         
             
            $LOAD_PATH.unshift(File.dirname(__FILE__))
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            require 'timeout'
         
     | 
| 
         @@ -14,6 +14,8 @@ rescue => e 
     | 
|
| 
       14 
14 
     | 
    
         
             
              raise "EventMachine gem could not be loaded: #{e.class}: #{e}"
         
     | 
| 
       15 
15 
     | 
    
         
             
            end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
      
 17 
     | 
    
         
            +
            puts $LOAD_PATH.inspect
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
       17 
19 
     | 
    
         
             
            require 'remailer'
         
     | 
| 
       18 
20 
     | 
    
         | 
| 
       19 
21 
     | 
    
         
             
            class Proc
         
     | 
| 
         @@ -31,7 +31,7 @@ class RemailerIMAPClientTest < Test::Unit::TestCase 
     | 
|
| 
       31 
31 
     | 
    
         
             
                    capabilities
         
     | 
| 
       32 
32 
     | 
    
         
             
                  end
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
                  assert_equal %w[ IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH ], capabilities
         
     | 
| 
      
 34 
     | 
    
         
            +
                  assert_equal %w[ IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 XYZZY SASL-IR AUTH=XOAUTH AUTH=XOAUTH2 ], capabilities
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
       36 
36 
     | 
    
         
             
                  # -- LOGIN ------------------------------------------------------------
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require File.expand_path( 
     | 
| 
      
 1 
     | 
    
         
            +
            require File.expand_path('../helper', File.dirname(__FILE__))
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            class RemailerSMTPServerTest < Test::Unit::TestCase
         
     | 
| 
       4 
4 
     | 
    
         
             
              def test_bind
         
     | 
| 
         @@ -67,9 +67,9 @@ class RemailerSMTPServerTest < Test::Unit::TestCase 
     | 
|
| 
       67 
67 
     | 
    
         | 
| 
       68 
68 
     | 
    
         
             
                  sender = 'sender@example.com'.freeze
         
     | 
| 
       69 
69 
     | 
    
         
             
                  recipient = 'recipient@example.net'.freeze
         
     | 
| 
       70 
     | 
    
         
            -
                   
     | 
| 
      
 70 
     | 
    
         
            +
                  content = "Subject: Re: Test Message\r\n\r\nTest message.\r\n\r\n.test\r\n.\r\n".freeze
         
     | 
| 
       71 
71 
     | 
    
         | 
| 
       72 
     | 
    
         
            -
                  client.send_email(sender, recipient,  
     | 
| 
      
 72 
     | 
    
         
            +
                  client.send_email(sender, recipient, content)
         
     | 
| 
       73 
73 
     | 
    
         | 
| 
       74 
74 
     | 
    
         
             
                  assert_eventually(30) do
         
     | 
| 
       75 
75 
     | 
    
         
             
                    transaction
         
     | 
| 
         @@ -77,7 +77,7 @@ class RemailerSMTPServerTest < Test::Unit::TestCase 
     | 
|
| 
       77 
77 
     | 
    
         | 
| 
       78 
78 
     | 
    
         
             
                  assert_equal sender, transaction.sender
         
     | 
| 
       79 
79 
     | 
    
         
             
                  assert_equal [ recipient ], transaction.recipients
         
     | 
| 
       80 
     | 
    
         
            -
                  assert_equal  
     | 
| 
      
 80 
     | 
    
         
            +
                  assert_equal content + Remailer::Constants::CRLF, transaction.data
         
     | 
| 
       81 
81 
     | 
    
         
             
                end
         
     | 
| 
       82 
82 
     | 
    
         
             
              end
         
     | 
| 
       83 
83 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: remailer
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.5. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.5.2
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -9,11 +9,11 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2012- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2012-11-30 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: eventmachine
         
     | 
| 
       16 
     | 
    
         
            -
              requirement:  
     | 
| 
      
 16 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       17 
17 
     | 
    
         
             
                none: false
         
     | 
| 
       18 
18 
     | 
    
         
             
                requirements:
         
     | 
| 
       19 
19 
     | 
    
         
             
                - - ! '>='
         
     | 
| 
         @@ -21,7 +21,12 @@ dependencies: 
     | 
|
| 
       21 
21 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       22 
22 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       23 
23 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       24 
     | 
    
         
            -
              version_requirements:  
     | 
| 
      
 24 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 25 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 26 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 27 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 28 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 29 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
       25 
30 
     | 
    
         
             
            description: EventMachine SMTP Mail User Agent
         
     | 
| 
       26 
31 
     | 
    
         
             
            email: scott@twg.ca
         
     | 
| 
       27 
32 
     | 
    
         
             
            executables: []
         
     | 
| 
         @@ -86,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       86 
91 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       87 
92 
     | 
    
         
             
            requirements: []
         
     | 
| 
       88 
93 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       89 
     | 
    
         
            -
            rubygems_version: 1.8. 
     | 
| 
      
 94 
     | 
    
         
            +
            rubygems_version: 1.8.24
         
     | 
| 
       90 
95 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       91 
96 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       92 
97 
     | 
    
         
             
            summary: Reactor-Ready SMTP Mailer
         
     |