test.py 851 B

123456789101112131415161718192021222324252627282930
  1. #!/usr/bin/env python3
  2. """LORIS: verify setupSocket connects to a local server (no DoS, just connection)."""
  3. import sys, os, socket, threading, time
  4. sys.path.insert(0, os.path.abspath("test"))
  5. from _lib.local_target import http_target
  6. from core.mods.loris import setupSocket, LORIS
  7. err = []
  8. with http_target() as (port, counter):
  9. target = f"127.0.0.1:{port}"
  10. l = LORIS()
  11. try:
  12. sock, ip = setupSocket(l, "http://" + target)
  13. except Exception as e:
  14. err.append(f"setupSocket raised: {type(e).__name__}: {e}")
  15. sock = None
  16. if sock is None:
  17. err.append("setupSocket returned no socket")
  18. else:
  19. try:
  20. sock.close()
  21. except Exception:
  22. pass
  23. print("setupSocket OK" if not err else "setupSocket FAILED")
  24. for e in err:
  25. print("FAIL:", e)
  26. sys.exit(0 if not err else 1)