def isIPAddress_test():

    assert_true(domain_utils.isIPAddress('192.168.0.1'))
    assert_true(domain_utils.isIPAddress('255.255.255.255'))
    assert_true(domain_utils.isIPAddress('0.0.0.0'))

    assert_true(domain_utils.isIPAddress('2001:0db8:85a3:0000:0000:8a2e:0370:7334'))
    assert_true(domain_utils.isIPAddress('2001:0db8:85a3:0:0:8a2e:0370:7334'))
    assert_true(domain_utils.isIPAddress('::1'))
    assert_true(domain_utils.isIPAddress('::'))
    assert_true(domain_utils.isIPAddress('::ffff:192.168.0.1'))
    
    assert_false(domain_utils.isIPAddress('www.example.com'))
    assert_false(domain_utils.isIPAddress('192.168.0.1.cn'))
def parse(data):

    csvdata = csv.DictReader(cStringIO.StringIO(data))
    
    domainset = set()
    for row in csvdata:
        url = row['url']
        host = domain_utils.URLtoHost(url)
        if not domain_utils.isIPAddress(host):
            domainset.add(host)

    return domainset
Exemplo n.º 3
0
def parse(blob):

    domainset = set()

    for line in blob.splitlines():
        line = line.strip()
        if line != "":
            host = domain_utils.URLtoHost(line)
            if not domain_utils.isIPAddress(host):
                domainset.add(host)

    return domainset