itwillsync 1.5.1 → 1.5.2

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/index.js CHANGED
@@ -3835,17 +3835,40 @@ async function getTailscaleStatus() {
3835
3835
  }
3836
3836
 
3837
3837
  // src/network.ts
3838
+ var VIRTUAL_INTERFACE_PREFIXES = [
3839
+ "utun",
3840
+ "tun",
3841
+ "tap",
3842
+ "wg",
3843
+ // VPN/tunnel
3844
+ "tailscale",
3845
+ // Tailscale
3846
+ "docker",
3847
+ "br-",
3848
+ "veth",
3849
+ // Docker
3850
+ "virbr",
3851
+ "vboxnet",
3852
+ "vmnet"
3853
+ // VM
3854
+ ];
3855
+ function isVirtualInterface(name) {
3856
+ return VIRTUAL_INTERFACE_PREFIXES.some((prefix) => name.startsWith(prefix));
3857
+ }
3838
3858
  function getLocalIP() {
3839
3859
  const interfaces = networkInterfaces();
3840
- for (const addresses of Object.values(interfaces)) {
3860
+ let fallback = null;
3861
+ for (const [name, addresses] of Object.entries(interfaces)) {
3841
3862
  if (!addresses) continue;
3842
3863
  for (const addr of addresses) {
3843
- if (addr.family === "IPv4" && !addr.internal) {
3864
+ if (addr.family !== "IPv4" || addr.internal) continue;
3865
+ if (!isVirtualInterface(name)) {
3844
3866
  return addr.address;
3845
3867
  }
3868
+ fallback ??= addr.address;
3846
3869
  }
3847
3870
  }
3848
- return "127.0.0.1";
3871
+ return fallback ?? "127.0.0.1";
3849
3872
  }
3850
3873
  async function resolveSessionIP(mode, isLocalhost) {
3851
3874
  if (isLocalhost) return "127.0.0.1";