diff options
author | Rob Austein <sra@hactrn.net> | 2017-04-15 17:53:23 -0400 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2017-04-15 17:53:23 -0400 |
commit | 5357c6d04432c25945563bd71e74ebecb8290276 (patch) | |
tree | 75484bd071f81c9c6606779bb1a353567ab82e3b | |
parent | 3e9a6bb6452cbe402291a8bc98bc42c7163d194e (diff) |
Add console log support to muxd.
-rwxr-xr-x | cryptech_muxd | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/cryptech_muxd b/cryptech_muxd index dc20b62..c1cdf22 100755 --- a/cryptech_muxd +++ b/cryptech_muxd @@ -217,9 +217,10 @@ class CTYIOStream(SerialIOStream): Tornado IOStream for a serial console channel. """ - def __init__(self, device): + def __init__(self, device, console_log = None): super(CTYIOStream, self).__init__(device) self.attached_cty = None + self.console_log = console_log @tornado.gen.coroutine def cty_output_loop(self): @@ -232,6 +233,11 @@ class CTYIOStream(SerialIOStream): self.attached_cty.close() return try: + if self.console_log is not None: + self.console_log.write(buffer) + except: + pass + try: if self.attached_cty is not None: yield self.attached_cty.write(buffer) except tornado.iostream.StreamClosedError: @@ -359,6 +365,10 @@ def main(): parser.add_argument("-l", "--log-file", help = "log to file instead of stderr") + parser.add_argument("-L", "--console-log", + type = argparse.FileType("w"), + help = "log console output to file") + parser.add_argument("-p", "--probe", nargs = "*", metavar = "DEVICE", @@ -409,7 +419,7 @@ def main(): if args.cty_device is None: logger.warn("No CTY device found") else: - cty_stream = CTYIOStream(device = args.cty_device) + cty_stream = CTYIOStream(device = args.cty_device, console_log = args.console_log) cty_server = CTYServer(cty_stream, args.cty_socket) futures.append(cty_stream.cty_output_loop()) |