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.

54 lines
1.3 KiB

  1. #!/bin/env python3
  2. import socket;
  3. import sys;
  4. def init_socket():
  5. # Create a TCP/IP socket
  6. sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  7. # Bind the socket to the port
  8. server_address = ('localhost', 8000)
  9. sock.bind(server_address)
  10. # Listen for incoming connections
  11. sock.listen(1)
  12. def check_bridge_socket():
  13. evt = None
  14. return evt
  15. def handle_bridge_evt(evt):
  16. """
  17. TODO: Whatever bridge events to handle
  18. """
  19. def check_debug_socket():
  20. dbg_evt = None
  21. return dbg_evt
  22. def handle_debug_evt(dbg_evt):
  23. """ TODO: Do something with the events here."""
  24. def run_loop():
  25. """ """
  26. while True:
  27. # 1. Check the BridgeSocket
  28. evt = check_bridge_socket()
  29. if evt != None:
  30. handle_bridge_evt(evt)
  31. dbg_evt = check_debug_socket()
  32. if dbg_evt != None:
  33. handle_debug_evt(dbg_evt)
  34. def main():
  35. """
  36. 1. TODO: Open Server port that the device connects to.
  37. 2. TODO: Open Server port that an admin connects to, i.e., to test sending packets to
  38. 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)
  39. and then add these functions. That way the person in debugging the phone can do live testing.
  40. """
  41. if __name__ == '__main__':
  42. main()