mirror of
https://blitiri.com.ar/repos/chasquid
synced 2026-01-08 17:51:57 +00:00
smtp-check: Add a -skip_tls_check flag
This patch adds a -skip_tls_check flag, so smtp-check can still be used from places where outgoing SMTP connections are blocked.
This commit is contained in:
@@ -17,6 +17,8 @@ import (
|
|||||||
var (
|
var (
|
||||||
port = flag.String("port", "smtp",
|
port = flag.String("port", "smtp",
|
||||||
"port to use for connecting to the MX servers")
|
"port to use for connecting to the MX servers")
|
||||||
|
skipTLSCheck = flag.Bool("skip_tls_check", false,
|
||||||
|
"skip TLS check (useful if connections are blocked)")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -56,27 +58,32 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
c, err := smtp.Dial(mx.Host + ":" + *port)
|
if *skipTLSCheck {
|
||||||
if err != nil {
|
log.Printf("TLS check skipped")
|
||||||
log.Fatal(err)
|
} else {
|
||||||
}
|
c, err := smtp.Dial(mx.Host + ":" + *port)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
config := &tls.Config{
|
config := &tls.Config{
|
||||||
// Expect the server to have a certificate valid for the MX
|
// Expect the server to have a certificate valid for the MX
|
||||||
// we're connecting to.
|
// we're connecting to.
|
||||||
ServerName: mx.Host,
|
ServerName: mx.Host,
|
||||||
}
|
}
|
||||||
err = c.StartTLS(config)
|
err = c.StartTLS(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("TLS error: %v", err)
|
log.Fatalf("TLS error: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cstate, _ := c.TLSConnectionState()
|
cstate, _ := c.TLSConnectionState()
|
||||||
log.Printf("TLS OK: %s - %s", tlsconst.VersionName(cstate.Version),
|
log.Printf("TLS OK: %s - %s", tlsconst.VersionName(cstate.Version),
|
||||||
tlsconst.CipherSuiteName(cstate.CipherSuite))
|
tlsconst.CipherSuiteName(cstate.CipherSuite))
|
||||||
|
|
||||||
|
c.Close()
|
||||||
|
}
|
||||||
|
|
||||||
log.Printf("")
|
log.Printf("")
|
||||||
c.Close()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("=== Success")
|
log.Printf("=== Success")
|
||||||
|
|||||||
Reference in New Issue
Block a user