Fix existing identd
This commit is contained in:
parent
2e967e8375
commit
9aafffd273
@ -2,26 +2,31 @@ var _ = require("lodash");
|
|||||||
var net = require("net");
|
var net = require("net");
|
||||||
|
|
||||||
var users = {};
|
var users = {};
|
||||||
|
var enabled = false;
|
||||||
|
|
||||||
module.exports.start = function(port) {
|
module.exports.start = function(port) {
|
||||||
port = port || 113;
|
port = port || 113;
|
||||||
log.info("Starting identd server on port", port);
|
log.info("Starting identd server on port", port);
|
||||||
net.createServer(init).listen(port);
|
net.createServer(init).listen(port);
|
||||||
|
enabled = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.hook = function(stream, user) {
|
module.exports.hook = function(stream, user) {
|
||||||
var id = "";
|
|
||||||
var socket = stream.socket || stream;
|
var socket = stream.socket || stream;
|
||||||
socket.on("connect", function() {
|
|
||||||
var ports = _.pick(socket, "localPort", "remotePort");
|
var ports = _.pick(socket, "localPort", "remotePort");
|
||||||
id = _.values(ports).join(", ");
|
var id = _.values(ports).join(", ");
|
||||||
|
|
||||||
users[id] = user;
|
users[id] = user;
|
||||||
});
|
|
||||||
socket.on("close", function() {
|
socket.on("close", function() {
|
||||||
delete users[id];
|
delete users[id];
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.exports.isEnabled = function() {
|
||||||
|
return enabled;
|
||||||
|
};
|
||||||
|
|
||||||
function init(socket) {
|
function init(socket) {
|
||||||
socket.on("data", function(data) {
|
socket.on("data", function(data) {
|
||||||
respond(socket, data);
|
respond(socket, data);
|
||||||
|
@ -9,10 +9,6 @@ module.exports = function(irc, network) {
|
|||||||
text: "Network created, connecting to " + network.host + ":" + network.port + "..."
|
text: "Network created, connecting to " + network.host + ":" + network.port + "..."
|
||||||
}));
|
}));
|
||||||
|
|
||||||
irc.on("raw socket connected", function() {
|
|
||||||
identd.hook(irc.connection.socket, network.username);
|
|
||||||
});
|
|
||||||
|
|
||||||
irc.on("socket connected", function() {
|
irc.on("socket connected", function() {
|
||||||
network.channels[0].pushMessage(client, new Msg({
|
network.channels[0].pushMessage(client, new Msg({
|
||||||
text: "Connected to the network."
|
text: "Connected to the network."
|
||||||
@ -25,6 +21,12 @@ module.exports = function(irc, network) {
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (identd.isEnabled()) {
|
||||||
|
irc.on("socket connected", function() {
|
||||||
|
identd.hook(irc.connection.socket, client.name || network.username);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
irc.on("socket error", function(err) {
|
irc.on("socket error", function(err) {
|
||||||
log.debug("IRC socket error", err);
|
log.debug("IRC socket error", err);
|
||||||
network.channels[0].pushMessage(client, new Msg({
|
network.channels[0].pushMessage(client, new Msg({
|
||||||
|
Loading…
Reference in New Issue
Block a user