New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework offline detection on Linux #2377
Conversation
e3643b1
to
b2c8b3d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 4 of 4 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @pinkisemils)
talpid-core/src/offline/linux.rs, line 118 at r1 (raw file):
async fn public_ip_not_reachable(handle: &Handle) -> Result<bool> {
I think this should be public_ip_reachable
(i.e., not negated).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @dlon)
talpid-core/src/offline/linux.rs, line 118 at r1 (raw file):
Previously, dlon (David Lönnhager) wrote…
I think this should be
public_ip_reachable
(i.e., not negated).
public_ip_unreachable()
would be better still IMO, since every time this function is called, it's return value is assigned to is_offline
in one way or another. Or do you think that !pubilc_ip_reachable()
is better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @pinkisemils)
talpid-core/src/offline/linux.rs, line 118 at r1 (raw file):
Previously, pinkisemils (Emīls Piņķis) wrote…
public_ip_unreachable()
would be better still IMO, since every time this function is called, it's return value is assigned tois_offline
in one way or another. Or do you think that!pubilc_ip_reachable()
is better?
You're right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 4 files at r1.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @pinkisemils)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @pinkisemils)
talpid-core/src/offline/linux.rs, line 52 at r1 (raw file):
} const PUBLIC_INTERNET_ADDRESS: Ipv4Addr = Ipv4Addr::new(193, 138, 218, 78);
Can we please leave a comment on such a magical constant? One that explains that any public IP should do, but we stick to one owned my Mullvad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @dlon and @pinkisemils)
talpid-core/src/offline/linux.rs, line 118 at r1 (raw file):
Previously, dlon (David Lönnhager) wrote…
You're right.
I vote for anything that does not have a negation in the name. Evaluating "is not reachable: true" in my head always leads to smoke coming out of my ears. "Is unreachable: true" or "is reachable: false" is way easier to process.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @dlon and @pinkisemils)
talpid-core/src/offline/mod.rs, line 42 at r1 (raw file):
#[cfg(target_os = "android")] android_context: AndroidContext, ) -> Result<MonitorHandle, Error> { let monitor = match std::env::var(TALPID_DISABLE_OFFLINE_MONITOR)
Maybe can be made simpler and more consistent if implemented with a lazy_static
like the other env variable checks? Then the constant can contain the actual value and not just the name of the env var to check
mullvadvpn-app/talpid-core/src/tunnel/wireguard/mod.rs
Lines 65 to 67 in 6b91207
static ref FORCE_USERSPACE_WIREGUARD: bool = env::var("TALPID_FORCE_USERSPACE_WIREGUARD") | |
.map(|v| v != "0") | |
.unwrap_or(false); |
Also easier to verify that the logic is the same as the others
b2c8b3d
to
b673a75
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @faern)
talpid-core/src/offline/linux.rs, line 52 at r1 (raw file):
Previously, faern (Linus Färnstrand) wrote…
Can we please leave a comment on such a magical constant? One that explains that any public IP should do, but we stick to one owned my Mullvad.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 of 4 files reviewed, 1 unresolved discussion (waiting on @dlon and @pinkisemils)
talpid-core/src/offline/mod.rs, line 25 at r2 (raw file):
lazy_static::lazy_static! { /// Disables offline monitor static ref FORCE_DISABLE_OFFLINE_MONITOR: bool = std::env::var("TALPID_FORCE_USERSPACE_WIREGUARD")
USERSPACE_WIREGUARD
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 2 of 4 files reviewed, 1 unresolved discussion (waiting on @dlon and @faern)
talpid-core/src/offline/mod.rs, line 25 at r2 (raw file):
Previously, faern (Linus Färnstrand) wrote…
USERSPACE_WIREGUARD
?
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 2 files at r2, 1 of 1 files at r3.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @faern)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 2 files at r2, 1 of 1 files at r3.
Reviewable status: complete! all files reviewed, all discussions resolved
59b0c3b
to
4d95fa2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r4.
Reviewable status: complete! all files reviewed, all discussions resolved
4d95fa2
to
b29cd20
Compare
To improve offline detection on Linux and desktop in general, I've done two things:
This change is