@@ -5,14 +5,14 @@ const fs = require('fs')
5
5
const net = require ( 'net' )
6
6
const stream = require ( 'stream' )
7
7
const through2 = require ( 'through2' )
8
- const generate = require ( 'nanoid/generate ' )
8
+ const nanoid = require ( 'nanoid' )
9
9
const hex = require ( 'hexer' )
10
10
11
- var hexerIn = hex . Transform ( { prefix : '< ' } )
12
- var hexerOut = hex . Transform ( { prefix : '> ' } )
11
+ const hexerIn = hex . Transform ( { prefix : '< ' } )
12
+ const hexerOut = hex . Transform ( { prefix : '> ' } )
13
13
14
14
module . exports = function ( debug ) {
15
- var self = this
15
+ const self = this
16
16
this . server = net . createServer ( )
17
17
18
18
function listening ( ) {
@@ -40,12 +40,12 @@ module.exports = function (debug) {
40
40
hexerOut . pipe ( self . _output )
41
41
}
42
42
43
- socket . id = generate ( '1234567890abcdefghpsxz' , 7 )
43
+ socket . id = nanoid . customAlphabet ( '1234567890abcdefghpsxz' , 7 )
44
44
socket . setKeepAlive ( ! ! self . _keepalive )
45
45
if ( self . _encoding ) socket . setEncoding ( self . _encoding )
46
46
self . emit ( 'connection' , socket )
47
47
48
- var IPandPort = socket . remoteAddress + ':' + socket . remotePort
48
+ const IPandPort = socket . remoteAddress + ':' + socket . remotePort
49
49
debug ( 'New connection' , socket . id , IPandPort )
50
50
self . _clients [ socket . id ] = socket
51
51
@@ -59,7 +59,7 @@ module.exports = function (debug) {
59
59
} else if ( self . _serveStream ) {
60
60
debug ( 'Serving given stream to the client' , socket . id )
61
61
if ( Buffer . isBuffer ( self . _serveStream ) ) {
62
- var pt = new stream . PassThrough ( )
62
+ const pt = new stream . PassThrough ( )
63
63
pt . end ( self . _serveStream )
64
64
pt . pipe ( socket )
65
65
} else {
@@ -140,7 +140,7 @@ module.exports = function (debug) {
140
140
}
141
141
142
142
function streamDebug ( debug , IPandPort ) {
143
- var self = this
143
+ const self = this
144
144
return through2 ( function ( chunk , enc , cb ) {
145
145
debug ( 'Got data from' , IPandPort , '->' , chunk )
146
146
if ( self . _output ) hexerIn . write ( chunk ) // hex Dump
0 commit comments