Debug Server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.5 KiB

  1. #!/bin/env python3
  2. import socket;
  3. import sys;
  4. def init_socket():
  5. # Create a TCP/IP socket
  6. # socket type .AF_INET is the Internet address family for IPv4.
  7. # .SOCK_STREAM is the socket type for TCP.
  8. sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  9. # Bind the socket to the port 8000
  10. server_address = ('localhost', 8000)
  11. sock.bind(server_address)
  12. # Listen for incoming connections
  13. sock.listen(1)
  14. def check_bridge_socket():
  15. evt = None
  16. return evt
  17. def handle_bridge_evt(evt):
  18. """
  19. TODO: Whatever bridge events to handle
  20. """
  21. def check_debug_socket():
  22. dbg_evt = None
  23. return dbg_evt
  24. def handle_debug_evt(dbg_evt):
  25. """ TODO: Do something with the events here."""
  26. def run_loop():
  27. """ """
  28. while True:
  29. # 1. Check the BridgeSocket
  30. evt = check_bridge_socket()
  31. if evt != None:
  32. handle_bridge_evt(evt)
  33. dbg_evt = check_debug_socket()
  34. if dbg_evt != None:
  35. handle_debug_evt(dbg_evt)
  36. def main():
  37. init_socket()
  38. """
  39. 1. TODO: Open Server port that the device connects to.
  40. 2. TODO: Open Server port that an admin connects to, i.e., to test sending packets to
  41. 3. TODO (Optional): We might be able to start a Scapy [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop)
  42. and then add these functions. That way the person in debugging the phone can do live testing.
  43. """
  44. if __name__ == '__main__':
  45. main()