summaryrefslogtreecommitdiffhomepage
path: root/mullvad-daemon/src
AgeCommit message (Collapse)AuthorFilesLines
2024-01-31If the last access method is removed, re-enable DirectMarkus Pettersson1-24/+24
2024-01-31Change API access methods settings formatMarkus Pettersson1-27/+286
Change API access methods settings format to encode that built-in access methods always exist by making them distinct values of the `AccessMethod` settings. This change was also propagated to the corresponding protobuf definition, such that any client may make use of this fact as well. The appropriate settings migration was added.
2024-01-31Allow fallible settings update functionsMarkus Pettersson1-6/+73
Implement `SettingsPersister.try_update`, which allow the caller to signal a failed settings update, hindering a bad settings update from being applied.
2024-01-22Add `TestCustomApiAccessMethod` RPC callMarkus Pettersson4-54/+143
Add a new RPC call `TestCustomApiAccessMethod` for testing access methods on the fly, without having to save them to the daemon settings first. This only works for custom access methods.
2024-01-22Move logic of toggling disabled access methods on use to the daemonMarkus Pettersson2-31/+58
2024-01-18Update the tunnel state on lockdown mode change.Sebastian Holmin2-4/+3
The printing of lockdown mode by `mullvad status` does not reflect the current setting unless the tunnel state has also been updated.
2024-01-18Print if lockdown mode is enabled when disconnected for `mullvad status`Sebastian Holmin1-8/+18
Add `locked_down` field to disconnected tunnel state.
2024-01-12Validate SOCKS5 credentialsMarkus Pettersson1-4/+3
Validate SOCKS credentials by checking that both `username` and `password` both have a length between 1 and 255 bytes. Link to RFC detailing SOCKS5 username/password authentication: https://datatracker.ietf.org/doc/html/rfc1929
2024-01-11Synchronize `mullvad-api` and `mullvad-daemon` when the `api-override`Markus Pettersson2-88/+106
feature is enabled Move the logic for using overridden API endpoints for API calls from `mullvad-api::rest` to `mullvad_daemon::api`. This is in line with how the interaction between the two crates work for a normal release build, i.e. when the `api-override` feature is disabled. This commit also removes references to `force_direct_connection` in the Android code. The flag does not exist in the `mullvad-*` rust crates anymore, so it would be erroneous to try to serialize/deserialize the value from the Android client.
2024-01-10Link to patch spec in patch moduleDavid Lönnhager1-0/+3
2024-01-10Add unit test for export functionDavid Lönnhager1-0/+19
2024-01-10Add patch export to the management interfaceDavid Lönnhager3-2/+57
2024-01-08Add unit test that loads valid patch fileDavid Lönnhager1-7/+24
2024-01-08Re-implement test procedure for access methodsMarkus Pettersson2-122/+69
Since the `AccessModeSelector` knows how to resolve endpoints on it's own, we no longer have to re-use the existing `MullvadRestHandle` from the daemon. Instead, we may spawn a completely new `ApiProxy` and except the appropriate endpoint in the firewall without affecting the running `MullvadRestHandle`.
2024-01-08Cleanup daemon code related to access methodsMarkus Pettersson1-41/+32
2024-01-08Implement handler for `NewAccessMethodEvent`Markus Pettersson1-1/+25
This commit implements the daemon logic for handling a `NewAccessMethodEvent`. Such an event occur when `AccessModeSelector` announces that a new access method is active, and it will cause the daemon to except some API endpoint in the firewall. It may conditionally broadcast the new access method to all clients.
2024-01-08Allow `AccessModeSelector` to resolve api endpointsMarkus Pettersson2-12/+14
Until now, `AccessModeSelector` has not been able to resolve API endpoints on it's own. This has happened at some later stage, for example in the `mullvad-api` crate. However, for testing the `Direct` access method, it is very useful to be able to resolve the actual endpoint without involving the daemon's "API runtime".
2024-01-08Remove `ApiEndpointUpdateHandler`Markus Pettersson2-46/+17
Previously, the `mullvad-api` would tell the `mullvad-daemon` that it wanted a new API endpoint by calling a certain callback (`ApiEndpointUpdateCallback`), which would asynchronously resolve a new API endpoint and tell the daemon to punch an appropriate hole in the firewall for that particular endpoint before the `mullvad-api` crate would consume it. The logic of the callback can be moved inside `AccessModeSelector`, which simplifies the contract between `mullvad-daemon` and `mullvad-api` somewhat.
2024-01-08Add new internal daemon event `AccessMethodEvent`Markus Pettersson3-161/+318
Add a new `InternalDaemonEvent` for announcing when the current API access method changes.
2024-01-05Run `cargo +nightly fmt`Sebastian Holmin5-9/+12
2024-01-05Run `cargo clippy --all-targets --fix`Sebastian Holmin2-3/+1
These lints where missed because the problems were inside tests. Note that "targets" does not refer to OS/architectures. ``` > cargo build --help ... Target Selection: --lib Build only this package's library --bins Build all binaries --bin [<NAME>] Build only the specified binary --examples Build all examples --example [<NAME>] Build only the specified example --tests Build all test targets --test [<NAME>] Build only the specified test target --benches Build all bench targets --bench [<NAME>] Build only the specified bench target --all-targets Build all targets ```
2024-01-04Add workspace level lintsLinus Färnstrand2-3/+0
2024-01-04Remove debug logging for geoipDavid Lönnhager1-1/+0
2024-01-03Allow app to use custom socks5 and shadwosocks proxiesJonathan7-21/+1043
This PR has a couple of different purposes - Allow users to use socks5 local proxies with the CLI without having to be root nor use split-tunneling. This only works for OpenVPN. - Unify the types used by different proxy parts of the codebase, such as the Access Methods as well as some already existing OpenVPN proxy code. This PR changes the firewall on all desktop platforms as well as changes the routing table slightly on MacOS and Windows. On Linux the firewall code is modified to apply the appropriate firewall marks to all packages that go to a remote endpoint corresponding to the remote part of a local socks5 proxy. The firewall marks will allow the routing to be done without having to modify the routing table. On MacOS and Windows the routing table is modified to allow packages to go to that same endpoint to pass outside the VPN tunnel, it will additionally punch a hole in the firewall. The PR also migrates the settings file from version 7 to version 8 in order to properly and neatly unify Proxy related types. Finally it provides some slight extensions to the gRPC interface in order to allow for control over the custom proxy settings.
2024-01-03Prevent the last access method from being disabledMarkus Pettersson1-10/+25
Add proper checks around disabling the last enabled access method. If the daemon detects that any one access method update would cause the last enabled access method to become disabled, it will find & toggle the `Direct` access method setting to be enabled.
2024-01-03Gracefully handle errors in `AccessModeSelector`Markus Pettersson1-9/+35
Not all errors which the running `AccessModeSelector` will encounter is fatal, and as such we should not bring the running instance down in every case. Instead, if the error is not fatal, the main loop of the `AccessModeSelector` should continue to process new commands.
2024-01-02Fix clippy lintsDavid Lönnhager3-12/+12
2023-12-29Fetch account ID from APIDavid Lönnhager3-21/+24
2023-12-21Handle am.i.mullvad.net with internal daemon eventSebastian Holmin2-69/+146
Add `geoip::GeoIpHandler`, which sends an `InternalDaemonEvent::LocationEvent` when the location arrives. It also handles aborting in-flight requests and retries.
2023-12-21Remove `GetCurrentLocation`.Sebastian Holmin3-80/+73
Make the daemon send two tunnel state updates, one with out IP being empty, and another with it being filled when am.i.mullvad.net responds. Update CLI for this change. Other front ends are left out.
2023-12-21Change to exponential retry delaySebastian Holmin1-5/+5
2023-12-12Add unit tests for deserializing missing or invalid settingsMarkus Pettersson1-1/+62
2023-12-12Refactor reading of settingsMarkus Pettersson1-37/+70
Separate concerns of `SettingsPersister`'s error recovery and the deserialization of `Settings` from file.
2023-12-12Run device check on every third attempt instead of every otherDavid Lönnhager1-1/+1
2023-12-12Add unit tests for device checkDavid Lönnhager1-32/+196
2023-12-12Remove unused 'default tunnel type' from relay selectorDavid Lönnhager1-3/+0
2023-12-06Add unit tests for `PersistentTargetState`Markus Pettersson1-25/+121
This includes refactoring reading of the state cache into a higher-order function.
2023-12-04Clean up error handlingMarkus Pettersson3-144/+133
2023-12-04Inline `ApiConnectionModeProvider` into `AccessModeSelector`Markus Pettersson1-61/+36
2023-12-04Add more error handlingMarkus Pettersson1-7/+16
2023-12-04Add more comments to `AccessModeSelector`Markus Pettersson2-13/+24
2023-12-04Get rid of unnecessary `Arc<Mutex<_>>`Markus Pettersson1-25/+22
2023-12-04Add proper error handlingMarkus Pettersson1-9/+20
2023-12-04Construct `AccessModeSelectorHandle` by calling `AccessModeSelector::spawn`Markus Pettersson3-54/+33
Construct an `AccessModeSelectorHandle` by calling `AccessModeSelector::spawn`, which is consistent with how actors are spawned in other parts of the `mullvad-daemon`.
2023-12-04Refactor `access_methods.rs`Markus Pettersson3-18/+20
- Naming of structs/enums/variables - Add documentation - Change existing doc comment to better reflect their context / any new naming
2023-12-04Perform testing of access methods asynchronouslyMarkus Pettersson4-131/+348
Perform testing of access methods asynchronously in a separate `tokio` task as to not block the daemon from handling other daemon events during the testing window
2023-12-04Move access method testing logic to `mullvad-daemon`Markus Pettersson2-11/+57
Move access method testing logic to `mullvad-daemon`, which means that the implementation details of how the test works is opaque to whatever frontend which wants to issue a test of some (configured) access method.
2023-11-28Add retry for `GetCurrentLocation`Sebastian Holmin2-37/+62
2023-11-23Fix uncaught clippy warnings and a typo.Sebastian Holmin1-17/+17
2023-11-22Complete certain management interface commands when the tunnel state machine ↵David Lönnhager1-7/+41
has actually handled the request