@matterbridge/utils 3.5.4-edge-20260211-1ea4e31 → 3.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/network.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export declare const excludedInterfaceNamePattern: RegExp;
1
2
  export declare function getInterfaceDetails(): {
2
3
  interfaceName: string;
3
4
  ipv4Address: string | undefined;
package/dist/network.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import os from 'node:os';
2
2
  import { AnsiLogger, BLUE, CYAN, nf } from 'node-ansi-logger';
3
+ export const excludedInterfaceNamePattern = /(tailscale|wireguard|openvpn|zerotier|hamachi|\bwg\d+\b|\btun\d+\b|\btap\d+\b|\butun\d+\b|docker|podman|\bveth[a-z0-9]*\b|\bbr-[a-z0-9]+\b|cni|kube|flannel|calico|virbr\d*\b|vmware|vmnet\d*\b|virtualbox|vboxnet\d*\b|teredo|isatap)/i;
3
4
  export function getInterfaceDetails() {
4
5
  const result = {
5
6
  interfaceName: '',
@@ -8,9 +9,9 @@ export function getInterfaceDetails() {
8
9
  macAddress: undefined,
9
10
  };
10
11
  for (const [interfaceName, interfaceDetails] of Object.entries(os.networkInterfaces())) {
11
- if (!interfaceName || !interfaceDetails || interfaceDetails.length === 0)
12
+ if (!interfaceName || excludedInterfaceNamePattern.test(interfaceName))
12
13
  continue;
13
- for (const detail of interfaceDetails) {
14
+ for (const detail of interfaceDetails || []) {
14
15
  if (detail.internal)
15
16
  continue;
16
17
  if (!result.interfaceName)
@@ -28,9 +29,9 @@ export function getInterfaceDetails() {
28
29
  }
29
30
  export function getInterfaceName() {
30
31
  for (const [interfaceName, interfaceDetails] of Object.entries(os.networkInterfaces())) {
31
- if (!interfaceName || !interfaceDetails || interfaceDetails.length === 0)
32
+ if (!interfaceName || excludedInterfaceNamePattern.test(interfaceName))
32
33
  continue;
33
- for (const detail of interfaceDetails) {
34
+ for (const detail of interfaceDetails || []) {
34
35
  if (!detail.internal)
35
36
  return interfaceName;
36
37
  }
@@ -38,9 +39,9 @@ export function getInterfaceName() {
38
39
  }
39
40
  export function getIpv4InterfaceAddress() {
40
41
  for (const [interfaceName, interfaceDetails] of Object.entries(os.networkInterfaces())) {
41
- if (!interfaceName || !interfaceDetails || interfaceDetails.length === 0)
42
+ if (!interfaceName || excludedInterfaceNamePattern.test(interfaceName))
42
43
  continue;
43
- for (const detail of interfaceDetails) {
44
+ for (const detail of interfaceDetails || []) {
44
45
  if (detail.family === 'IPv4' && !detail.internal)
45
46
  return detail.address;
46
47
  }
@@ -48,9 +49,9 @@ export function getIpv4InterfaceAddress() {
48
49
  }
49
50
  export function getIpv6InterfaceAddress(scope = false) {
50
51
  for (const [interfaceName, interfaceDetails] of Object.entries(os.networkInterfaces())) {
51
- if (!interfaceName || !interfaceDetails || interfaceDetails.length === 0)
52
+ if (!interfaceName || excludedInterfaceNamePattern.test(interfaceName))
52
53
  continue;
53
- for (const detail of interfaceDetails) {
54
+ for (const detail of interfaceDetails || []) {
54
55
  if (detail.family === 'IPv6' && !detail.internal) {
55
56
  const address = detail.address;
56
57
  if (!scope)
@@ -69,9 +70,9 @@ export function getIpv6InterfaceAddress(scope = false) {
69
70
  }
70
71
  export function getMacAddress() {
71
72
  for (const [interfaceName, interfaceDetails] of Object.entries(os.networkInterfaces())) {
72
- if (!interfaceName || !interfaceDetails || interfaceDetails.length === 0)
73
+ if (!interfaceName || excludedInterfaceNamePattern.test(interfaceName))
73
74
  continue;
74
- for (const detail of interfaceDetails) {
75
+ for (const detail of interfaceDetails || []) {
75
76
  if (!detail.internal)
76
77
  return detail.mac;
77
78
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matterbridge/utils",
3
- "version": "3.5.4-edge-20260211-1ea4e31",
3
+ "version": "3.5.4",
4
4
  "description": "Matterbridge utils library",
5
5
  "author": "https://github.com/Luligu",
6
6
  "homepage": "https://matterbridge.io/",
@@ -65,7 +65,7 @@
65
65
  "@eslint/js": "9.39.2"
66
66
  },
67
67
  "dependencies": {
68
- "@matterbridge/jest-utils": "3.5.4-edge-20260211-1ea4e31",
68
+ "@matterbridge/jest-utils": "3.5.4",
69
69
  "node-ansi-logger": "3.2.0"
70
70
  }
71
71
  }