Exemplo n.º 1
0
rbl_result=None
ipaddr = None
relay_result = None
avail_result=None
redund_result=None
diag_score=None
revdns_result = None


def run_tests(mx_obj):
    try:
        end_results, rbl_result = run_diag(mx_obj.mx_url, mx_obj.ipaddr)
        p_status, created = MailserverStatus.objects.get_or_create(mailserver=mx)
        if created == False:
            p_status.relay = end_results['relay_result']
            p_status.backupmx = end_results['redund_result']
            p_status.backupmxport = end_results['backupmxport_result']
            p_status.score = get_diag_score(end_results['diag_count'])
            if end_results['revdns_result'] is not "no":
                p_status.revdns = "yes"
            else:
                p_status.revdns = "no"
            p_status.save()
    except:
        end_results = None
        
mx_list = get_all_mailservers()
for mx in mx_list:
    run_tests(mx)
    connection.close()
    mark_checked(mx, 'misc', 'us')
Exemplo n.º 2
0
        else:
            queue_alert('sms', mx_obj, rbl_obj.name, email_wait_time, "blacklist")


def blacklist_check( mx_obj ):
    # turn "1.2.3.4" into "4.3.2.1.sbl-xbl.spamhaus.org"
    # object = mailserver item
    iplist = string.split(mx_obj.ipaddr, ".")
    iplist.reverse()
    ip = string.join(iplist, ".")

    for item in mx_obj.rbl.all():
        dnsbl = ip + "." + item.site_url
        try:
            #Is blacklisted
             socket.gethostbyname( dnsbl )
             mark_blk(mx_obj, item)
        except socket.gaierror:
             unmark_blk(mx_obj, item)

def check_bad_mx(mailservers):
    #answers = dns.resolver.query(str(item.url), 'MX')
    #answers = item.mailserver.all()
    for object in mailservers:
        blacklist_check(object)
        mark_checked(object, 'blacklist', 'us')

if __name__ == "__main__":
    mailservers = get_all_mailservers()
    check_bad_mx(mailservers)