func (milter *milter) Eom(ctx uintptr) (sfsistat int8) { defer milterHandleError(ctx, &sfsistat) s := milterGetSession(ctx, true, false) StatsCounters["MilterCallbackEom"].increase(1) Log.Debug("%s milter.Eom() was called", s.milterGetDisplayId()) verdict, msg, results := messageGetVerdict(s.getLastMessage()) headersAdd, headersDelete := messageGetMutableHeaders(s.getLastMessage(), results) for _, hdr := range headersDelete { var delete string // Must be null to delete m.ChgHeader(ctx, hdr.getKey(), hdr.milterIdx, delete) hdr.deleted = true for _, allHdr := range s.getLastMessage().GetHeader(hdr.getKey(), false) { if allHdr.milterIdx > hdr.milterIdx { allHdr.milterIdx = allHdr.milterIdx - 1 } } } for _, hdr := range headersAdd { m.AddHeader(ctx, hdr.getKey(), hdr.getValue()) } if s.isWhitelisted() { verdict = messagePermit msg = "Whitelisted" } switch { case verdict == messagePermit: Log.Info("Message Permit: sess=%s message=%s %s", s.milterGetDisplayId(), s.getLastMessage().QueueId, msg) return case verdict == messageTempFail: m.SetReply(ctx, "421", "4.7.0", msg) Log.Info("Message TempFail: sess=%s message=%s msg: %s", s.milterGetDisplayId(), s.getLastMessage().QueueId, msg) if Config.ClueGetter.Noop { return } return m.Tempfail case verdict == messageReject: m.SetReply(ctx, "550", "5.7.1", msg) Log.Info("Message Reject: sess=%s message=%s msg: %s", s.milterGetDisplayId(), s.getLastMessage().QueueId, msg) if Config.ClueGetter.Noop { return } return m.Reject } panic("verdict was not recognized") }
func (milter *milter) Eom(ctx uintptr) (sfsistat int8) { defer milterHandleError(ctx, &sfsistat) s := milterGetSession(ctx, true, false) StatsCounters["MilterCallbackEom"].increase(1) Log.Debug("%d milter.Eom() was called", s.getId()) verdict, msg, results := messageGetVerdict(s.getLastMessage()) for _, hdr := range messageGetHeadersToAdd(s.getLastMessage(), results) { m.AddHeader(ctx, hdr.getKey(), hdr.getValue()) } if s.isWhitelisted() { verdict = messagePermit msg = "Whitelisted" } switch { case verdict == messagePermit: Log.Info("Message Permit: sess=%d message=%s %s", s.getId(), s.getLastMessage().getQueueId(), msg) return case verdict == messageTempFail: m.SetReply(ctx, "421", "4.7.0", msg) Log.Info("Message TempFail: sess=%d message=%s msg: %s", s.getId(), s.getLastMessage().getQueueId(), msg) if Config.ClueGetter.Noop { return } return m.Tempfail case verdict == messageReject: m.SetReply(ctx, "550", "5.7.1", msg) Log.Info("Message Reject: sess=%d message=%s msg: %s", s.getId(), s.getLastMessage().getQueueId(), msg) if Config.ClueGetter.Noop { return } return m.Reject } panic("verdict was not recognized") }