Skip to content

Commit c1269a0

Browse files
authored
Merge pull request #87 from Madriix/master
Update jBNC
2 parents 481f0ab + 0c9984e commit c1269a0

File tree

6 files changed

+26
-6
lines changed

6 files changed

+26
-6
lines changed

bouncer.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,26 @@ process.on('SIGHUP', function () {
6464

6565
if (global.UNCAUGHTEXCEPTION) {
6666
// Prevent BNC from crashing for all other users when an error is caused by a user (with log error and time)
67-
process.on('uncaughtException', (err, origin) => {
67+
/*process.on('uncaughtException', (err, origin) => {
6868
console.error(`${parseInt(Number(new Date()) / 1000)} # Serious problem (${origin}) - this should not happen but the JBNC is still running. ${err.stack}`);
6969
global.LAST_BUG = new Date().toLocaleString();
70+
});*/
71+
72+
process.on('uncaughtException', (err, origin) => {
73+
if (Array.isArray(err)) {
74+
// Do something with the error if it's an array
75+
console.error(`${new Date().toLocaleString()} - Error originating from an array:`, err);
76+
} else {
77+
// Handle other types of errors
78+
console.error(`${new Date().toLocaleString()} - ${parseInt(Number(new Date()) / 1000)} # Serious problem (${origin}) - this should not happen but the JBNC is still running. ${err.stack}`);
79+
}
80+
global.LAST_BUG = new Date().toLocaleString();
7081
});
82+
7183
}
7284

85+
86+
7387
const jBNC = require('./lib/Server');
7488

7589
const server = new jBNC();

lib/ClientConnect.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ class ClientConnect {
8787
this.client.ircv3_extendedjoin = false;
8888
this.client.gone='';
8989
this.client.goneTime='';
90+
this.client.users = -1;
9091

9192
// Default is null, false is reconnecting, and true is disconnected before 005.
9293
this.client.preConnectionLogout = false;
@@ -295,6 +296,7 @@ class ClientConnect {
295296
case '001': // RPL_WELCOME
296297
if (!this.client.authenticated) {
297298
this.client.authenticated = true;
299+
this.client.users=1;
298300
this.client.nick_original = data[2];
299301
if (lines[n].lastIndexOf("@") > 0) {
300302
this.client.ircuser = lines[n].substr(lines[n].lastIndexOf("!") + 1, lines[n].lastIndexOf("@") - lines[n].lastIndexOf("!") - 1);

lib/ClientReconnect.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ class ClientReconnect {
99
}
1010

1111
init(socket) {
12-
let _success = true;
12+
/*let _success = true;
1313
if (socket.connected)
14-
_success = false;
15-
if (_success) {
14+
_success = false;*/
15+
if (true) {
1616
this.connection = this.connections[socket.hash];
1717
this.connection.parents[this.connection.parents.length] = socket;
1818
clearTimeout(this.connection.gone);
@@ -43,6 +43,8 @@ class ClientReconnect {
4343
this.write(socket, ":*jbnc PRIVMSG " + this.connection.nick + " :Attaching you to the network\n");
4444
this.write(socket, this.connection.motd + "\n");
4545
this.write(socket, ":*jbnc 376 " + this.connection.nick + " :End of /MOTD command.\n");
46+
} else {
47+
this.connection.users++;
4648
}
4749

4850
this.write(socket, ":*jbnc PRIVMSG " + this.connection.nick + " :Attaching you to the network\n");

lib/Server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,8 @@ class Server {
706706
}
707707
let i=0;
708708
if (i < this.connections[socket.hash].parents.length) {
709-
if(this.users <= 1)
709+
this.connections[socket.hash].users--;
710+
if(this.connections[socket.hash].users <= 1)
710711
this.connections[socket.hash].parents.splice(i, 1);
711712
if (this.connections[socket.hash].parents.length == 0) {
712713
this.connections[socket.hash].connected = false;

lib/WebAdminPanel.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class WebAdminPanel {
6565
host: this.connections[key].host,
6666
realname: this.connections[key].realname,
6767
goneTime: this.connections[key].goneTime,
68+
users: this.connections[key].users,
6869
channelCount: this.instanceConnections.userChannelCount(key)
6970
};
7071
connectionsData.push(connection);

lib/webadminpanel/dashboard.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ <h5>Last UncaughtException: {{ last_bug }}</h5>
2424
<h2 class="mt-4">Connections (total: {{ count }}) :</h2>
2525
<ul>
2626
<li v-for="connection in connections" :key="connection.id">
27-
<button class="kill btn btn-primary" @click="removeConnection(connection.key, $event)">Kill</button> Nick: {{ connection.nick }} - User: {{ connection.user }} - Host: {{ connection.host }} - Number of channels: {{ connection.channelCount }} - <span v-if="connection.goneTime !== ''" class="p-2 text-light bg-danger">{{ calculateElapsedTime(connection.goneTime) }}</span>
27+
<button class="kill btn btn-primary" @click="removeConnection(connection.key, $event)">Kill</button> Nick: {{ connection.nick }} - User: {{ connection.user }} - Host: {{ connection.host }} - Number of channels: {{ connection.channelCount }} - Users: {{ connection.users }} - <span v-if="connection.goneTime !== ''" class="p-2 text-light bg-danger">{{ calculateElapsedTime(connection.goneTime) }}</span>
2828
</li>
2929
</ul>
3030
</div>

0 commit comments

Comments
 (0)