1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-18 10:07:02 +00:00

feat: Add RemoteAddr to SMTPSession (#548)

Signed-off-by: James Hillyerd <james@hillyerd.com>
This commit is contained in:
James Hillyerd
2024-10-20 11:49:55 -07:00
committed by GitHub
parent 78d4c4f4e7
commit 15d1970dbe
5 changed files with 42 additions and 20 deletions

View File

@@ -47,20 +47,22 @@ func checkSMTPSession(ls *lua.LState, pos int) *event.SMTPSession {
// Gets a field value from SMTPSession user object. This emulates a Lua table,
// allowing `msg.subject` instead of a Lua object syntax of `msg:subject()`.
func smtpSessionIndex(ls *lua.LState) int {
m := checkSMTPSession(ls, 1)
session := checkSMTPSession(ls, 1)
field := ls.CheckString(2)
// Push the requested field's value onto the stack.
switch field {
case "from":
ls.Push(wrapMailAddress(ls, m.From))
ls.Push(wrapMailAddress(ls, session.From))
case "to":
lt := &lua.LTable{}
for _, v := range m.To {
for _, v := range session.To {
addr := v
lt.Append(wrapMailAddress(ls, addr))
}
ls.Push(lt)
case "remote_addr":
ls.Push(lua.LString(session.RemoteAddr))
default:
// Unknown field.
ls.Push(lua.LNil)