module Pounder::Server::Command

Public Instance Methods

cmd_DELE(params) click to toggle source
# File lib/pounder/server/command.rb, line 28
def cmd_DELE(params)
  # nop.
  print_line "+OK"
end
cmd_LIST(params) click to toggle source
# 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) click to toggle source
# File lib/pounder/server/command.rb, line 23
def cmd_PASS(params)
  # nop.
  print_line "+OK"
end
cmd_QUIT(params) click to toggle source
# File lib/pounder/server/command.rb, line 33
def cmd_QUIT(params)
  print_line "+OK"
  terminate
end
cmd_RETR(params) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# File lib/pounder/server/command.rb, line 18
def cmd_USER(params)
  # nop.
  print_line "+OK"
end