dos.es.tst 848 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. Denial of service testing
  3. */
  4. const HTTP = tget('TM_HTTP') || "127.0.0.1:8080"
  5. // Check server available
  6. http = new Http
  7. http.get(HTTP + "/index.html")
  8. ttrue(http.status == 200)
  9. http.close()
  10. if (tdepth() >= 3) {
  11. // TODO - TEMP
  12. if (Config.OS != 'windows') {
  13. // Try to crash with DOS attack
  14. for (i in 200) {
  15. let s = new Socket
  16. try {
  17. s.connect(HTTP.address)
  18. } catch (e) {
  19. print("ERROR", i)
  20. print(e)
  21. throw e
  22. }
  23. let written = s.write("Any Text")
  24. ttrue(written == 8)
  25. s.close()
  26. }
  27. }
  28. // Check server still there
  29. http = new Http
  30. http.get(HTTP + "/index.html")
  31. ttrue(http.status == 200)
  32. http.close()
  33. } else {
  34. tskip("Runs at depth 3");
  35. }