Module: Pounder::Server::Command

Included in:
Pounder::Server
Defined in:
lib/pounder/server/command.rb

Instance Method Summary collapse

Instance Method Details

#cmd_DELE(params) ⇒ Object



28
29
30
31
# File 'lib/pounder/server/command.rb', line 28

def cmd_DELE(params)
  # nop.
  print_line "+OK"
end

#cmd_LIST(params) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/pounder/server/command.rb', line 10

def cmd_LIST(params)
  print_line "+OK"
  params[:maildir].messages.each do |m|
    print_line "#{m.seq} #{m.octets}"
  end
  print_line "."
end

#cmd_PASS(params) ⇒ Object



23
24
25
26
# File 'lib/pounder/server/command.rb', line 23

def cmd_PASS(params)
  # nop.
  print_line "+OK"
end

#cmd_QUIT(params) ⇒ Object



33
34
35
36
# File 'lib/pounder/server/command.rb', line 33

def cmd_QUIT(params)
  print_line "+OK"
  terminate
end

#cmd_RETR(params) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/pounder/server/command.rb', line 38

def cmd_RETR(params)
  message = params[:maildir][params[:args].first.to_i]
  print_line "+OK"
  message.each_line do |line|
    if line.match(/\ADate: .*/) then
      # Outputs a Date header of the time it was run.
      print_line "Date: #{DateTime.now.httpdate}"
      next
    elsif (params[:options][:from_address] && line.match(/\AFrom: .*/)) then
      print_line "From: \"#{params[:options][:from_address]}\" <#{params[:options][:from_address]}>"
      next
    end
    print_line_message line
  end

  # To prevent dot to become a part of the body,
  # and outputs a new line.
  print_line ""
  print_line "."
end

#cmd_STAT(params) ⇒ Object



6
7
8
# File 'lib/pounder/server/command.rb', line 6

def cmd_STAT(params)
  print_line "+OK #{params[:maildir].size} #{params[:maildir].total_octets}"
end

#cmd_USER(params) ⇒ Object



18
19
20
21
# File 'lib/pounder/server/command.rb', line 18

def cmd_USER(params)
  # nop.
  print_line "+OK"
end