This is the main dovel repository, it has the Go code to run dovel SMTP server.
Author: blmayer (bleemayer@gmail.com)
Date: Wed Sep 13 13:42:31 2023 -0300
Parent: 885ff35
Removed link check. Use hard links
commit aaa89b448a20a157f885a89aa9d15ab2577e1ec2 Author: blmayer <bleemayer@gmail.com> Date: Wed Sep 13 13:42:31 2023 -0300 Removed link check. Use hard links diff --git a/cmd/dovel/backend.go b/cmd/dovel/backend.go index b18e60d..029daf9 100644 --- a/cmd/dovel/backend.go +++ b/cmd/dovel/backend.go @@ -5,7 +5,6 @@ import ( "bytes" "fmt" "io" - "io/ioutil" "net" "net/mail" "net/textproto" @@ -78,14 +77,7 @@ func (s *Session) Data(raw io.Reader) error { domain := strings.Split(from.Address, "@")[1] h := path.Join(configPath, "hooks", "send-"+domain) - if f, err := os.Lstat(h); err == nil { - if !f.Mode().IsRegular() { - h, err = os.Readlink(h) - if err != nil { - println(domain, "read link", err.Error()) - } - } - + if _, err := os.Stat(h); err == nil { err = s.Send(s.from, s.tos, strings.NewReader(string(cont))) if err != nil { println("send", err.Error()) @@ -110,14 +102,9 @@ func (s *Session) Data(raw io.Reader) error { domain := strings.Split(toAddr.Address, "@")[1] h := path.Join(configPath, "hooks", "receive-"+domain) - if f, err := os.Lstat(h); err != nil { + if _, err := os.Stat(h); err != nil { println(domain, "receive error:", err.Error()) continue - } else if !f.Mode().IsRegular() { - h, err = os.Readlink(h) - if err != nil { - println(domain, "read link", err.Error()) - } } c := exec.Command(h) @@ -145,7 +132,7 @@ func (s *Session) Send(from string, tos []string, raw io.Reader) error { return err } - body, err := ioutil.ReadAll(email.Body) + body, err := io.ReadAll(email.Body) if err != nil { return err }