Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
9,651 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
var app = require('appjs') | ||
, http = require('http') | ||
, url = require('url'); | ||
|
||
|
||
app.serveFilesFrom(__dirname + '/content'); | ||
|
||
|
||
var window = app.createWindow({ | ||
width: 800, | ||
height: 480, | ||
resizable: true, | ||
disableSecurity: true, | ||
icons: __dirname + '/content/icons' | ||
}); | ||
|
||
|
||
window.on('create', function(){ | ||
console.log("Window Created"); | ||
window.frame.show(); | ||
window.frame.center(); | ||
window.frame.opacity=0.92; | ||
window.frame.showChrome=1; | ||
}); | ||
|
||
|
||
window.on('ready', function(){ | ||
console.log("Window Ready"); | ||
window.require = require; | ||
window.process = process; | ||
window.module = module; | ||
var document = window.document; | ||
var $ = this.$, | ||
$target = $('input[name=target]'), | ||
$ammo = $('input[name=ammo]'), | ||
$caliber = $('input[name=caliber]'), | ||
$info = $('#info-target'), | ||
$label = $info.find('span'), | ||
$buttons = $('input, button'), | ||
$results = $('#resultsbox'); | ||
$placeholder = $('#placeholder'); | ||
$label.text('Select target and blast!'); | ||
|
||
$('#blaster-form').submit(function(e){ | ||
e.preventDefault(); | ||
$label.text('Blasting!'); | ||
$buttons.attr('disabled', true); | ||
var target = $target.val() || 'http://localhost', | ||
ammo = $ammo.val() || 100, | ||
caliber = $caliber.val() || 100; | ||
console.log(ammo + ' ' + caliber + ' ' + target); | ||
http.globalAgent.maxSockets = caliber; | ||
var options = { | ||
host: url.parse(target).hostname, | ||
port: url.parse(target).port, | ||
path: url.parse(target).path | ||
}; | ||
var Data={}; | ||
var Status=new Array(); | ||
Status.push('<h2>Blasted: ' + target + ' ' + ammo + ' times</h2>'); | ||
var startTime = Date.now(); | ||
|
||
for(var i = 1; i <= ammo; i++) { | ||
blaster(i); | ||
}; | ||
|
||
function blaster(i) { | ||
var req = http.get(options, function(res) { | ||
if (i%100===0) { | ||
Status.push('Request: ' + i + ' STATUS: ' + res.statusCode); | ||
} | ||
if (i == ammo) { | ||
var endTime = Date.now(); | ||
var blastTime = (endTime - startTime)/1000; | ||
Data=JSON.stringify(Status); | ||
Data=eval(Data).join(",") | ||
Data= Data.replace(/,/g,'<p>'); | ||
blastedOut(Data, blastTime); | ||
} | ||
}).on('error', function(e) { | ||
Status.push('Request: ' + i + ' ERROR: ' + e.message); | ||
if (i == ammo) { | ||
var endTime = Date.now(); | ||
var blastTime = (endTime - startTime)/1000; | ||
Data=JSON.stringify(Status); | ||
Data=eval(Data).join(",") | ||
Data= Data.replace(/,/g,'<p>'); | ||
blastedOut(Data, blastTime); | ||
} | ||
}); | ||
}; | ||
}); | ||
|
||
function blastedOut(Data, blastTime){ | ||
$label.text('Blasting lasted: ' + blastTime.toFixed(1)); | ||
$results.html(Data); | ||
$buttons.attr('disabled', false); | ||
}; | ||
|
||
}); |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>blaster</title> | ||
<link rel="stylesheet" href="style.css"> | ||
<script src="js/jquery.js"></script> | ||
</head> | ||
<body> | ||
<div id="container"> | ||
<header> | ||
<h1>blaster</h1> | ||
</header> | ||
<div id="blastingbox"> | ||
<form action="/" method="POST" id="blaster-form"> | ||
<input id="target" name="target" type="text" placeholder="URL"/> | ||
<input id="ammo" name="ammo" type="number" placeholder="ammo"/> | ||
<input id="caliber" name="caliber" type="number" placeholder="caliber"/> | ||
<button type="submit" class="button">blast</button> | ||
</form> | ||
<label id="info-target"> | ||
<span></span></label> | ||
</div> | ||
<div id="resultsbox"> | ||
<p id="placeholder">results will appear here</span> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
Oops, something went wrong.