Skip to content

Commit

Permalink
Hex field display
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Askarov committed Oct 28, 2019
1 parent 8feb904 commit b5741ec
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 10 deletions.
3 changes: 2 additions & 1 deletion lib/helpers/lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ module.exports.safeLog = function(msg, modes) {
// In dangerous mode hex dump is available
if (global.c.dangerous && modes.indexOf('hex') >=0) {
var result = msg.toString('hex');
//return result;
len = result.length;
for (var i = 0; i < len; i += 2) {
if (i) {
Expand Down Expand Up @@ -63,7 +64,7 @@ module.exports.safeLog = function(msg, modes) {
});
}

// Field 55
// Field 55 (what to do?)
if (modes.indexOf('field55') >= 0) {

}
Expand Down
10 changes: 7 additions & 3 deletions lib/iso8583-packet/lib/iso8583Packet.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,17 +286,21 @@ Iso8583Packet.prototype.pretty = function() {
if (this.fields.hasOwnProperty(key)) {
var val = this.fields[key];
var fieldName = this.packager.format[key] && this.packager.format[key].hasOwnProperty('name') ? this.packager.format[key]['name'] : 'Unknown field';
var fieldType = this.packager.format[key] && this.packager.format[key].hasOwnProperty('type') ? this.packager.format[key]['type'] : '';

var title = fieldName + ' [' + key + ']';

if (['2', '19'].indexOf(key) >= 0) {
val = helpers.safeLog(val, ['number']);
} else if (['35'].indexOf(key) >= 0) {
val = helpers.safeLog(val, ['pan']);
} else if (['55'].indexOf(key) >= 0) {
} else if (['ll-bin-char'].indexOf(fieldType) >= 0) {
var strictMode = (['55'].indexOf(key) >= 0) ? ['field55'] : null;

if (typeof val == 'object' && val instanceof Buffer) {
val = helpers.safeLog(val.toString('hex'), ['field55']);
val = helpers.safeLog(val.toString('hex'), strictMode);
} else {
val = helpers.safeLog((Buffer.from(val, 'binary')).toString('hex'), ['field55']);
val = helpers.safeLog((Buffer.from(val, 'binary')).toString('hex'), strictMode);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/iso8583/lib/iso8583.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ var ISO8583 = function(packagerName) {
try {
result = this._unpack(result.restData, fieldIds[i]);
} catch(e) {
console.log(e.message);
console.log('Exception: ' + e.message);
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/iso8583/lib/packer/ll-bin-char.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ exports.pack = function(row, packager) {
row = Buffer.from('' + row);
}

var length = row.length;
var length = row.length;

if (length > packager.length) {
length = packager.length;
Expand Down
2 changes: 1 addition & 1 deletion lib/testSuite/lib/echoServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ function randomCase(v) {
return Math.floor(Math.random() * (v - 0)) == 1;
}

module.exports = echoServer;
module.exports = echoServer;
1 change: 0 additions & 1 deletion lib/testSuite/lib/testClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ testClient.prototype.start = function (c, terminalId) {
var p = parent.getPacket(packets[2]);

this.sourcePacket = p;

this.write(p.getMessage());
this.isWaiting = true;
this.isTrying = false;
Expand Down
3 changes: 1 addition & 2 deletions socketQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ if (c.echoServerPort || c.testClients) var testSuite = require('./lib/testSuite'
if (c.echoServerPort) {
// Run local echo server
var echoServer = new testSuite.echoServer(c, dd).listen(c.echoServerPort);

dd("Echo server is now running on port " + c.echoServerPort + "\n");
dd("Echo server is now running on port " + c.echoServerPort);
}

// Run local clients
Expand Down

0 comments on commit b5741ec

Please sign in to comment.