Skip to content

Commit

Permalink
Filter out not used intrefaces: #37
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Sep 18, 2024
1 parent 66c5860 commit f5d6bee
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
28 changes: 27 additions & 1 deletion src/lib/fritzbox.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,32 @@
import axios from 'axios';
import crypto from 'node:crypto';

const KNOWN_INTERFACES: Record<string, boolean> = {
':acc0': true, // 27,2 MB
':acc0.4': true, // 4,5 KB
'l2sd0.2': true, // 76,7 KB
l2sm0: false, // 0 Bytes
acc0: true, // 23,1 KB
'acc0.4': false, // 0 Bytes
eth0: true, // 182 KB
eth1: true, // 0 Bytes
eth2: true, // 186 KB
eth3: true, // 0 Bytes
eth_udma0: true, // 137 KB
lan: true, // not tested
ppptty: false, // 0 Bytes
traceDH0: true, // 3,5 MB
traceDH2: true, // 30,7 KB
traceDL0: true, // 264 KB
traceDL2: true, // 15,5 KB
traceN0: true, // 766 KB
traceV0: true, // 382 KB
traceV1: true, // 37,8 KB
vlan_master0: true, // 241 KB
wifi0: true, // 0 KB
wifi1: true, // 0 KB
};

export async function getFritzBoxInterfaces(
ip: string,
login?: string,
Expand Down Expand Up @@ -51,7 +77,7 @@ export async function getFritzBoxInterfaces(
i = text.indexOf('<th>');
}

return result;
return result.filter(e => KNOWN_INTERFACES[e.value] === undefined || KNOWN_INTERFACES[e.value]);
}

return null;
Expand Down
2 changes: 1 addition & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as utils from '@iobroker/adapter-core';
import fs from 'node:fs';
import axios, {AxiosResponse} from 'axios';
import axios, { type AxiosResponse } from 'axios';
import path from 'node:path';
import crypto from 'node:crypto';

Expand Down

0 comments on commit f5d6bee

Please sign in to comment.