dos.es.tst 828 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. if (Config.OS != 'windows') {
  12. // Try to crash with DOS attack
  13. for (i in 200) {
  14. let s = new Socket
  15. try {
  16. s.connect(HTTP.address)
  17. } catch (e) {
  18. print("ERROR", i)
  19. print(e)
  20. throw e
  21. }
  22. let written = s.write("Any Text")
  23. ttrue(written == 8)
  24. s.close()
  25. }
  26. }
  27. // Check server still there
  28. http = new Http
  29. http.get(HTTP + "/index.html")
  30. ttrue(http.status == 200)
  31. http.close()
  32. } else {
  33. tskip("Runs at depth 3");
  34. }