2025-01-31 12:06:42 +01:00
|
|
|
#!/usr/bin/env python3.7
|
2025-05-09 14:19:29 +02:00
|
|
|
import asyncio,sys,asyncssh
|
|
|
|
|
async def handle_client(process):
|
|
|
|
|
A=process;E,F,C,D=A.term_size;A.stdout.write(f"Terminal type: {A.term_type}, size: {E}x{F}")
|
|
|
|
|
if C and D:A.stdout.write(f" ({C}x{D} pixels)")
|
|
|
|
|
A.stdout.write('\nTry resizing your window!\n')
|
|
|
|
|
while not A.stdin.at_eof():
|
|
|
|
|
try:await A.stdin.read()
|
|
|
|
|
except asyncssh.TerminalSizeChanged as B:
|
|
|
|
|
A.stdout.write(f"New window size: {B.width}x{B.height}")
|
|
|
|
|
if B.pixwidth and B.pixheight:A.stdout.write(f" ({B.pixwidth}x{B.pixheight} pixels)")
|
|
|
|
|
A.stdout.write('\n')
|
|
|
|
|
async def start_server():await asyncssh.listen('',2230,server_host_keys=['ssh_host_key'],process_factory=handle_client)
|
|
|
|
|
loop=asyncio.new_event_loop()
|
|
|
|
|
try:loop.run_until_complete(start_server())
|
|
|
|
|
except(OSError,asyncssh.Error)as exc:sys.exit('Error starting server: '+str(exc))
|
|
|
|
|
loop.run_forever()
|