Im using a python script to open tunnels automaticly and im searching for a way to see if tunnel is being used.
python code:
from sshtunnel import SSHTunnelForwarder
server = ( SSHTunnelForwarder(
'main_server_ip',
ssh_username="username",
ssh_pkey="~/.ssh/id_rsa",
local_bind_address=('0.0.0.0', randomPort),
remote_bind_address=(host_ip, 3389)
) )
I used sshtunnel options :
server.skip_tunnel_checkup = False
server.start()
server.check_tunnels()
print(server.tunnel_is_up, flush=True)
But it only shows if tunnel is open \ active not used, i have looked for a way before posting this but all examples shows only if tunnel is active\ open.
i need an option to see if tunnel is used \ not used so i can close it if it has not being used for X time.
The tunnels are for rdp connections and for me used is if someone is connected through the tunnel to an rdp connection and working on it. if rdp session is closed then it means tunnel is not used.
Thanks