author | Alberto Bertogli
<albertito@blitiri.com.ar> 2016-11-22 22:05:07 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2016-11-22 22:05:07 UTC |
parent | b1a29d8194115842e5b808563cfb176d037c0ddb |
internal/smtpsrv/conn.go | +7 | -0 |
internal/smtpsrv/server_test.go | +3 | -0 |
diff --git a/internal/smtpsrv/conn.go b/internal/smtpsrv/conn.go index 29920f4..4950322 100644 --- a/internal/smtpsrv/conn.go +++ b/internal/smtpsrv/conn.go @@ -48,6 +48,9 @@ var ( var ( maxReceivedHeaders = flag.Int("testing__max_received_headers", 50, "max Received headers, for loop detection; ONLY FOR TESTING") + + // Some go tests disable SPF, to avoid leaking DNS lookups. + disableSPFForTesting = false ) // Mode for a socket (listening or connection). @@ -385,6 +388,10 @@ func (c *Conn) checkSPF(addr string) (spf.Result, error) { return "", nil } + if disableSPFForTesting { + return "", nil + } + if tcp, ok := c.conn.RemoteAddr().(*net.TCPAddr); ok { res, err := spf.CheckHost( tcp.IP, envelope.DomainOf(addr)) diff --git a/internal/smtpsrv/server_test.go b/internal/smtpsrv/server_test.go index 5b0bb00..08d4512 100644 --- a/internal/smtpsrv/server_test.go +++ b/internal/smtpsrv/server_test.go @@ -453,6 +453,9 @@ func realMain(m *testing.M) int { s.AddDomain("localhost") s.AddUserDB("localhost", udb) + // Disable SPF lookups, to avoid leaking DNS queries. + disableSPFForTesting = true + go s.ListenAndServe() }