diff options
author | Rob Austein <sra@hactrn.net> | 2014-04-05 22:42:12 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2014-04-05 22:42:12 +0000 |
commit | fe0bf509f528dbdc50c7182f81057c6a4e15e4bd (patch) | |
tree | 07c9a923d4a0ccdfea11c49cd284f6d5757c5eda /rpkid/portal-gui/scripts/rpkigui-query-routes | |
parent | aa28ef54c271fbe4d52860ff8cf13cab19e2207c (diff) |
Source tree reorg, phase 1. Almost everything moved, no file contents changed.
svn path=/branches/tk685/; revision=5757
Diffstat (limited to 'rpkid/portal-gui/scripts/rpkigui-query-routes')
-rwxr-xr-x | rpkid/portal-gui/scripts/rpkigui-query-routes | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/rpkid/portal-gui/scripts/rpkigui-query-routes b/rpkid/portal-gui/scripts/rpkigui-query-routes deleted file mode 100755 index 1f698f23..00000000 --- a/rpkid/portal-gui/scripts/rpkigui-query-routes +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env python - -# Copyright (C) 2013 SPARTA, Inc. a Parsons Company -# -# Permission to use, copy, modify, and distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND SPARTA DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL SPARTA BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -__version__ = '$Id$' - -import sys -import optparse - -from rpki.gui.script_util import setup -setup() - -from rpki.gui.routeview import models as rv -from rpki.resource_set import resource_range_ip - -parser = optparse.OptionParser( - usage='%prog [options] PREFIX', - description='query the rpki web portal database for routes covering a ' - 'prefix specified as an argument, and display the validity and covering ' - 'ROAs for each route', - version=__version__, -) -options, args = parser.parse_args() - -if len(args) == 0: - print 'error: Specify an address/prefix' - sys.exit(1) - -# allow bare IP addresses -if '/' not in args[0]: - args[0] = args[0] + '/32' - -r = resource_range_ip.parse_str(args[0]) - -qs = rv.RouteOrigin.objects.filter( - prefix_min__lte=r.min, - prefix_max__gte=r.max -) - - -def validity_marker(route, roa, roa_prefix): - "Return + if the roa would cause the route to be accepted, or - if not" - # we already know the ROA covers this route because they are returned - # from RouteOrigin.roas, so just check the ASN and max prefix length - return '-' if (roa.asid == 0 or route.asn != roa.asid or - route.prefixlen > roa_prefix.max_length) else '+' - -# xxx.xxx.xxx.xxx/xx-xx is 22 characters -for route in qs: - print route.as_resource_range(), route.asn, route.status - for pfx in route.roa_prefixes: - for roa in pfx.roas.all(): - print validity_marker(route, roa, pfx), pfx.as_roa_prefix(), roa.asid, roa.repo.uri - print |