DbgMuxConnHandler: implement DbgMuxConnInteractiveTerminal

fixeria/threads
Vadim Yanitskiy 5 months ago
parent c58e7e3f07
commit 91abeb7220
  1. 28
      handlers.py

@ -22,6 +22,7 @@ import socket
import queue
import enum
import abc
import sys
from typing import Any, Optional
from construct import Container
@ -123,6 +124,33 @@ class DbgMuxConnHandler(DbgMuxFrameHandler):
''' Called on connection termination '''
class DbgMuxConnInteractiveTerminal(DbgMuxConnHandler):
def __init__(self, *args, **kw):
self.attached: bool = False
super().__init__(*args)
def attach(self):
self.attached = True
while True:
try:
line = input()
if self.conn_state == ConnState.Established:
self.send_data(bytes(line, 'ascii'))
except (KeyboardInterrupt, EOFError) as e:
break
self.attached = False
def _handle_data(self, data: bytes) -> None:
if self.attached:
sys.stdout.write(data.decode('ascii'))
def _handle_establish(self) -> None:
pass
def _handle_terminate(self) -> None:
pass
class DbgMuxConnUdpBridge(DbgMuxConnHandler):
DGRAM_MAX_LEN: int = 1024

Loading…
Cancel
Save