forked from public/pyceo
Update check_email to handle hosts without an A record (either AAAA only or MX only)
This commit is contained in:
parent
466af409b4
commit
df5f61ffd0
|
@ -12,7 +12,7 @@ must also be moved into this module.
|
||||||
import os, re, subprocess, ldap, socket
|
import os, re, subprocess, ldap, socket
|
||||||
from ceo import conf, ldapi, terms, remote, ceo_pb2
|
from ceo import conf, ldapi, terms, remote, ceo_pb2
|
||||||
from ceo.excep import InvalidArgument
|
from ceo.excep import InvalidArgument
|
||||||
|
import dns.resolver
|
||||||
|
|
||||||
### Configuration ###
|
### Configuration ###
|
||||||
|
|
||||||
|
@ -179,11 +179,16 @@ def check_email(email):
|
||||||
if c in ('"', "'", ',', '|', '$', '/', '#', ':'):
|
if c in ('"', "'", ',', '|', '$', '/', '#', ':'):
|
||||||
return 'Invalid character in address: %s' % c
|
return 'Invalid character in address: %s' % c
|
||||||
|
|
||||||
|
# Start by searching for host record
|
||||||
host = match.group(1)
|
host = match.group(1)
|
||||||
try:
|
try:
|
||||||
ip = socket.gethostbyname(host)
|
ip = socket.getaddrinfo(host, None)
|
||||||
except:
|
except:
|
||||||
return 'Invalid host: %s' % host
|
# Check for MX record
|
||||||
|
try:
|
||||||
|
dns.resolver.query(host, 'MX')
|
||||||
|
except:
|
||||||
|
return 'Invalid host: %s' % host
|
||||||
|
|
||||||
|
|
||||||
def current_email(username):
|
def current_email(username):
|
||||||
|
|
Loading…
Reference in New Issue