Changeset a6f716d7d5a83b908b2739db317651b19855f337

Show
Ignore:
Timestamp:
05/10/12 12:23:48 (2 years ago)
Author:
Theo Schlossnagle <jesus@lethargy.org>
git-committer:
Theo Schlossnagle <jesus@lethargy.org> 1336652628 -0700
git-parent:

[2fca673b4c11f684f51006dceb5daac6fdcfd94d], [36e16b6395712e880342df82953be8f8be31f548]

git-author:
Theo Schlossnagle <jesus@lethargy.org> 1336652628 -0700
Message:

Merge pull request #68 from ddispaltro/add_send_quit_on_no_to_merged

Make the "to" field optional

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/modules-lua/noit/module/smtp.lua

    r3f101f0 r36e16b6  
    4646    <parameter name="from" required="optional" default="" 
    4747               allowed=".+">Specifies the envelope sender.</parameter> 
    48     <parameter name="to" required="required
    49                allowed=".+">Specifies the envelope recipient.</parameter> 
     48    <parameter name="to" required="optional
     49               allowed=".+">Specifies the envelope recipient, if blank issue quit.</parameter> 
    5050    <parameter name="payload" required="optional" default="Subject: Testing" 
    5151               allowed=".+">Specifies the payload sent (on the wire). CR LF DOT CR LF is appended automatically.</parameter> 
     
    254254end 
    255255 
     256function ex_actions(action, check, mailfrom, rcptto, payload) 
     257  local status = '' 
     258  -- Only proceed if from is present, empty or not 
     259  if check.config.from == "" or check.config.from then 
     260    action("mailfrom", mailfrom, 250) 
     261  else 
     262     return status 
     263  end 
     264 
     265  if check.config.to then 
     266     action("rcptto", rcptto, 250) 
     267  else 
     268     return status 
     269  end 
     270 
     271  -- Since the way the protocol works, the to address may be in the payload... 
     272  if payload then 
     273     action("data", "DATA", 354) 
     274     action("body", payload .. "\r\n.", 250) 
     275     status = ',sent' 
     276  end 
     277  return status 
     278end 
     279 
    256280function initiate(module, check) 
    257281  local starttime = noit.timeval.now() 
    258282  local e = noit.socket(check.target_ip) 
    259283  local rv, err = e:connect(check.target_ip, check.config.port or 25) 
     284  local action_result 
    260285  check.unavailable() 
    261286 
     
    312337  end 
    313338 
    314   if     action("mailfrom", mailfrom, 250) 
    315      and action("rcptto", rcptto, 250) 
    316      and action("data", "DATA", 354) 
    317      and action("body", payload .. "\r\n.", 250) 
    318      and action("quit", "QUIT", 221) 
    319   then 
    320     status = status .. ',sent' 
    321   else 
    322     return 
    323   end 
     339  action_result = ex_actions(action, check, mailfrom, rcptto, payload) 
     340  -- Always issue quit 
     341  action("quit", "QUIT", 221) 
     342 
     343  status = status .. action_result 
     344 
    324345  check.status(status) 
    325346  if good then check.good() end