aboutsummaryrefslogtreecommitdiff
path: root/rtr-origin
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2009-10-02 16:49:58 +0000
committerRob Austein <sra@hactrn.net>2009-10-02 16:49:58 +0000
commit8978bf83163b0fab467e5c176abc63edc067dc63 (patch)
tree455e558b4877d2da0a7f42d5773a827dea0d14b9 /rtr-origin
parent734ee3846a3131aeab3c65dcf5870d2c9afce17f (diff)
Clean up client_main(), log both outbound and incoming PDUs in client
mode. svn path=/rtr-origin/rtr-origin.py; revision=2808
Diffstat (limited to 'rtr-origin')
-rw-r--r--rtr-origin/rtr-origin.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/rtr-origin/rtr-origin.py b/rtr-origin/rtr-origin.py
index 9c3ed41f..8e0a54f4 100644
--- a/rtr-origin/rtr-origin.py
+++ b/rtr-origin/rtr-origin.py
@@ -864,6 +864,13 @@ class client_channel(pdu_channel):
"""
pdu.consume(self)
+ def push_pdu(self, pdu):
+ """
+ Log outbound PDU then write it to stream.
+ """
+ log(pdu)
+ pdu_channel.push_pdu(self, pdu)
+
def cleanup(self):
"""
Force clean up this client's child process. If everything goes
@@ -1067,27 +1074,22 @@ def client_main(argv):
Main program for client mode. This is just test code.
"""
log("[Startup]")
- if not argv or (argv[0] == "loopback" and len(argv) == 1):
- mode = client_channel.loopback
- args = ()
- elif argv[0] == "ssh" and len(argv) == 3:
- mode = client_channel.ssh
- args = argv[1:]
- elif argv[0] == "tcp" and len(argv) == 3:
- mode = client_channel.tcp
- args = argv[1:]
- else:
- raise RuntimeError, "Unexpected arguments: %r" % (argv,)
client = None
try:
- client = mode(*args)
+ if not argv or (argv[0] == "loopback" and len(argv) == 1):
+ client = client_channel.loopback()
+ elif argv[0] == "ssh" and len(argv) == 3:
+ client = client_channel.ssh(*argv[1:])
+ elif argv[0] == "tcp" and len(argv) == 3:
+ client = client_channel.tcp(*argv[1:])
+ else:
+ raise RuntimeError, "Unexpected arguments: %r" % (argv,)
client.push_pdu(reset_query())
client.timer = client_timer(client, rpki.sundial.timedelta(minutes = 10))
rpki.async.event_loop()
- except:
+ finally:
if client is not None:
client.cleanup()
- raise
def log(msg):
rpki.log.warn(str(msg))