diff options
Diffstat (limited to 'rp')
-rwxr-xr-x | rp/rpki-rtr/rpki-rtr | 82 | ||||
-rwxr-xr-x | rp/rpki-rtr/rtr-origin | 37 |
2 files changed, 102 insertions, 17 deletions
diff --git a/rp/rpki-rtr/rpki-rtr b/rp/rpki-rtr/rpki-rtr new file mode 100755 index 00000000..73c8836e --- /dev/null +++ b/rp/rpki-rtr/rpki-rtr @@ -0,0 +1,82 @@ +#!/usr/bin/env python + +# $Id$ +# +# Copyright (C) 2014 Dragon Research Labs ("DRL") +# Portions copyright (C) 2009-2013 Internet Systems Consortium ("ISC") +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notices and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND DRL AND ISC DISCLAIM ALL +# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL OR +# ISC 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. + +""" +RPKI-Router protocol implementation. See RFC 6810 et sequalia in fine +RFC and Internet-Draft repositories near you. +""" + +import os +import sys +import time +import logging +import logging.handlers +import argparse + +from rpki.rpki_rtr.server import argparse_setup as argparse_setup_server +from rpki.rpki_rtr.client import argparse_setup as argparse_setup_client +from rpki.rpki_rtr.generator import argparse_setup as argparse_setup_generator + +class Formatter(logging.Formatter): + + converter = time.gmtime + + def format(self, record): + if getattr(record, "connection", None) is None: + record.connection = "" + return super(Formatter, self).format(record) + + def formatException(self, ei): + if args.debug: + return super(Formatter, self).formatException(ei) + else: + return str(ei[1]) + +os.environ["TZ"] = "UTC" +time.tzset() + +argparser = argparse.ArgumentParser(description = __doc__) +argparser.add_argument("--debug", action = "store_true", help = "debugging mode") +argparser.add_argument("--log-level", default = logging.DEBUG, + choices = ("debug", "info", "warning", "error", "critical"), + type = lambda s: int(getattr(logging, s.upper()))) +argparser.add_argument("--log-to", + choices = ("syslog", "stderr")) +subparsers = argparser.add_subparsers(title = "Commands", metavar = "", dest = "mode") +argparse_setup_server(subparsers) +argparse_setup_client(subparsers) +argparse_setup_generator(subparsers) +args = argparser.parse_args() + +fmt = "rpki-rtr/" + args.mode + "%(connection)s[%(process)d] %(message)s" + +if (args.log_to or args.default_log_to) == "stderr": + handler = logging.StreamHandler() + fmt = "%(asctime)s " + fmt +elif os.path.exists("/dev/log"): + handler = logging.handlers.SysLogHandler("/dev/log") +else: + handler = logging.handlers.SysLogHandler() + +handler.setFormatter(Formatter(fmt, "%Y-%m-%dT%H:%M:%SZ")) +logging.root.addHandler(handler) +logging.root.setLevel(args.log_level) + +sys.exit(args.func(args)) diff --git a/rp/rpki-rtr/rtr-origin b/rp/rpki-rtr/rtr-origin index b2b3d1ab..ecfd09cb 100755 --- a/rp/rpki-rtr/rtr-origin +++ b/rp/rpki-rtr/rtr-origin @@ -1,28 +1,31 @@ #!/usr/bin/env python -# Router origin-authentication rpki-router protocol implementation. See -# draft-ietf-sidr-rpki-rtr in fine Internet-Draft repositories near you. -# -# Run the program with the --help argument for usage information, or see -# documentation for the *_main() functions. -# -# # $Id$ # -# Copyright (C) 2009-2013 Internet Systems Consortium ("ISC") -# +# Copyright (C) 2014 Dragon Research Labs ("DRL") +# Portions copyright (C) 2009-2013 Internet Systems Consortium ("ISC") +# # 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 ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC 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 +# copyright notices and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND DRL AND ISC DISCLAIM ALL +# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DRL OR +# ISC 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. +""" +Router origin-authentication rpki-router protocol implementation. See +RFC 6810 et sequalia in fine Internet-Draft repositories near you. + +Run the program with the --help argument for usage information, or see +documentation for the *_main() functions. +""" + import sys import os import struct |