| 383 | } |
| 384 | |
| 385 | func (endp *Endpoint) NewSession(conn *smtp.Conn) (smtp.Session, error) { |
| 386 | sess := endp.newSession(conn) |
| 387 | |
| 388 | // Executed before authentication and session initialization. |
| 389 | if err := endp.pipeline.RunEarlyChecks(context.TODO(), &sess.connState); err != nil { |
| 390 | if err := sess.Logout(); err != nil { |
| 391 | endp.log.Error("early checks logout failed", err) |
| 392 | } |
| 393 | return nil, endp.wrapErr("", true, "EHLO", err) |
| 394 | } |
| 395 | |
| 396 | endp.sessionCnt.Add(1) |
| 397 | |
| 398 | return sess, nil |
| 399 | } |
| 400 | |
| 401 | func (endp *Endpoint) newSession(conn *smtp.Conn) *Session { |
| 402 | s := &Session{ |