Permalink
Browse files

Add gui

  • Loading branch information...
1 parent 716d768 commit 422ec6be56c76ead6e704c79b36ac616956aa4a2 @gildean committed Aug 7, 2012
Showing with 102 additions and 62 deletions.
  1. +9 −5 README.md
  2. +49 −43 app.js
  3. +8 −2 content/index.html
  4. +36 −12 content/style.css
View
@@ -1,8 +1,11 @@
BLASTER
=======
-Node.js app for blasting http-servers with requests. Cli and gui both included.
-Gui-version made with appjs, so node-gyp is required (for gui only).
+Node.js app for blasting http-servers with requests.
+
+Cli and gui both included.
+
+Gui-version made with [appjs](https://github.com/appjs/appjs) , so node-gyp is required (for gui only).
Usage:
------
@@ -12,14 +15,15 @@ node blaster http://someurl ammo caliber
```
gui:
-* install node-gyp with `npm install node-gyp -g`
-* install appjs with `npm install appjs`
+* Install node-gyp with `npm install node-gyp -g`
+* Install appjs with `npm install appjs`
+
Then run the gui:
```
node --harmony app.js
```
-url defaults to localhost, ammo and caliber default to 100.
+Url defaults to localhost, ammo and caliber default to 100.
(ammo = number of requests, caliber = max sockets used)
View
92 app.js
@@ -16,7 +16,6 @@ var window = app.createWindow({
window.on('create', function(){
- console.log("Window Created");
window.frame.show();
window.frame.center();
window.frame.opacity=0.92;
@@ -25,10 +24,14 @@ window.on('create', function(){
window.on('ready', function(){
- console.log("Window Ready");
window.require = require;
window.process = process;
window.module = module;
+ window.addEventListener('keydown', function(e){
+ if (e.keyIdentifier === 'F12') {
+ window.frame.openDevTools();
+ }
+ });
var document = window.document;
var $ = this.$,
$target = $('input[name=target]'),
@@ -37,62 +40,65 @@ window.on('ready', function(){
$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){
+ $results = $('#resultsbox'),
+ $footer = $('#footer'),
+ $footerlabel = $footer.find('span');
+ $label.text('Select target and blast!');
+ $footerlabel.text('blaster by: ok 2012');
+
+ $('#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();
+ 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);
- };
+ 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 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;
+ $footerlabel.text('Blasting lasted: ' + blastTime.toFixed(1) + ' s');
+ Data=JSON.stringify(Status);
+ Data=eval(Data).join(",")
+ Data= Data.replace(/,/g,'<p>');
+ blastedOut(Data);
+ }
+ }).on('error', function(e) {
+ Status.push('Request: ' + i + ' ERROR: ' + e.message);
+ if (i == ammo) {
+ var endTime = Date.now();
+ var blastTime = (endTime - startTime)/1000;
+ $footerlabel.text('ERROR! ERROR! ERROR!');
+ 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));
+ function blastedOut(Data){
+ $label.text('Ceasefire called');
$results.html(Data);
$buttons.attr('disabled', false);
};
View
@@ -21,8 +21,14 @@
<span></span></label>
</div>
<div id="resultsbox">
- <p id="placeholder">results will appear here</span>
+ <p id="placeholder">results will appear here</p>
+ <p id="results"></p>
</div>
+ <footer>
+ <label id="footer">
+ <span></span>
+ </label>
+ </footer>
</div>
</body>
-</html>
+</html>
View
@@ -15,7 +15,6 @@ body {
margin: 0;
padding: 0;
overflow: hidden;
- background: transparent;
}
header {
@@ -25,7 +24,7 @@ header {
left: 0;
height: 40px;
background: #0e0e0e;
- box-shadow: 0 2px 5px rgba(0,0,0,0.4);
+ box-shadow: 0 3px 5px rgba(0,0,0,0.4);
padding: 5px 0;
text-align: left;
}
@@ -40,7 +39,8 @@ h1 {
h2 {
font-size: 20px;
color: #0e0e0e;
- text-shadow: -2px 0 0px #FF3380
+ text-shadow: -2px 0 0px #FF3380;
+ padding: 10px 0;
}
input {
@@ -51,15 +51,21 @@ input {
}
.button {
- box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
+ color: #fff;
+ background-color: #0e0e0e;
+ box-shadow: inset 0 0 2px #FF3380;
border: 1px solid rgba(0,0,0,0.1);
margin: 7%;
- width: 50%;
- padding: 5px;
+ width: 40%;
+ padding: 10px 0;
+ border-radius: 0.5em;
+ font-size: 1.2em;
+ transition: all 0.3s ease-in-out;
+ -webkit-transition: all 0.3s ease-in-out;
}
.button:hover {
- box-shadow: inset 0 0 15px rgba(0,0,0,0.3);
+ box-shadow: inset 0 0 100px #FF3380;
cursor: pointer;
}
@@ -84,20 +90,38 @@ p {
position: fixed;
left: 0;
top: 100px;
+ padding:0 0 80px;
}
#resultsbox {
-float: right;
-height: 430px;
-min-height: 430px;
-overflow-y: auto;
+ float: right;
+ min-height: 400px;
+ height: 400px;
+ overflow-y: auto;
}
#resultsbox p {
margin: 1% 0;
}
#placeholder {
- padding: 160px 0;
+ padding: 150px 0 120px;
color: rgba(0,0,0,0.2);
}
+
+footer {
+ height: 20px;
+ padding: 5px 0;
+ position: fixed;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+ background: #0e0e0e;
+ text-align: right;
+}
+
+#footer {
+ color: #fff;
+ font-size: 0.9em;
+ padding: 0 10px;
+}

0 comments on commit 422ec6b

Please sign in to comment.