|
@@ -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)
|
|
@@ -61,7 +60,7 @@ func setupAllowedNetworks() {
|
|
// meaning the address refers to a host and not a network.
|
|
// meaning the address refers to a host and not a network.
|
|
if !allowedNet.IP.Equal(baseIP) {
|
|
if !allowedNet.IP.Equal(baseIP) {
|
|
log.WithFields(logrus.Fields{
|
|
log.WithFields(logrus.Fields{
|
|
- "given_net": netstr,
|
|
|
|
|
|
+ "given_net": netstr,
|
|
"proper_net": allowedNet,
|
|
"proper_net": allowedNet,
|
|
}).Fatal("Invalid network in allowed_nets (host bits set)")
|
|
}).Fatal("Invalid network in allowed_nets (host bits set)")
|
|
}
|
|
}
|
|
@@ -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)
|
|
|
|
|
|
@@ -123,7 +121,7 @@ func setupRemoteAuth() {
|
|
host, _, err := net.SplitHostPort(*remoteHost)
|
|
host, _, err := net.SplitHostPort(*remoteHost)
|
|
if err != nil {
|
|
if err != nil {
|
|
logger.WithField("remote_host", *remoteHost).
|
|
logger.WithField("remote_host", *remoteHost).
|
|
- Fatal("Invalid remote_host")
|
|
|
|
|
|
+ Fatal("Invalid remote_host")
|
|
}
|
|
}
|
|
|
|
|
|
switch *remoteAuthStr {
|
|
switch *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 {
|
|
|
|
- address: s,
|
|
|
|
|
|
+ return protoAddr{
|
|
|
|
+ address: s,
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return protoAddr {
|
|
|
|
- protocol: s[0 : idx],
|
|
|
|
- address: s[idx+3 : len(s)],
|
|
|
|
|
|
+ return protoAddr{
|
|
|
|
+ protocol: s[0:idx],
|
|
|
|
+ address: s[idx+3:],
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -161,10 +159,9 @@ func setupListeners() {
|
|
if localAuthRequired() && pa.protocol == "" {
|
|
if localAuthRequired() && pa.protocol == "" {
|
|
log.WithField("address", pa.address).
|
|
log.WithField("address", pa.address).
|
|
Fatal("Local authentication (via allowed_users file) " +
|
|
Fatal("Local authentication (via allowed_users file) " +
|
|
- "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!")
|
|
}
|
|
}
|
|
|
|
|