mirror of
https://github.com/decke/smtprelay.git
synced 2025-12-25 07:43:06 -07:00
Fix code formatting with gofmt -s
This commit is contained in:
19
config.go
19
config.go
@@ -7,8 +7,8 @@ import (
|
|||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/vharitonsky/iniflags"
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
"github.com/vharitonsky/iniflags"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -47,7 +47,6 @@ func localAuthRequired() bool {
|
|||||||
return *allowedUsers != ""
|
return *allowedUsers != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func setupAllowedNetworks() {
|
func setupAllowedNetworks() {
|
||||||
for _, netstr := range splitstr(*allowedNetsStr, ' ') {
|
for _, netstr := range splitstr(*allowedNetsStr, ' ') {
|
||||||
baseIP, allowedNet, err := net.ParseCIDR(netstr)
|
baseIP, allowedNet, err := net.ParseCIDR(netstr)
|
||||||
@@ -73,7 +72,7 @@ func setupAllowedNetworks() {
|
|||||||
func setupAllowedPatterns() {
|
func setupAllowedPatterns() {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
if (*allowedSenderStr != "") {
|
if *allowedSenderStr != "" {
|
||||||
allowedSender, err = regexp.Compile(*allowedSenderStr)
|
allowedSender, err = regexp.Compile(*allowedSenderStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithField("allowed_sender", *allowedSenderStr).
|
log.WithField("allowed_sender", *allowedSenderStr).
|
||||||
@@ -82,7 +81,7 @@ func setupAllowedPatterns() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*allowedRecipStr != "") {
|
if *allowedRecipStr != "" {
|
||||||
allowedRecipients, err = regexp.Compile(*allowedRecipStr)
|
allowedRecipients, err = regexp.Compile(*allowedRecipStr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.WithField("allowed_recipients", *allowedRecipStr).
|
log.WithField("allowed_recipients", *allowedRecipStr).
|
||||||
@@ -92,7 +91,6 @@ func setupAllowedPatterns() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func setupRemoteAuth() {
|
func setupRemoteAuth() {
|
||||||
logger := log.WithField("remote_auth", *remoteAuthStr)
|
logger := log.WithField("remote_auth", *remoteAuthStr)
|
||||||
|
|
||||||
@@ -144,13 +142,13 @@ type protoAddr struct {
|
|||||||
func splitProto(s string) protoAddr {
|
func splitProto(s string) protoAddr {
|
||||||
idx := strings.Index(s, "://")
|
idx := strings.Index(s, "://")
|
||||||
if idx == -1 {
|
if idx == -1 {
|
||||||
return protoAddr {
|
return protoAddr{
|
||||||
address: s,
|
address: s,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return protoAddr {
|
return protoAddr{
|
||||||
protocol: s[0 : idx],
|
protocol: s[0:idx],
|
||||||
address: s[idx+3 : len(s)],
|
address: s[idx+3:],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +162,6 @@ func setupListeners() {
|
|||||||
"not allowed with non-TLS listener")
|
"not allowed with non-TLS listener")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
listenAddrs = append(listenAddrs, pa)
|
listenAddrs = append(listenAddrs, pa)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -175,7 +172,7 @@ func ConfigLoad() {
|
|||||||
// Set up logging as soon as possible
|
// Set up logging as soon as possible
|
||||||
setupLogger()
|
setupLogger()
|
||||||
|
|
||||||
if (*remoteHost == "") {
|
if *remoteHost == "" {
|
||||||
log.Warn("remote_host not set; mail will not be forwarded!")
|
log.Warn("remote_host not set; mail will not be forwarded!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ func setupLogger() {
|
|||||||
log = logrus.New()
|
log = logrus.New()
|
||||||
|
|
||||||
// Handle logfile
|
// Handle logfile
|
||||||
if (*logFile == "") {
|
if *logFile == "" {
|
||||||
log.SetOutput(os.Stderr)
|
log.SetOutput(os.Stderr)
|
||||||
} else {
|
} else {
|
||||||
writer, err := os.OpenFile(*logFile, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0600)
|
writer, err := os.OpenFile(*logFile, os.O_CREATE|os.O_RDWR|os.O_APPEND, 0600)
|
||||||
|
|||||||
2
main.go
2
main.go
@@ -163,7 +163,7 @@ func mailHandler(peer smtpd.Peer, env smtpd.Envelope) error {
|
|||||||
"uuid": generateUUID(),
|
"uuid": generateUUID(),
|
||||||
})
|
})
|
||||||
|
|
||||||
if (*remoteHost == "") {
|
if *remoteHost == "" {
|
||||||
logger.Warning("remote_host not set; discarding mail")
|
logger.Warning("remote_host not set; discarding mail")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user