Пример #1
0
def _getLocId(ip):
    int_ip = ipv4ToInit(ip)
    cursor.execute('SELECT locId FROM Blocks WHERE startIpNum <= ? and endIpNum >= ?', (int_ip, int_ip))
    result = cursor.fetchall()

    if result:
        return result[0][0]

    return 0
Пример #2
0
def getAS(ip):
    int_ip = ipv4ToInit(ip)
    cursor.execute('SELECT Org FROM ASN WHERE startIpNum <= ? and endIpNum >= ?', (int_ip, int_ip))
    result = cursor.fetchall()

    if result:
        result = result[0][0]
        assert result.startswith('AS')

        return result

    return u''