Package opensmtpd implements OpenSMTPD-extras in Go
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

session.go 715B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package opensmtpd
  2. type Session struct {
  3. ID uint64
  4. filter *Filter
  5. qtype int
  6. qid uint64
  7. }
  8. func NewSession(f *Filter, id uint64) *Session {
  9. return &Session{
  10. ID: id,
  11. filter: f,
  12. }
  13. }
  14. func (s *Session) Accept() error {
  15. return s.filter.respond(s, FilterOK, 0, "")
  16. }
  17. func (s *Session) AcceptCode(code int, line string) error {
  18. return s.filter.respond(s, FilterOK, code, line)
  19. }
  20. func (s *Session) Reject(status, code int) error {
  21. if status == FilterOK {
  22. status = FilterFail
  23. }
  24. return s.filter.respond(s, status, code, "")
  25. }
  26. func (s *Session) RejectCode(status, code int, line string) error {
  27. if status == FilterOK {
  28. status = FilterFail
  29. }
  30. return s.filter.respond(s, status, code, line)
  31. }