mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-17 17:47:03 +00:00
Impl deletes, update SMTP session tracing
This commit is contained in:
@@ -492,7 +492,13 @@ func (ses *Session) retainAll() {
|
|||||||
// indicates that the session was closed cleanly and that deletes should be
|
// indicates that the session was closed cleanly and that deletes should be
|
||||||
// processed.
|
// processed.
|
||||||
func (ses *Session) processDeletes() {
|
func (ses *Session) processDeletes() {
|
||||||
ses.trace("Processing deletes")
|
ses.info("Processing deletes")
|
||||||
|
for i, msg := range ses.messages {
|
||||||
|
if !ses.retain[i] {
|
||||||
|
ses.trace("Deleting %v", msg)
|
||||||
|
msg.Delete()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ses *Session) enterState(state State) {
|
func (ses *Session) enterState(state State) {
|
||||||
|
|||||||
@@ -83,12 +83,12 @@ func (ss *Session) String() string {
|
|||||||
/* Session flow:
|
/* Session flow:
|
||||||
* 1. Send initial greeting
|
* 1. Send initial greeting
|
||||||
* 2. Receive cmd
|
* 2. Receive cmd
|
||||||
* 3. If good cmd, respond, optionally change state
|
* 3. If good cmd, respond, optionally change state
|
||||||
* 4. If bad cmd, respond error
|
* 4. If bad cmd, respond error
|
||||||
* 5. Goto 2
|
* 5. Goto 2
|
||||||
*/
|
*/
|
||||||
func (s *Server) startSession(id int, conn net.Conn) {
|
func (s *Server) startSession(id int, conn net.Conn) {
|
||||||
log.Info("Connection from %v, starting session <%v>", conn.RemoteAddr(), id)
|
log.Info("SMTP Connection from %v, starting session <%v>", conn.RemoteAddr(), id)
|
||||||
expConnectsCurrent.Add(1)
|
expConnectsCurrent.Add(1)
|
||||||
defer func() {
|
defer func() {
|
||||||
conn.Close()
|
conn.Close()
|
||||||
@@ -512,21 +512,21 @@ func (ss *Session) ooSeq(cmd string) {
|
|||||||
|
|
||||||
// Session specific logging methods
|
// Session specific logging methods
|
||||||
func (ss *Session) trace(msg string, args ...interface{}) {
|
func (ss *Session) trace(msg string, args ...interface{}) {
|
||||||
log.Trace("%v<%v> %v", ss.remoteHost, ss.id, fmt.Sprintf(msg, args...))
|
log.Trace("SMTP<%v> %v", ss.id, fmt.Sprintf(msg, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ss *Session) info(msg string, args ...interface{}) {
|
func (ss *Session) info(msg string, args ...interface{}) {
|
||||||
log.Info("%v<%v> %v", ss.remoteHost, ss.id, fmt.Sprintf(msg, args...))
|
log.Info("SMTP<%v> %v", ss.id, fmt.Sprintf(msg, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ss *Session) warn(msg string, args ...interface{}) {
|
func (ss *Session) warn(msg string, args ...interface{}) {
|
||||||
// Update metrics
|
// Update metrics
|
||||||
expWarnsTotal.Add(1)
|
expWarnsTotal.Add(1)
|
||||||
log.Warn("%v<%v> %v", ss.remoteHost, ss.id, fmt.Sprintf(msg, args...))
|
log.Warn("SMTP<%v> %v", ss.id, fmt.Sprintf(msg, args...))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ss *Session) error(msg string, args ...interface{}) {
|
func (ss *Session) error(msg string, args ...interface{}) {
|
||||||
// Update metrics
|
// Update metrics
|
||||||
expErrorsTotal.Add(1)
|
expErrorsTotal.Add(1)
|
||||||
log.Error("%v<%v> %v", ss.remoteHost, ss.id, fmt.Sprintf(msg, args...))
|
log.Error("SMTP<%v> %v", ss.id, fmt.Sprintf(msg, args...))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user