scripts/mailtest: fix socket family check.
authorJan-Philip Gehrcke <jgehrcke@googlemail.com>
Tue, 22 Jul 2014 14:14:41 +0000 (16:14 +0200)
committerJan-Philip Gehrcke <jgehrcke@googlemail.com>
Tue, 22 Jul 2014 14:14:41 +0000 (16:14 +0200)
There is no AddressFamily attribute:

Traceback (most recent call last):
  File "/var/docker/scripts/mailtest", line 140, in <module>
    do_tls(smtp,smtp_sslv)
  File "/var/docker/scripts/mailtest", line 44, in do_tls
    if conn.sock.family == socket.AddressFamily.AF_INET:
AttributeError: 'module' object has no attribute 'AddressFamily'

However, there is `socket.AF_INET` etc.

scripts/mailtest

index 416bc2e88d91854cd4869b52a33ab4c3c8581fb5..3c0548c2c9f5eca40361b279ebe2363a76bc8b65 100755 (executable)
@@ -41,7 +41,7 @@ def do_tls(conn, sslv):
             print_warn('WARNING: cannot attempt verification of server certificate:')
             print_warn(' (need Python 3.4+ to attempt verification)')
             # Damn you, openssl. Why don't you support IPv6?
-            if conn.sock.family == socket.AddressFamily.AF_INET:
+            if conn.sock.family == socket.AF_INET:
                 print_warn(' You can verify the certificate manually by running:')
                 print_warn(' echo quit | openssl s_client -CAfile /etc/ssl/certs/ca-certificates.crt \\')
                 print_warn('   -starttls smtp -connect {}:{}'.format(*conn.sock.getpeername()[0:2]))