Small code quality improvements (#2553)
* Small code quality improvements - Fix misleading JSDoc comment in cache.ts - Mitigate timing-based username enumeration in Basic auth - Extract duplicated TOTP configuration into private method - Replace manual peer counter with clients.length in Prometheus metrics - Simplify isValidPasswordHash return expression * reset session.ts this is currently worked on in the dev-oauth branch * reset password.ts no need to change * specify unit for cache function * remove type assertion --------- Co-authored-by: Anghios <Anghios@users.noreply.github.com> Co-authored-by: Bernd Storath <bernd@berndstorath.de>
This commit is contained in:
co-authored by
Anghios
Bernd Storath
parent
d0566a1df9
commit
c70ad1d08b
@@ -6,14 +6,12 @@ export default defineMetricsHandler('prometheus', async ({ event }) => {
|
||||
async function getPrometheusResponse() {
|
||||
const wgInterface = await Database.interfaces.get();
|
||||
const clients = await WireGuard.getAllClients();
|
||||
let wireguardPeerCount = 0;
|
||||
let wireguardEnabledPeersCount = 0;
|
||||
let wireguardConnectedPeersCount = 0;
|
||||
const wireguardSentBytes = [];
|
||||
const wireguardReceivedBytes = [];
|
||||
const wireguardLatestHandshakeSeconds = [];
|
||||
for (const client of clients) {
|
||||
wireguardPeerCount++;
|
||||
if (client.enabled === true) {
|
||||
wireguardEnabledPeersCount++;
|
||||
}
|
||||
@@ -41,7 +39,7 @@ async function getPrometheusResponse() {
|
||||
const returnText = [
|
||||
'# HELP wireguard_configured_peers',
|
||||
'# TYPE wireguard_configured_peers gauge',
|
||||
`wireguard_configured_peers{${id}} ${wireguardPeerCount}`,
|
||||
`wireguard_configured_peers{${id}} ${clients.length}`,
|
||||
'',
|
||||
'# HELP wireguard_enabled_peers',
|
||||
'# TYPE wireguard_enabled_peers gauge',
|
||||
|
||||
Reference in New Issue
Block a user