lint, gitignore, GNU Makefile to make things simpler
This commit is contained in:
parent
006a4f9d6d
commit
7df5779a24
5 changed files with 38 additions and 25 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
.idea/
|
12
Makefile
Normal file
12
Makefile
Normal file
|
@ -0,0 +1,12 @@
|
|||
test: check
|
||||
|
||||
check: lint
|
||||
go test -v
|
||||
|
||||
lint:
|
||||
gofmt -w=true -s=true -l=true ./
|
||||
golint ./...
|
||||
go vet ./...
|
||||
|
||||
|
||||
|
2
go.mod
2
go.mod
|
@ -1,3 +1,3 @@
|
|||
module github.com/chrj/smtpd
|
||||
|
||||
go 1.14
|
||||
go 1.19
|
||||
|
|
34
smtpd.go
34
smtpd.go
|
@ -66,10 +66,11 @@ type Server struct {
|
|||
type Protocol string
|
||||
|
||||
const (
|
||||
// SMTP
|
||||
// SMTP means Simple Mail Transfer Protocol
|
||||
SMTP Protocol = "SMTP"
|
||||
|
||||
// Extended SMTP
|
||||
// ESMTP means Extended Simple Mail Transfer Protocol, because it has some extra features
|
||||
// Simple Mail Transfer Protocol doesn't have
|
||||
ESMTP = "ESMTP"
|
||||
)
|
||||
|
||||
|
@ -228,7 +229,7 @@ func (srv *Server) Shutdown(wait bool) error {
|
|||
// First close the listener
|
||||
srv.mu.Lock()
|
||||
if srv.listener != nil {
|
||||
lnerr = (*srv.listener).Close();
|
||||
lnerr = (*srv.listener).Close()
|
||||
}
|
||||
srv.closeDoneChanLocked()
|
||||
srv.mu.Unlock()
|
||||
|
@ -254,7 +255,7 @@ func (srv *Server) Wait() error {
|
|||
|
||||
// Address returns the listening address of the server
|
||||
func (srv *Server) Address() net.Addr {
|
||||
return (*srv.listener).Addr();
|
||||
return (*srv.listener).Addr()
|
||||
}
|
||||
|
||||
func (srv *Server) configureDefaults() {
|
||||
|
@ -433,28 +434,27 @@ func (session *session) close() {
|
|||
session.conn.Close()
|
||||
}
|
||||
|
||||
|
||||
// From net/http/server.go
|
||||
|
||||
func (s *Server) shuttingDown() bool {
|
||||
return s.inShutdown.isSet()
|
||||
func (srv *Server) shuttingDown() bool {
|
||||
return srv.inShutdown.isSet()
|
||||
}
|
||||
|
||||
func (s *Server) getDoneChan() <-chan struct{} {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
return s.getDoneChanLocked()
|
||||
func (srv *Server) getDoneChan() <-chan struct{} {
|
||||
srv.mu.Lock()
|
||||
defer srv.mu.Unlock()
|
||||
return srv.getDoneChanLocked()
|
||||
}
|
||||
|
||||
func (s *Server) getDoneChanLocked() chan struct{} {
|
||||
if s.doneChan == nil {
|
||||
s.doneChan = make(chan struct{})
|
||||
func (srv *Server) getDoneChanLocked() chan struct{} {
|
||||
if srv.doneChan == nil {
|
||||
srv.doneChan = make(chan struct{})
|
||||
}
|
||||
return s.doneChan
|
||||
return srv.doneChan
|
||||
}
|
||||
|
||||
func (s *Server) closeDoneChanLocked() {
|
||||
ch := s.getDoneChanLocked()
|
||||
func (srv *Server) closeDoneChanLocked() {
|
||||
ch := srv.getDoneChanLocked()
|
||||
select {
|
||||
case <-ch:
|
||||
// Already closed. Don't close again.
|
||||
|
|
Loading…
Add table
Reference in a new issue