fix: ensure commandSocket is set before retrieving ip address of connection (#222)

This commit is contained in:
techmunk
2020-12-09 04:05:50 +10:00
committed by GitHub
parent db49063b0d
commit 4cd88b129c

View File

@@ -14,6 +14,7 @@ class FtpConnection extends EventEmitter {
super();
this.server = server;
this.id = uuid.v4();
this.commandSocket = options.socket;
this.log = options.log.child({id: this.id, ip: this.ip});
this.commands = new Commands(this);
this.transferType = 'binary';
@@ -24,7 +25,6 @@ class FtpConnection extends EventEmitter {
this.connector = new BaseConnector(this);
this.commandSocket = options.socket;
this.commandSocket.on('error', (err) => {
this.log.error(err, 'Client error');
this.server.emit('client-error', {connection: this, context: 'commandSocket', error: err});