Skip to content

Commit e58db0a

Browse files
authored
Merge pull request #82 from Madriix/master
Optimization of the 'gone' and 'readme'
2 parents 0a19ac2 + 82da1d9 commit e58db0a

File tree

6 files changed

+21
-5
lines changed

6 files changed

+21
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ To use it, simply install `npm install express express-session` and add the foll
176176
"WebAdminPanelPassword":"<password>",
177177
```
178178

179-
Then launch the web page in the browser at `http://127.0.0.1:8889`
179+
Then launch the web page in the browser at `http://127.0.0.1:8889`. The login is `bouncerAdmin` and the password is `WebAdminPanelPassword`.
180180

181181
The web page is designed to be used with a proxy from nginx or httpd, by creating a subdomain like https://j-bnc.domain.com and configuring the proxy:
182182

lib/ClientConnect.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ class ClientConnect {
8484
this.client.messagetags = false;
8585
this.client.ircv3Monitor = false;
8686
this.client.ircv3_extendedjoin = false;
87+
this.client.gone='';
88+
this.client.goneTime='';
8789

8890
// Default is null, false is reconnecting, and true is disconnected before 005.
8991
this.client.preConnectionLogout = false;
@@ -770,7 +772,8 @@ class ClientConnect {
770772
if (data[0] == "ERROR") {
771773
if (this.client.gone) {
772774
clearTimeout(this.client.gone);
773-
this.client.gone = null;
775+
this.client.gone = '';
776+
this.client.goneTime = '';
774777
}
775778
}
776779
if (lines[n].length > 1) {

lib/ClientReconnect.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ class ClientReconnect {
1616
this.connection = this.connections[socket.hash];
1717
this.connection.parents[this.connection.parents.length] = socket;
1818
clearTimeout(this.connection.gone);
19+
this.connection.gone='';
20+
this.connection.goneTime='';
1921
socket.connected = true;
2022
let newdevice = false;
2123
if (!this.connection.buffers[socket.clientbuffer]) {

lib/Server.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,7 @@ class Server {
712712
this.connections[socket.hash].write(`AWAY :away-${Math.floor(Date.now() / 1000)}\n`);
713713
if (global.BOUNCER_TIMEOUT != 0 && global.BOUNCER_TIMEOUT != null) {
714714
this.connections[socket.hash].gone = setTimeout(() => { try { this.connections[socket.hash].write("QUIT :jbnc gateway\n"); this.connections[socket.hash].end(); } catch (e) { } delete this.connections[socket.hash]; }, global.BOUNCER_TIMEOUT * 1000, socket.hash);
715+
this.connections[socket.hash].goneTime = Math.floor(Date.now() / 1000);
715716
}
716717
}
717718
}

lib/WebAdminPanel.js

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

lib/webadminpanel/dashboard.html

Lines changed: 12 additions & 3 deletions
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-
Key: {{ connection.key }} - Nick: {{ connection.nick }} - User: {{ connection.user }} - Host: {{ connection.host }} - Number of channels: {{ connection.channelCount }} - <button class="kill btn btn-primary" @click="removeConnection(connection.key, $event)">Kill</button>
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>
2828
</li>
2929
</ul>
3030
</div>
@@ -77,7 +77,6 @@ <h2 class="mt-4">Connections (total: {{ count }}) :</h2>
7777
})
7878
.then((data) => {
7979
if (data == "disconnected") {
80-
event.target.innerText="disconnected !";
8180
const index = this.connections.findIndex(connection => connection.key === key);
8281
if (index !== -1) {
8382
this.connections.splice(index, 1);
@@ -90,6 +89,17 @@ <h2 class="mt-4">Connections (total: {{ count }}) :</h2>
9089
.catch(function(error) {
9190
console.error("Error sending request:", error);
9291
});
92+
},
93+
calculateElapsedTime(goneTime) {
94+
const currentTime = Math.floor(Date.now() / 1000);
95+
const elapsedSeconds = currentTime - goneTime;
96+
97+
if (elapsedSeconds < 60) {
98+
return 'Gone since ' + elapsedSeconds + ' seconds';
99+
} else {
100+
const elapsedMinutes = Math.floor(elapsedSeconds / 60);
101+
return 'Gone since ' + elapsedMinutes + ' minutes';
102+
}
93103
}
94104
},
95105
mounted() {
@@ -99,7 +109,6 @@ <h2 class="mt-4">Connections (total: {{ count }}) :</h2>
99109
}, 5000);
100110
}
101111
});
102-
103112
</script>
104113
</body>
105114
</html>

0 commit comments

Comments
 (0)