Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TLS/non-TLS server issues in cluster mode (issue #79) #99

Merged
merged 1 commit into from
May 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix TLS/non-TLS server issues in cluster mode
Valter Pires committed Mar 28, 2019
commit 7b519c7a145a341386c9b97fcebbcbff18d0e879
26 changes: 23 additions & 3 deletions lib/smpp.js
Original file line number Diff line number Diff line change
@@ -171,19 +171,38 @@ function Server(options, listener) {
});
}

util.inherits(Server, tls.Server);
util.inherits(Server, net.Server);

Server.prototype.listen = function() {
function SecureServer(options, listener) {
Server.call(this, options, listener);
}

util.inherits(SecureServer, tls.Server);

SecureServer.prototype.listen = Server.prototype.listen = function() {
var args = [this.tls ? 3550 : 2775];
if (typeof arguments[0] == 'function') {
args[1] = arguments[0];
} else if (arguments.length > 0) {
args = arguments;
}
return tls.Server.prototype.listen.apply(this, args);

var transport = this.tls ? tls : net;
return transport.Server.prototype.listen.apply(this, args);
};

exports.createServer = function(options, listener) {
if (typeof options == 'function') {
listener = options;
options = {};
} else {
options = options || {};
}

if (options.key && options.cert) {
return new SecureServer(options, listener);
}

return new Server(options, listener);
};

@@ -236,6 +255,7 @@ exports.addTLV = function(tag, options) {

exports.Session = Session;
exports.Server = Server;
exports.SecureServer = SecureServer;
exports.PDU = PDU;
for (var key in defs) {
exports[key] = defs[key];