Socket
Socket
Sign inDemoInstall

rai

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.10 to 0.1.11

30

lib/mockup.js

@@ -0,1 +1,3 @@

"use strict";
var net = require("net"),

@@ -22,3 +24,3 @@ crypto = require("crypto"),

* <p>Runs a batch of commands against a server</p>
*
*
* <pre>

@@ -30,5 +32,5 @@ * var cmds = ["EHLO FOOBAR", "STARTTLS", "QUIT"];

* </pre>
*
*
* @memberOf mockup
* @param {Number} port Port number
* @param {Number} port Port number
* @param {String} host Hostname to connect to

@@ -41,4 +43,4 @@ * @param {Array} commands Command list to be sent to server

function runClientMockup(port, host, commands, callback, debug){
host = host || "localhost";
port = port || 25;
host = host || "localhost";
port = port || 25;
commands = Array.isArray(commands) ? commands : [];

@@ -51,8 +53,10 @@

socket.on("data", function(chunk){
if(ignore_data)return;
if(ignore_data){
return;
}
if(debug){
console.log("S: "+chunk.toString("utf-8").trim());
}
if(!commands.length){

@@ -68,3 +72,3 @@ socket.end();

}
if(["STARTTLS", "STLS"].indexOf((command || "").trim().toUpperCase())>=0){

@@ -77,7 +81,7 @@ ignore_data = true;

pair = tlslib.createSecurePair(sslcontext, false);
pair.encrypted.pipe(socket);
socket.pipe(pair.encrypted);
pair.fd = socket.fd;
pair.on("secure", function(){

@@ -97,3 +101,3 @@ if(debug){

}
if(!commands.length){

@@ -125,3 +129,3 @@ pair.cleartext.end();

});
}

@@ -0,5 +1,6 @@

"use strict";
/**
* @fileOverview This is the main file for the RAI library to create text based servers
* @author <a href="mailto:andris@node.ee">Andris Reinman</a>
* @version 0.1.3
*/

@@ -12,4 +13,4 @@

tlslib = require("tls"),
crypto = require("crypto"),
fs = require("fs");
fs = require("fs"),
SlowBuffer = require("buffer").SlowBuffer;

@@ -229,3 +230,3 @@ // Default credentials for starting TLS server

var buffer;
if(data instanceof Buffer || (typeof SlowBuffer != "undefined" && data instanceof SlowBuffer)){
if(data instanceof Buffer || data instanceof SlowBuffer){
buffer = new Buffer(data.length+2);

@@ -435,3 +436,5 @@ buffer[buffer.length-2] = 0xD;

RAISocket.prototype._destroy = function(){
if(this._destroyed)return;
if(this._destroyed){
return;
}
this._destroyed = true;

@@ -488,4 +491,4 @@

*/
RAISocket.prototype._onClose = function(hadError){
RAISocket.prototype._onClose = function(/* hadError */){
this._destroy();
};

@@ -0,1 +1,3 @@

"use strict";
// SOURCE: https://gist.github.com/848444

@@ -27,3 +29,3 @@

* <p>Upgrades a socket to a secure TLS connection</p>
*
*
* @memberOf starttls

@@ -36,3 +38,3 @@ * @param {Object} socket Plaintext socket to be upgraded

var sslcontext, pair, cleartext;
socket.removeAllListeners("data");

@@ -61,20 +63,16 @@ sslcontext = require('crypto').createCredentials(options);

function forwardEvents(events, emitterSource, emitterDestination) {
var map = [], name, handler;
for(var i = 0, len = events.length; i < len; i++) {
name = events[i];
var map = [], handler;
handler = forwardEvent.bind(emitterDestination, name);
events.forEach(function(name){
handler = function(){
this.emit.apply(this, arguments);
}.bind(emitterDestination, name);
map.push(name);
emitterSource.on(name, handler);
}
});
return map;
}
function forwardEvent() {
this.emit.apply(this, arguments);
}
function removeEvents(map, emitterSource) {

@@ -91,5 +89,5 @@ for(var i = 0, len = map.length; i < len; i++){

pair.fd = socket.fd;
var cleartext = pair.cleartext;
cleartext.socket = socket;

@@ -106,3 +104,3 @@ cleartext.encrypted = pair.encrypted;

var map = forwardEvents(["timeout", "end", "close", "drain", "error"], socket, cleartext);
function onclose() {

@@ -109,0 +107,0 @@ socket.removeListener('error', onerror);

{
"name": "rai",
"description": "Request-Answer-Interface for generating text based command servers (SMTP, POP etc)",
"version": "0.1.10",
"version": "0.1.11",
"author" : "Andris Reinman",

@@ -6,0 +6,0 @@ "maintainers":[

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc