Beispiel #1
0
 def __init__(self):
     self.listing = Listing()
     self.whitelisting = WhiteListing()
     self.rule = Rule()
     self.asnum = ASNum()
     self.subnet = Subnet()
     self.rir = RIR()
     self.country = Country()
     self.peering = Peering()
Beispiel #2
0
basedir = "/www/blacklist/app/backup"

from blacklist.common.config			import Config
from blacklist.middleware.country		import Country
from blacklist.middleware.rir			import RIR
from blacklist.middleware.asnum			import ASNum
from blacklist.middleware.subnet		import Subnet
from blacklist.middleware.whitelisting	import WhiteListing
from blacklist.middleware.peering		import Peering
from blacklist.middleware.rule			import Rule
from blacklist.middleware.duration		import Duration
from blacklist.middleware.listing		import Listing
from blacklist.middleware.historylisting	import HistoryListing

config = Config()
asnum = ASNum()
country = Country()
rir = RIR()
subnet = Subnet()
whitelisting = WhiteListing()
peering = Peering()
rule = Rule()
duration = Duration()
listing = Listing()
historylisting = HistoryListing()

def log(msg):
	stdout.write(msg)
	stdout.flush()

def get_data(item):
Beispiel #3
0
 def __init__(self):
     self.ipcalc = IPCalc()
     self.asnum = ASNum()
Beispiel #4
0
def providers(request):
	errmsg = ""
	listing_changed = False
	whitelisting_changed = False

	for item in request.GET.keys():
		if item.startswith("id_"):
			(result, asn) = asnum.get(id=item[3:])
			if result:
				if request.GET["bulk_action"] == "blacklist":
					asn.listed = not asn.listed
					listing_changed = True
					if asn.whitelisted:
						whitelisting_changed = True
						asn.whitelisted = False
				elif request.GET["bulk_action"] == "whitelist":
					asn.whitelisted = not asn.whitelisted
					whitelisting_changed = True
					if asn.listed:
						listing_changed = True
						asn.listed = False
				asn.save()

	if listing_changed:
		broker.update_listings()
	if whitelisting_changed:
		broker.update_whitelistings()

	if "q" in request.GET.keys() and len(request.GET["q"]) != 0:
		s = Search(
			model=ASNum(),
			fields={
				"asnum":	"asnum",
				"name":		"name",
				"country":	"country__name",
				"code":		"country__code",
				"rir":		"rir__name",
				"regdate":	"regdate",
				"listed":		"listed",
				"whitelisted":	"whitelisted",
			}
		)
		(result, asnum_data) = s.find(request.GET["q"])
		if not result:
			errmsg = asnum_data
			(result, asnum_data) = asnum.all()
	else:
		(result, asnum_data) = asnum.all()
		if not result: return HttpResponseRedirect("/")

	try: page = int(request.GET.get('page', '1'))
	except: page = 1

	asnum_table = ASNumTable(
		asnum_data,
		order_by=request.GET.get('sort', 'title')
	)

	if request.method == "GET":
		search_form = SearchForm(request.GET)
	else:
		search_form = SearchForm()

	return render_to_response("registry/provider/overview.html", {
		"errmsg":		errmsg,
		"asnum_table":	asnum_table,
		"search_form":	search_form,
	}, context_instance=RequestContext(request))