covert-sites.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Slitheen - a decoy routing system for censorship resistance
  3. * Copyright (C) 2017 Cecylia Bocovich (cbocovic@uwaterloo.ca)
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, version 3.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. * Additional permission under GNU GPL version 3 section 7
  18. *
  19. * If you modify this Program, or any covered work, by linking or combining
  20. * it with the OpenSSL library (or a modified version of that library),
  21. * containing parts covered by the terms of the OpenSSL Licence and the
  22. * SSLeay license, the licensors of this Program grant you additional
  23. * permission to convey the resulting work. Corresponding Source for a
  24. * non-source form of such a combination shall include the source code
  25. * for the parts of the OpenSSL library used as well as that of the covered
  26. * work.
  27. */
  28. var fs = require('fs');
  29. var page = require('webpage').create();
  30. page.settings.resourceTimeout = 50000;
  31. page.onResourceRequested = function(request, network) {
  32. console.log('Request ' + JSON.stringify(request, undefined, 4));
  33. };
  34. page.onResourceReceived = function(response) {
  35. console.log('Receive ' + JSON.stringify(response, undefined, 4));
  36. };
  37. var stream = fs.open('top100.txt', 'r');
  38. function loadpage(){
  39. //ping port 8888 to mark end of page
  40. var url = "http://localhost:8888";
  41. page.open(url, function (status) {
  42. var line = stream.readLine();
  43. console.log(line);
  44. page.clearMemoryCache();
  45. var t = Date.now();
  46. page.open(line, function(status) {
  47. if(status === "success") {
  48. t = Date.now() - t;
  49. console.log("page load time: "+ t);
  50. fs.write("timing.out", line + ','+ t + '\n', 'a');
  51. } else {
  52. console.log("page load failed");
  53. fs.write("timing.out", line + ','+ '-1\n', 'a');
  54. }
  55. if(!stream.atEnd()){
  56. loadpage();
  57. } else {
  58. phantom.exit();
  59. }
  60. });
  61. });
  62. }
  63. loadpage();