Vorta did not respect metered network exclusion
Description
I was working through an internet outage at home. I connected my laptop to my phone as a mobile hotspot. Within 30-60 minutes I got a text from my wireless carrier that I had exhausted my network data plan for the month. After checking activity on my laptop, I found Vorta was in the middle of a backup.
- In the Schedule -> Network settings I have "Run backups over metered networks" unchecked.
- The Allowed Networks list automatically added my Wi-Fi hotspot and enabled it. I have since un-selected it.
It seems like the metered network setting did not work for me.
Digging around in Vorta's source code I learned how it detects metered networks on macOS here: https://github.com/borgbase/vorta/blob/master/src/vorta/network_status/darwin.py#L50-L51
def is_network_metered(bsd_device) -> bool:
return b'ANDROID_METERED' in call_ipconfig_getpacket(bsd_device)
However, when I run the underlying command, ipconfig getpacket en0 I get the following output, which does not include the text, ANDROID_METERED.
$ ipconfig getpacket en0
op = BOOTREPLY
htype = 1
flags = 0
hlen = 6
hops = 0
xid = 0x64757b68
secs = 0
ciaddr = 0.0.0.0
yiaddr = REDACTED
siaddr = REDACTED
giaddr = 0.0.0.0
chaddr = REDACTED
sname = My-Hotspot
file =
options:
Options count is 7
dhcp_message_type (uint8): ACK 0x5
server_identifier (ip): REDACTED
lease_time (uint32): 0x15180
subnet_mask (ip): 255.255.255.240
router (ip_mult): {REDACTED}
domain_name_server (ip_mult): {REDACTED}
end (none):
While doing some investigating on my own, I did find a network setting that was correlated to "Low Data Mode" on my WiFi network when connected to my mobile hotspot. I was able to find it using scutil like this:
scutil
> show State:/Network/Interface/en0/Link
<dictionary> {
Active : TRUE
Expensive : TRUE
}
I'm interested to know if anyone else is experiencing this? And whether it would be acceptable to submit a patch that changes the technique used to detect whether macOS is using a metered connection?
Reproduction
- [X] I tried to reproduce the issue.
- [X] I was able to reproduce the issue.
OS
macOS Sonoma 14.1.2
Version of Vorta
0.8.11
What did you install Vorta with?
Homebrew
Version of Borg
1.2.4
Logs
No response
Oh, that sucks. Sorry for the issue.
I was experimenting with this setting a few years ago, when it was first added on Linux. I believe ANDROID_METERED will only apply, when sharing from an Android phone.
Apple also keeps changing these things. E.g. they removed access to known Wifis a while back.
So any improvement, is surely welcome. Code is separate per-OS, so simpler to test.
There is also an app I use in such situations. It's also useful for catching background updates, etc: https://apps.apple.com/us/app/bandwidth/id490461369?mt=12
PR submitted. :)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Closing this, since the related PR was already merged. Thanks for bringing this up and also fixing it!