Comparing version 0.1.5 to 0.1.6
@@ -9,16 +9,20 @@ var net = require('net'); | ||
constructor(consumer, options) { | ||
var buf = Buffer.concat([]); | ||
var id = utils.randomAscii(12); | ||
super(); | ||
this.consumer = consumer; | ||
this.opts = opts; | ||
if(options.tls) { | ||
var srv = tls; | ||
this.srv = tls; | ||
} else { | ||
var srv = net; | ||
this.srv = net; | ||
} | ||
}) | ||
this.client = srv.connect(options, () => { | ||
connect() { | ||
var buf = Buffer.concat([]); | ||
this.client = this.srv.connect(this.opts, () => { | ||
console.log('consumer:'+util.inspect(consumer)); | ||
this.trunk.socket = this.client; | ||
consumer.connect(); | ||
this.consumer.connect(); | ||
}) | ||
@@ -29,3 +33,3 @@ | ||
data = Buffer.concat([buf, data], buf.length + data.length); | ||
var leftover = await consumer.read({data, trunk: this.trunk, options}); | ||
var leftover = await this.consumer.read({data, trunk: this.trunk, options: this.opts}); | ||
@@ -32,0 +36,0 @@ if(leftover && leftover.length) { |
class Message { | ||
constructor() { | ||
constructor(data) { | ||
console.log('ORIG CONSTRUCTOR'); | ||
this.trunk = data.trunk; | ||
} | ||
@@ -4,0 +6,0 @@ } |
@@ -20,5 +20,4 @@ var path = require('path'); | ||
var buf = Buffer.concat([]); | ||
var accept = {socket, options}; | ||
socks.push(socket); | ||
var trunk = await consumer.acceptChain(accept); | ||
var trunk = await consumer.acceptChain({socket, options}); | ||
@@ -28,5 +27,4 @@ socket.on('data', async (data) => { | ||
console.log('SOCKET data:'+data.length+', buf:' + Buffer.byteLength(buf)); | ||
// data = buf + data.toString(); | ||
data = Buffer.concat([buf, data], buf.length + data.length); | ||
var leftover = await trunk.read({data, trunk, options}) | ||
var leftover = await consumer.read({data, trunk, options}) | ||
@@ -33,0 +31,0 @@ if(leftover && leftover.length) { |
@@ -0,4 +1,7 @@ | ||
var Protocol = require('./protocol'); | ||
class Trunk { | ||
constructor(opts) { | ||
this.options = opts; | ||
this.protocol = new Protocol(); | ||
} | ||
@@ -27,4 +30,12 @@ | ||
} | ||
send(msg) { | ||
this.socket.write(this.protocol.createMessage(msg.headers, msg.content)) | ||
} | ||
reply(headers, content) { | ||
this.socket.write(this.protocol.createMessage(headers, content)) | ||
} | ||
} | ||
module.exports = Trunk; |
@@ -42,2 +42,4 @@ var util = require('util'); | ||
incoming({id, msg, trunk}) { | ||
console.log('INCOMING:',id, typeof msg.reply); | ||
if(id) { | ||
@@ -47,5 +49,7 @@ var trans = this.req.get(id); | ||
if(trans) { | ||
console.log('TRNS'); | ||
var entry = trans.table.get(id); | ||
if(entry) { | ||
console.log('ENTRY'); | ||
entry.counter--; | ||
@@ -52,0 +56,0 @@ entry.resp.push(msg); |
@@ -59,3 +59,3 @@ { | ||
"optionalDependencies": {}, | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"directories": { | ||
@@ -62,0 +62,0 @@ "lib": "lib" |
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
53902
651
5