DbgMuxConnHandler: implement DbgMuxConnInteractiveTerminal
This commit is contained in:
parent
c58e7e3f07
commit
91abeb7220
28
handlers.py
28
handlers.py
|
@ -22,6 +22,7 @@ import socket
|
||||||
import queue
|
import queue
|
||||||
import enum
|
import enum
|
||||||
import abc
|
import abc
|
||||||
|
import sys
|
||||||
|
|
||||||
from typing import Any, Optional
|
from typing import Any, Optional
|
||||||
from construct import Container
|
from construct import Container
|
||||||
|
@ -123,6 +124,33 @@ class DbgMuxConnHandler(DbgMuxFrameHandler):
|
||||||
''' Called on connection termination '''
|
''' 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):
|
class DbgMuxConnUdpBridge(DbgMuxConnHandler):
|
||||||
DGRAM_MAX_LEN: int = 1024
|
DGRAM_MAX_LEN: int = 1024
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue