summaryrefslogtreecommitdiffhomepage
path: root/mullvad-daemon/src/access_method.rs
AgeCommit message (Collapse)AuthorFilesLines
2025-09-30Handle error returned by access method's update functionTobias Järvelöv1-11/+16
Map error in settings::Error in the update_access_method fn so we can use the From impl to turn the error into a management interface status later.
2025-09-30Handle error returned by access method's append functionTobias Järvelöv1-3/+4
Map error in settings::Error so we can use the From impl to turn error into a management interface status
2025-07-10Run `cargo fmt`Sebastian Holmin1-2/+2
2025-06-05Fix typosomahs1-2/+2
2025-03-17Fix building for Android, rename api to access_mode in mullvad-apiBug Magnet1-9/+8
2025-03-17Move the api client from the daemon to mullvad-apiBug Magnet1-8/+9
2024-11-27Handle legacy always-on vpn profilesDavid Göransson1-0/+14
Co-authored-by: Jonatan Rhodin <jonatan.rhodin@mullvad.net>
2024-08-06Shut down gRPC server gracefullyMarkus Pettersson1-5/+2
This commit also removes the `EventListener` trait and the daemon is no longer parameterized over it.
2024-06-24Refactor daemon init and deinit on AndroidDavid Lönnhager1-1/+1
2024-04-12Add ClearCustomApiAccessMethods rpc callJoakim Hulthe1-0/+11
2024-02-27Replace err_derive with thiserrorJoakim Hulthe1-11/+11
`err_derive` is unmaintained and will probably stop working with rust edition 2024. `thiserror` is almost a drop-in replacement. This commit simply replaces all occurences of `derive(err_derive::Error)` with `derive(thiserror::Error)` and fixes the attributes, but the Error and Display impls should be identical.
2024-02-16Refactor API access methodsDavid Lönnhager1-134/+30
2024-02-15Fix off-by-one error when choosing access method candidatesMarkus Pettersson1-6/+2
2024-01-31If the current access method is disabled or removed, select the next availableMarkus Pettersson1-45/+31
If the current access method is disabled, select the next available access method from the daemon settings.
2024-01-31If the last access method is removed, re-enable DirectMarkus Pettersson1-24/+24
2024-01-22Add `TestCustomApiAccessMethod` RPC callMarkus Pettersson1-5/+62
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 Pettersson1-30/+57
2024-01-08Re-implement test procedure for access methodsMarkus Pettersson1-100/+2
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-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-02Fix clippy lintsDavid Lönnhager1-6/+6
2023-12-04Clean up error handlingMarkus Pettersson1-2/+94
2023-12-04Construct `AccessModeSelectorHandle` by calling `AccessModeSelector::spawn`Markus Pettersson1-9/+1
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 Pettersson1-7/+4
- 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 Pettersson1-28/+39
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-11-22Default to the direct access method if all methods are disabled in the settingsMarkus Pettersson1-9/+27
Make sure that access method settings can never be empty, as `ConnectionModesIterator` should never work with an empty collection
2023-10-09UX improvements for `mullvad api-access`Markus Pettersson1-28/+109
- Re-phrase help texts for a lot of `mullvad api-access` commands - Add to help texts for some `mullvad api-access` commands - Compact the output of `mullvad api-access test` - `mullvad api-access status` is changed to `mullvad api-access get` to align with other `mullvad` commands. - `mullvad api-access get` does not print the enabled/disabled status of the shown access method - Rotate access method if the currently active one is updated or removed - Fix reset access method after `mullvad api-access test` After running `mullvad api-access test`, the previously used access method should be used, which was not the case previously. - Fix `mullvad api-access use` API connectivity check - `mullvad api-access use` now runs a test-routine to check that the new access method will function before comitting to it. If this check fails, the previously used access method will be used instead - guarantee that `set_api_access_method` has finished upon returning. Make `mullvad_api::rest::next_api_endpoint` `async` and send a message upon completion. This is propagated to the caller of `next_api_endpoint` which can `await` the result
2023-10-09Code cleanupMarkus Pettersson1-1/+1
- Get rid of extraneous calls to `clone` - Address nit: combine similar match arms into a single match arm - Fix `clippy` lint "unused `async` for function with no await statements" - Fix protobuf field numbers should start from 1 - This was not the case for `Socks5Local` & `Shadowsocks` - Refactor code for opening proxy connections - Cut down on duplicated code for setting up a proxied connection in `mullvad-api`. The difference between different connection modes is how they wrap the underlying `TCP` stream. - Remove `enable_access_method` & `disable_access_method` from RPC-client
2023-10-09Add `GetCurrentApiAccessMethod` to show the current API access methodMarkus Pettersson1-13/+24
- Add a new RPC message: `GetCurrentApiAccessMethod`. This message may be used to retrieve the access method which is currently in use by the daemon for connecting to the Mullvad API. - Add `mullvad api-access status` for showing the API access method in use
2023-10-09Code cleanupMarkus Pettersson1-13/+20
- Rename `mullvad_types::api_access.rs` -> `mullvad_types::access_method.rs` - Rename `ApiAccessMethodId` to simply `Id` Prefer to prefix with module name `access_method` to disambiguate use of `Id` instead, like `access_method::Id` - Remove dead code - Remove `AccessMethodSettingsUpdate` - Remove the `retry_attempt` struct field from `ApiConnectionModeProvider`, as it is no longer used for anything. - Fix typos - `GetApiAddressess` is now correctly spelled `GetApiAddresses` (a single trailing "s") - Deprecate the name `ApiAccessMethod` in favor of `AccessMethodSetting` - To decrease the confusion between `AccessMethod` & `ApiAccessMethod`. `AccessMethodSetting` adds some app-specific settings details on top of an `AccessMethod`, which is not too far fetched with the new naming convention. - Refactor proto file - Rename protobuf message `AccessMethodSettingAdd` to `NewAccessMethodSetting` - `AccessMethod` is now its own message - `AccessMethods` is removed - Add `ApiAccessMethodAdd` protobuf message - The `ApiAccessMethodAdd` returns a `UUID` for the . One important change is that new `AccessMethodSetting`s are created in the daemon, rather than in the CLI/other clients. This means that the daemon now has full control over generating new `AccessMethodSetting`s from `AccessMethod`s. - Clean up conversion code to/from `AccessMethod` protobuf types - Simplify `UpdateApiAccessMethod` RPC - Remove the extranous `ApiAccessMethodUpdate` data type - get rid of `ApiAccessMethodUpdate` protobuf message. Use `UUID` of `ApiAccessMethod` to identify which struct to edit. - get rid of `ApiAccessMethodUpdate` struct
2023-10-09Rename `ApiAccessMethod` to `AccessMethodSetting`Markus Pettersson1-1/+4
`ApiAccessMethod` was just an app-centric wrapper around `AccessMethod`.
2023-10-09`AccessMethod`s are now filtered by the daemon rather than ↵Markus Pettersson1-1/+2
`ConnectionModesIterator` Move the duty of filtering active `AccessMethod`s from `ConnectionModesIterator` to the daemon. This provides more flexibility in the iterator as it does not need to know about `AccessMethod` at all.
2023-10-09Code cleanupMarkus Pettersson1-4/+15
- Refactor `RemoveApiAccessMethod` to be based on UUID - Remove debug-prints in `mullvad api-access list` et al - Get rid of `GetApiAccessMethods` RPC - Use the more generic RPC `GetSettings` to get hold of all API access methods instead - Rename `mullvad_types::access_method` to `mullvad_types::api_access` - Remove (unjustified) `#[inline(always)]` attributes
2023-10-09Refactor protobuf `ApiAccessMethod` definitionsMarkus Pettersson1-31/+24
- Replace rpcs `ReplaceApiAccessMethod` and `ToggleApiAccessMethod` in favor of a commmon `UpdateApiAccessMethod` (which resembles `ReplaceApiAccessMethod` in a lot of ways). - `UpdateApiAccessMethod` works with unique identifiers instead of array indices to pinpoint which API access method to update. - Toggling an API access method to be enabled/disabled now happens via `UpdateApiAccessMethod` - Add the useful `UUID` protobuf type definition, which conveys more information that a raw string. - Refactor `SetApiAccessMethod` to use API access method ID - Update `ApiAcessMethod` messages to use `UUID` type for uuid values - Use unique id for removing custom `ApiAccessMethods`
2023-10-09CleanupMarkus Pettersson1-0/+102
- General code cleanup - Fix some typos - Add some doc comments - Address several `TODO` comments - Fix `clippy` warnings - Removed unused dependency `mullvad-api` from `mullvad-cli` - Removed unused dependency `rand` from `mullvad-daemon` - Rename `mullvad proxy` to `mullvad api-access` - Rename `mullvad_types::api_access_method` -> `mullvad_types::access_method` - Remove unused `mullvad api-access edit` arguments - Fix `Display` for `ProxyConfig` printing arguments in the wrong order - Re-phrase `mullvad api-access test` - If the API call failed, point out which tested access method that did not work. - Fix missing `socket_bypass_tx` value for Android - Refactor `ApiAccessMethod` proto definition - Simplify protobuf definitions of `SOCKS5` api access methods - Remove the `Socks5` enum in favor of implementing `Socks5Local` and `Socks5Remote` directly. - Move `enabled` and `name` out of the individual messages and put them next to the `oneof access_method` in `ApiAccessMethod` proto definition - Use derived `PartialEq` and `Hash` from `AccessMethod` - Instead of hand-rolling `Hash` and implementing an ad-hoc version of half of `PartialEq`, these can now be derived and used as one would imaging due to the refactoring wherer `name` and `enabled` was moved out of `AccessMethod` into `ApiAccessMethod`.