def main(argv):
	c = asntryst_read_config()
	d = c['database']
	conn = MySQLdb.connect(host=d['hostname'], user=d['username'], passwd=d['password'], db=d['database'])
	# print_counts(conn)
	print_traceroute_counts(conn)

	conn.close()
Exemple #2
0
def main(argv):
	global verbose
	asn1 = 0
	asn2 = 0
	geo_file = None
	results_file = None
	af_list = [4, 6]

	help_string = 'usage: asntryst-dump.py [--help] [--verbose] [--as1 ASN1] [--as2 ASN2] [--geo file] [--results file]\n'

	try:
		opts, args = getopt.getopt(argv, 'hv46a:b:g:r:', ['help', 'verbose', '4', '6', 'as1=', 'as2=', 'geo=*', 'results=*'])
	except getopt.GetoptError:
		sys.stderr.write(help_string)
		sys.exit(1)
	for opt, arg in opts:
		if opt in ('-h', '--help'):
			sys.stderr.write(help_string)
			sys.exit(0)
		elif opt in ('-v', '--verbose'):
			verbose = 1
		elif opt in ('-4', '--4'):
			af_list = [4]
		elif opt in ('-6', '--6'):
			af_list = [6]
		elif opt in ('-a', '--as1'):
			asn1 = arg
		elif opt in ('-b', '--as2'):
			asn2 = arg
		elif opt in ('-g', '--geo'):
			geo_file = arg
		elif opt in ('-r', '--results'):
			results_file = arg

	if len(args) > 0:
		sys.stderr.write(help_string)
		sys.exit(1)

	c = asntryst_read_config()
	d = c['database']

	conn = MySQLdb.connect(host=d['hostname'], user=d['username'], passwd=d['password'], db=d['database'])
	doit(conn, af_list, int(asn1), int(asn2), geo_file, results_file)
	conn.close()
import argparse
import logging
from multiprocessing import Pool
import MySQLdb
import netaddr
import requests
import sys

from read_config import asntryst_read_config


#
# Project specific settings
#
CONFIG = asntryst_read_config()
DB_HOST = CONFIG["database"]["hostname"]
DB_NAME = CONFIG["database"]["database"]
DB_USER = CONFIG["database"]["username"]
DB_PASS = CONFIG["database"]["password"]

INVALID_ASN = 0xffffffff

# IP versions supported
#   4 ... IP version 4
#   6 ... IP version 6
IP_VERSIONS = [4, 6]
# Data call URL for fetching ASN
RIPESTAT_DC_URL = "http://stat.ripe.net/data/network-info/data.json?resource={}"

log = logging.getLogger(__file__)