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