-
Notifications
You must be signed in to change notification settings - Fork 36
VPN-4586: Return an error when the Nym log file is not created #4122
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
Conversation
241bace to
7f02a6a
Compare
pronebird
left a comment
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.
As we discussed in internal comms. Let's debate in offline before merging this
pronebird
left a comment
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: 0 of 16 files reviewed, 2 unresolved discussions (waiting on @mrkiwi and @trojanfoe)
nym-vpn-core/crates/nym-vpn-lib-uniffi/src/ios.rs line 51 at r2 (raw file):
if let Some(parent) = path.parent() && !parent.exists() && let Err(e) = std::fs::create_dir_all(parent)
IIRC create_dir_all() never fails if created directory already exists. Please verify. There is no need to check for parent.exists() neither.
nym-vpn-core/crates/nym-vpn-lib-uniffi/src/ios.rs line 62 at r2 (raw file):
// Attempt to open the log file for writing let file = match OpenOptions::new()
Rewrite with .map_err()?; perhaps? In most cases Ok(x) => x is indication that something isn't right. Presence or return too.
pronebird
left a comment
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: 0 of 16 files reviewed, 3 unresolved discussions (waiting on @mrkiwi and @trojanfoe)
nym-vpn-core/crates/nym-vpn-lib-uniffi/src/ios.rs line 98 at r2 (raw file):
.try_init() .map_err(|err| VpnError::CreateLogFile { details: format!("Failed to initialize OsLogger: {err}"),
Please correct the message. We're not initializing OsLogger alone, but tracing log.
pronebird
left a comment
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: 0 of 16 files reviewed, 4 unresolved discussions (waiting on @mrkiwi and @trojanfoe)
nym-vpn-core/crates/nym-vpn-lib-uniffi/src/lib.rs line 224 at r2 (raw file):
#[cfg(target_os = "ios")] let result = ios::init_logs(log_level, path, sentry_monitoring);
Nit: It's possible to wrap this in { .. } and return explicitly without going via result
pronebird
left a comment
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: 0 of 16 files reviewed, 5 unresolved discussions (waiting on @mrkiwi and @trojanfoe)
nym-vpn-core/crates/nym-vpn-lib-uniffi/src/android.rs line 8 at r2 (raw file):
use crate::error::VpnError; pub(crate) fn init_logs(level: String) -> Result<(), VpnError> {
This method is infallible. Remove the Result
pronebird
left a comment
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: 0 of 16 files reviewed, 6 unresolved discussions (waiting on @mrkiwi and @trojanfoe)
nym-vpn-android/core/src/main/java/net/nymtech/vpn/backend/NymBackend.kt line 134 at r2 (raw file):
initLogger(storagePath, LOG_LEVEL, config.sentryMonitoringEnabled) ?: Timber.e("Failed to initialize backed logger")
typo in backend?
pronebird
left a comment
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: 0 of 16 files reviewed, 7 unresolved discussions (waiting on @mrkiwi and @trojanfoe)
nym-vpn-apple/NymMixnetTunnel/PacketTunnelProvider.swift line 135 at r2 (raw file):
let logPath = LogFileManager.logFileURL(logFileType: .library)?.path() Task {
Problem that this makes logging initialization asynchronous. This needs to be synchronous somehow.
On the mobile platform, if the VPN log files fails to open, then it's considered a fatal error.
pronebird
left a comment
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: 0 of 16 files reviewed, 8 unresolved discussions (waiting on @mrkiwi and @trojanfoe)
nym-vpn-core/crates/nym-firewall/src/net.rs line 29 at r2 (raw file):
/// When "allow local network" is enabled the app will allow traffic to these networks. #[cfg_attr( any(target_os = "windows", target_os = "android", target_os = "ios"),
We don't compile nor even reference nym-firewall on mobile, please undo the change.
pronebird
left a comment
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.
@pronebird reviewed 3 of 10 files at r1, 13 of 13 files at r2, all commit messages.
Reviewable status: all files reviewed, 7 unresolved discussions (waiting on @mrkiwi and @trojanfoe)
da7cef2 to
39a13bd
Compare
trojanfoe
left a comment
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, 6 unresolved discussions (waiting on @mrkiwi and @pronebird)
nym-vpn-core/crates/nym-firewall/src/net.rs line 29 at r2 (raw file):
Previously, pronebird (Andrej Mihajlov) wrote…
We don't compile nor even reference nym-firewall on mobile, please undo the change.
I was getting a warning in VSCode configured for iOS, so it was seeing this code.
nym-vpn-core/crates/nym-vpn-lib-uniffi/src/android.rs line 8 at r2 (raw file):
Previously, pronebird (Andrej Mihajlov) wrote…
This method is infallible. Remove the
Result
I would prefer both the iOS and the Android code to have similar semantics, infallible or not.
nym-vpn-core/crates/nym-vpn-lib-uniffi/src/ios.rs line 51 at r2 (raw file):
Previously, pronebird (Andrej Mihajlov) wrote…
IIRC
create_dir_all()never fails if created directory already exists. Please verify. There is no need to check forparent.exists()neither.
Done.
nym-vpn-core/crates/nym-vpn-lib-uniffi/src/ios.rs line 62 at r2 (raw file):
Previously, pronebird (Andrej Mihajlov) wrote…
Rewrite with
.map_err()?;perhaps? In most casesOk(x) => xis indication that something isn't right. Presence orreturntoo.
Huh? Ok(x) is indication that something isn't right?
trojanfoe
left a comment
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: 11 of 16 files reviewed, 5 unresolved discussions (waiting on @mrkiwi, @neacsu, and @pronebird)
nym-vpn-apple/NymMixnetTunnel/PacketTunnelProvider.swift line 135 at r2 (raw file):
Previously, pronebird (Andrej Mihajlov) wrote…
Problem that this makes logging initialization asynchronous. This needs to be synchronous somehow.
I'll wait for Matt.
pronebird
left a comment
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: 11 of 16 files reviewed, 5 unresolved discussions (waiting on @mrkiwi, @neacsu, and @trojanfoe)
nym-vpn-core/crates/nym-vpn-lib-uniffi/src/ios.rs line 62 at r2 (raw file):
Previously, trojanfoe (Andy Duplain) wrote…
Huh?
Ok(x)is indication that something isn't right?
Sorry for confusion. What I mean is that the expression can be rewritten using .map or .map_err with early return ? to achieve the same. The indication is when either leg of match returns the value verbatim (i.e Ok(x) => x or Err(e) => e).
pronebird
left a comment
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: 11 of 16 files reviewed, 5 unresolved discussions (waiting on @mrkiwi, @neacsu, and @trojanfoe)
nym-vpn-apple/NymMixnetTunnel/PacketTunnelProvider.swift line 135 at r2 (raw file):
Previously, trojanfoe (Andy Duplain) wrote…
I'll wait for Matt.
Le'ts tackle that separately.
pronebird
left a comment
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: 11 of 16 files reviewed, 1 unresolved discussion (waiting on @mrkiwi, @neacsu, and @trojanfoe)
nym-vpn-android/core/src/main/java/net/nymtech/vpn/backend/NymBackend.kt line 134 at r4 (raw file):
startNetworkMonitorJob() initLogger(storagePath, LOG_LEVEL, config.sentryMonitoringEnabled)
Since we return an error here, would it not make sense to print it?
pronebird
left a comment
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.
@pronebird reviewed 1 of 1 files at r4.
Reviewable status: 12 of 16 files reviewed, 1 unresolved discussion (waiting on @mrkiwi, @neacsu, and @trojanfoe)
pronebird
left a comment
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.
@pronebird reviewed 4 of 5 files at r3, all commit messages.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on @mrkiwi and @neacsu)
Ticket
JIRA-VPN-4586
Description
On the mobile platform, if the VPN log files fails to open we capture the error for reporting to the user.
Checklist:
Screenshots (optional, if UI related)
This change is