Skip to content

Commit 0fca322

Browse files
committed
Fix a bug where XRG would record phantom traffic on the lo0 network interface when VPNs are used. The lo0 interface is now ignored.
1 parent 8d841d3 commit 0fca322

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Data Miners/XRGNetMiner.m

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ - (void)getInterfacesBandwidth {
226226
continue;
227227
strncpy(s, sdl->sdl_data, sdl->sdl_nlen);
228228
s[sdl->sdl_nlen] = '\0';
229-
229+
230230
[self setInterfaceBandwidth:s inBytes:(UInt64)ifm->ifm_data.ifi_ibytes outBytes:(UInt64)ifm->ifm_data.ifi_obytes];
231231
}
232232
}
@@ -240,7 +240,11 @@ - (void)setInterfaceBandwidth:(char *)interface_name inBytes:(UInt64)in_bytes ou
240240
zeroDelta = YES;
241241
}
242242

243-
243+
if (strncmp(interface_name, "lo0", 32) == 0) {
244+
// Don't record the loopback interface.
245+
return;
246+
}
247+
244248
if (_numInterfaces == 0) {
245249
_interfaceStats = (network_interface_stats *)malloc(sizeof(network_interface_stats));
246250

@@ -258,9 +262,7 @@ - (void)setInterfaceBandwidth:(char *)interface_name inBytes:(UInt64)in_bytes ou
258262
_interfaceStats[0].if_out.bsd_bytes = out_bytes;
259263
_interfaceStats[0].if_out.bsd_bytes_prev = 0;
260264

261-
if (strcmp(interface_name, "lo0") != 0)
262-
[networkInterfaces addObject:@(interface_name)];
263-
265+
[networkInterfaces addObject:@(interface_name)];
264266
_numInterfaces++;
265267
}
266268
else {
@@ -354,9 +356,7 @@ - (void)setInterfaceBandwidth:(char *)interface_name inBytes:(UInt64)in_bytes ou
354356
_interfaceStats[_numInterfaces].if_out.bsd_bytes = out_bytes;
355357
_interfaceStats[_numInterfaces].if_out.bsd_bytes_prev = 0;
356358

357-
if (strcmp(interface_name, "lo0") != 0)
358-
[networkInterfaces addObject:@(interface_name)];
359-
359+
[networkInterfaces addObject:@(interface_name)];
360360
_numInterfaces++;
361361
}
362362
}

0 commit comments

Comments
 (0)