more refractoring, adding makefile for tests
This commit is contained in:
parent
71409bf7cd
commit
194daa594d
4 changed files with 30 additions and 14 deletions
8
Makefile
Normal file
8
Makefile
Normal 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
22
error.go
Normal 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")
|
||||
|
||||
|
|
@ -160,4 +160,3 @@ func (session *session) close() {
|
|||
session.conn.Close()
|
||||
}
|
||||
|
||||
|
||||
|
|
13
smtpd.go
13
smtpd.go
|
@ -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{
|
||||
|
|
Loading…
Add table
Reference in a new issue