2
0
forked from drew/smtprelay

Add localAuthRequired() helper function

This just makes the configuration state a little more obvious.
This commit is contained in:
Jonathon Reinhart
2021-03-31 22:37:02 -04:00
parent ca1ccd85e3
commit 45a676e274
2 changed files with 7 additions and 3 deletions

View File

@@ -81,7 +81,7 @@ func addrAllowed(addr string, allowedAddrs []string) bool {
func senderChecker(peer smtpd.Peer, addr string) error {
// check sender address from auth file if user is authenticated
if *allowedUsers != "" && peer.Username != "" {
if localAuthRequired() && peer.Username != "" {
user, err := AuthFetch(peer.Username)
if err != nil {
// Shouldn't happen: authChecker already validated username+password
@@ -276,7 +276,7 @@ func main() {
Debug("starting smtprelay")
// Load allowed users file
if *allowedUsers != "" {
if localAuthRequired() {
err := AuthLoadFile(*allowedUsers)
if err != nil {
log.WithField("file", *allowedUsers).
@@ -300,7 +300,7 @@ func main() {
Handler: mailHandler,
}
if *allowedUsers != "" {
if localAuthRequired() {
server.Authenticator = authChecker
}