Mirror: Best-effort discovery of the machine's local network using just Node.js dgram sockets
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: Mark `bridge*` interfaces as internal by default to deprioritize them (#15)

* Deprioritize bridge interfaces as internal

* Add changeset

authored by

Phil Pluckthun and committed by
GitHub
18413d6f 134f5f30

+57 -2
+5
.changeset/social-islands-bet.md
··· 1 + --- 2 + 'lan-network': patch 3 + --- 4 + 5 + Deprioritize `bridge*` interfaces as internal networks
+47
src/__tests__/network.test.ts
··· 116 116 ] 117 117 `); 118 118 }); 119 + 120 + it('deprioritizes bridge interfaces', () => { 121 + networkInterfaces.mockReturnValueOnce({ 122 + bridge0: [ 123 + { 124 + address: '100.0.0.11', 125 + netmask: '255.255.255.0', 126 + family: 'IPv4', 127 + mac: '10:00:00:00:00:00', 128 + internal: false, 129 + cidr: '', 130 + }, 131 + ], 132 + en1: [ 133 + { 134 + address: '10.0.0.10', 135 + netmask: '255.255.255.0', 136 + family: 'IPv4', 137 + mac: '10:00:00:00:00:00', 138 + internal: false, 139 + cidr: '', 140 + }, 141 + ], 142 + }); 143 + expect(interfaceAssignments()).toMatchInlineSnapshot(` 144 + [ 145 + { 146 + "address": "10.0.0.10", 147 + "cidr": "", 148 + "family": "IPv4", 149 + "iname": "en1", 150 + "internal": false, 151 + "mac": "10:00:00:00:00:00", 152 + "netmask": "255.255.255.0", 153 + }, 154 + { 155 + "address": "100.0.0.11", 156 + "cidr": "", 157 + "family": "IPv4", 158 + "iname": "bridge0", 159 + "internal": false, 160 + "mac": "10:00:00:00:00:00", 161 + "netmask": "255.255.255.0", 162 + }, 163 + ] 164 + `); 165 + }); 119 166 }); 120 167 121 168 describe(matchAssignment, () => {
+5 -2
src/network.ts
··· 67 67 } else if (mac[0] === 0 && mac[1] === 21 && mac[2] === 93) { 68 68 // NOTE(@kitten): Microsoft virtual interface 69 69 return true; 70 - } else if (assignment.iname.includes('vEthernet')) { 71 - // NOTE(@kitten): Other Windows virtual interfaces 70 + } else if ( 71 + assignment.iname.includes('vEthernet') || 72 + /^bridge\d+$/.test(assignment.iname) 73 + ) { 74 + // NOTE(@kitten): Other Windows virtual interfaces, or Linux bridge interfaces 72 75 return true; 73 76 } else { 74 77 return false;