Skip to content
Browse files

Better performance

  • Loading branch information...
1 parent 10e3dc2 commit 716d768d68b21def28ddd05cd5636e5269546246 @gildean committed Aug 5, 2012
View
21 README.md
@@ -1,14 +1,25 @@
BLASTER
=======
-Node.js cli-app for blasting http-servers with requests.
-
+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).
Usage:
------
-`node blaster http://someurl ammo caliber`
-
-url defaults to localhost, ammo defaults and caliber default to 100.
+cli:
+```
+node blaster http://someurl ammo caliber
+```
+
+gui:
+* 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.
(ammo = number of requests, caliber = max sockets used)
View
100 app.js
@@ -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);
+ };
+
+});
View
BIN content/icons/128.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN content/icons/16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN content/icons/32.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN content/icons/64.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
28 content/index.html
@@ -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>
View
9,404 content/js/jquery.js
9,404 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
103 content/style.css
@@ -0,0 +1,103 @@
+
+* {
+ border: 0;
+ margin: 0;
+ padding: 0;
+ -webkit-font-smoothing: antialiased;
+ font-family: "Ubuntu mono", monospace;
+ text-shadow: -0.1em -0.1em 0 rgba(0,0,0,0.04);
+}
+
+body {
+ width: 100%;
+ font-size: 120%;
+ text-align: center;
+ margin: 0;
+ padding: 0;
+ overflow: hidden;
+ background: transparent;
+}
+
+header {
+ position: fixed;
+ width: 100%;
+ top: 0;
+ left: 0;
+ height: 40px;
+ background: #0e0e0e;
+ box-shadow: 0 2px 5px rgba(0,0,0,0.4);
+ padding: 5px 0;
+ text-align: left;
+}
+
+h1 {
+ font-size: 36px;
+ color: #FFF;
+ text-shadow: -12px 0 0px #FF3380,-24px 0 0px #921D42, -36px 0 0px #4D061C;
+ padding: 0 0 0 8%;
+}
+
+h2 {
+ font-size: 20px;
+ color: #0e0e0e;
+ text-shadow: -2px 0 0px #FF3380
+}
+
+input {
+ margin: 20px 0;
+ width: 75%;
+ padding: 5px;
+ box-shadow: 0 0 10px rgba(0,0,0,0.2);
+}
+
+.button {
+ box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
+ border: 1px solid rgba(0,0,0,0.1);
+ margin: 7%;
+ width: 50%;
+ padding: 5px;
+}
+
+.button:hover {
+ box-shadow: inset 0 0 15px rgba(0,0,0,0.3);
+ cursor: pointer;
+}
+
+p {
+ font-size: .9em;
+ text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
+}
+
+#container {
+ position: relative;
+ margin: 50px 0 0 0;
+ padding: 0;
+}
+
+#blastingbox, #resultsbox {
+ width: 50%;
+ margin: 0;
+ padding: 0;
+}
+
+#blastingbox {
+ position: fixed;
+ left: 0;
+ top: 100px;
+}
+
+#resultsbox {
+float: right;
+height: 430px;
+min-height: 430px;
+overflow-y: auto;
+}
+
+#resultsbox p {
+ margin: 1% 0;
+}
+
+#placeholder {
+ padding: 160px 0;
+ color: rgba(0,0,0,0.2);
+}

0 comments on commit 716d768

Please sign in to comment.
Something went wrong with that request. Please try again.