Class: MailDiode::DelayFilter

Inherits:
Filter
  • Object
show all
Defined in:
lib/maildiode-plugins/delay.rb

Instance Method Summary collapse

Methods inherited from Filter

#process

Constructor Details

#initialize(settings) ⇒ DelayFilter

Returns a new instance of DelayFilter.



18
19
20
21
22
23
# File 'lib/maildiode-plugins/delay.rb', line 18

def initialize(settings)
	@delay_helo = 0
	@delay_mail = 0
	@delay_rcpt = 0
	load_settings(settings)
end

Instance Method Details

#delay(name, seconds) ⇒ Object



37
38
39
40
# File 'lib/maildiode-plugins/delay.rb', line 37

def delay(name, seconds)
	MailDiode::log_debug "Delaying #{name} for #{seconds} seconds..."
	sleep(seconds)
end

#helo(helo) ⇒ Object



25
26
27
# File 'lib/maildiode-plugins/delay.rb', line 25

def helo(helo)
	delay('helo', @delay_helo)
end

#load_settings(settings) ⇒ Object



42
43
44
45
46
47
# File 'lib/maildiode-plugins/delay.rb', line 42

def load_settings(settings)
	@delay_helo = settings.get_setting('delay', 'helo').to_i
	@delay_mail = settings.get_setting('delay', 'mail').to_i
	@delay_rcpt = settings.get_setting('delay', 'rcpt').to_i
	MailDiode::log_debug "  HELO #{@delay_helo} MAIL #{@delay_mail} RCPT #{@delay_rcpt} seconds"
end

#mail(from) ⇒ Object



29
30
31
# File 'lib/maildiode-plugins/delay.rb', line 29

def mail(from)
	delay('mail', @delay_mail)
end

#rcpt(recipient) ⇒ Object



33
34
35
# File 'lib/maildiode-plugins/delay.rb', line 33

def rcpt(recipient)
	delay('rcpt', @delay_rcpt)
end