more refractoring, adding makefile for tests

This commit is contained in:
Johannes Bülow 2025-03-14 12:46:30 +01:00
parent 71409bf7cd
commit 194daa594d
Signed by: jmb
GPG key ID: B56971CF7B8F83A6
4 changed files with 30 additions and 14 deletions

8
Makefile Normal file
View file

@ -0,0 +1,8 @@
test:
go test .
dkim-proxy:
cd _examples && go get . && go build .
testsum:
gotestsum --format testname

22
error.go Normal file
View file

@ -0,0 +1,22 @@
package smtpd
import (
"errors"
"fmt"
)
// Error represents an Error reported in the SMTP session.
type Error struct {
Code int // The integer error code
Message string // The error message
}
// Error returns a string representation of the SMTP error
func (e Error) Error() string {
return fmt.Sprintf("%d %s", e.Code, e.Message)
}
// ErrServerClosed is returned by the Server's Serve and ListenAndServe,
// methods after a call to Shutdown.
var ErrServerClosed = errors.New("smtp: Server closed")

View file

@ -160,4 +160,3 @@ func (session *session) close() {
session.conn.Close()
}

View file

@ -83,19 +83,6 @@ type Peer struct {
TLS *tls.ConnectionState // TLS Connection details, if on TLS
}
// Error represents an Error reported in the SMTP session.
type Error struct {
Code int // The integer error code
Message string // The error message
}
// Error returns a string representation of the SMTP error
func (e Error) Error() string { return fmt.Sprintf("%d %s", e.Code, e.Message) }
// ErrServerClosed is returned by the Server's Serve and ListenAndServe,
// methods after a call to Shutdown.
var ErrServerClosed = errors.New("smtp: Server closed")
func (srv *Server) newSession(c net.Conn) (s *session) {
s = &session{