Skip to content

Commit 7ba7ef5

Browse files
committed
Migrate to gRPC
1 parent 685bd3c commit 7ba7ef5

File tree

537 files changed

+9445
-13012
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

537 files changed

+9445
-13012
lines changed

.github/workflows/android-app.yml

+2
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ jobs:
222222
:app:testOssProdDebugUnitTest
223223
:service:testOssProdDebugUnitTest
224224
:lib:billing:testDebugUnitTest
225+
:lib:daemon-grpc:testDebugUnitTest
226+
:lib:shared:testDebugUnitTest
225227
- gradle-task: :test:arch:test --rerun-tasks
226228
- gradle-task: detekt
227229
- gradle-task: lint

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

android/app/build.gradle.kts

+12-7
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ android {
174174
"META-INF/LGPL2.1",
175175
// Fixes packaging error caused by: jetified-junit-*
176176
"META-INF/LICENSE.md",
177-
"META-INF/LICENSE-notice.md"
177+
"META-INF/LICENSE-notice.md",
178+
"META-INF/io.netty.versions.properties",
179+
"META-INF/INDEX.LIST"
178180
)
179181
}
180182
}
@@ -305,18 +307,19 @@ afterEvaluate {
305307
play { serviceAccountCredentials.set(file("play-api-key.json")) }
306308

307309
dependencies {
308-
implementation(project(Dependencies.Mullvad.vpnService))
309-
implementation(project(Dependencies.Mullvad.tileService))
310-
311310
implementation(project(Dependencies.Mullvad.commonLib))
311+
implementation(project(Dependencies.Mullvad.daemonGrpc))
312312
implementation(project(Dependencies.Mullvad.endpointLib))
313-
implementation(project(Dependencies.Mullvad.ipcLib))
313+
implementation(project(Dependencies.Mullvad.intentLib))
314+
implementation(project(Dependencies.Mullvad.mapLib))
314315
implementation(project(Dependencies.Mullvad.modelLib))
316+
implementation(project(Dependencies.Mullvad.paymentLib))
315317
implementation(project(Dependencies.Mullvad.resourceLib))
318+
implementation(project(Dependencies.Mullvad.sharedLib))
316319
implementation(project(Dependencies.Mullvad.talpidLib))
320+
implementation(project(Dependencies.Mullvad.tileService))
317321
implementation(project(Dependencies.Mullvad.themeLib))
318-
implementation(project(Dependencies.Mullvad.paymentLib))
319-
implementation(project(Dependencies.Mullvad.mapLib))
322+
implementation(project(Dependencies.Mullvad.vpnService))
320323

321324
// Play implementation
322325
playImplementation(project(Dependencies.Mullvad.billingLib))
@@ -342,6 +345,8 @@ dependencies {
342345
implementation(Dependencies.Kotlin.stdlib)
343346
implementation(Dependencies.KotlinX.coroutinesAndroid)
344347

348+
implementation(Dependencies.Arrow.core)
349+
345350
// UI tooling
346351
implementation(Dependencies.Compose.uiToolingPreview)
347352
debugImplementation(Dependencies.Compose.uiTooling)

android/app/lint-baseline.xml

+2-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<issues format="6" by="lint 8.1.4" type="baseline" client="gradle" dependencies="false" name="AGP (8.1.4)" variant="all" version="8.1.4">
3-
4-
<issue
5-
id="MissingSuperCall"
6-
message="Overriding method should call `super.onActivityResult`"
7-
errorLine1=" override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {"
8-
errorLine2=" ~~~~~~~~~~~~~~~~">
9-
<location
10-
file="src/main/kotlin/net/mullvad/mullvadvpn/ui/MainActivity.kt"
11-
line="70"
12-
column="18"/>
13-
</issue>
2+
<issues format="6" by="lint 8.3.0" type="baseline" client="gradle" dependencies="false" name="AGP (8.3.0)" variant="all" version="8.3.0">
143

154
<issue
165
id="UseCheckPermission"
@@ -30,7 +19,7 @@
3019
errorLine2=" ~~~~~">
3120
<location
3221
file="src/main/AndroidManifest.xml"
33-
line="25"
22+
line="23"
3423
column="39"/>
3524
</issue>
3625

android/app/proguard-rules.pro

+12
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,15 @@
1818
-dontwarn org.joda.time.**
1919
-keep class org.joda.time.** { *; }
2020
-keep interface org.joda.time.** { *; }
21+
22+
# grpc
23+
-keep class io.grpc.okhttp.OkHttpChannelBuilder { *; }
24+
-keep class mullvad_daemon.management_interface.** { *; }
25+
-keep class com.google.protobuf.Timestamp { *; }
26+
-dontwarn com.google.j2objc.annotations.ReflectionSupport
27+
-dontwarn com.google.j2objc.annotations.RetainedWith
28+
-dontwarn com.squareup.okhttp.CipherSuite
29+
-dontwarn com.squareup.okhttp.ConnectionSpec
30+
-dontwarn com.squareup.okhttp.TlsVersion
31+
32+
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,108 @@
11
package net.mullvad.mullvadvpn.compose.data
22

3-
import net.mullvad.mullvadvpn.model.CustomListName
4-
import net.mullvad.mullvadvpn.model.PortRange
5-
import net.mullvad.mullvadvpn.model.RelayEndpointData
6-
import net.mullvad.mullvadvpn.model.RelayList
7-
import net.mullvad.mullvadvpn.model.RelayListCity
8-
import net.mullvad.mullvadvpn.model.RelayListCountry
9-
import net.mullvad.mullvadvpn.model.WireguardEndpointData
10-
import net.mullvad.mullvadvpn.model.WireguardRelayEndpointData
11-
import net.mullvad.mullvadvpn.relaylist.RelayItem
12-
import net.mullvad.mullvadvpn.relaylist.toRelayCountries
3+
import net.mullvad.mullvadvpn.lib.model.CustomList
4+
import net.mullvad.mullvadvpn.lib.model.CustomListId
5+
import net.mullvad.mullvadvpn.lib.model.CustomListName
6+
import net.mullvad.mullvadvpn.lib.model.GeoLocationId
7+
import net.mullvad.mullvadvpn.lib.model.Ownership
8+
import net.mullvad.mullvadvpn.lib.model.PortRange
9+
import net.mullvad.mullvadvpn.lib.model.Provider
10+
import net.mullvad.mullvadvpn.lib.model.ProviderId
11+
import net.mullvad.mullvadvpn.lib.model.RelayItem
12+
import net.mullvad.mullvadvpn.lib.model.RelayList
13+
import net.mullvad.mullvadvpn.lib.model.WireguardEndpointData
1314

1415
private val DUMMY_RELAY_1 =
15-
net.mullvad.mullvadvpn.model.Relay(
16-
hostname = "Relay host 1",
16+
RelayItem.Location.Relay(
17+
id =
18+
GeoLocationId.Hostname(
19+
city = GeoLocationId.City(GeoLocationId.Country("RCo1"), "Relay City 1"),
20+
"Relay host 1"
21+
),
1722
active = true,
18-
endpointData = RelayEndpointData.Wireguard(WireguardRelayEndpointData),
19-
owned = true,
20-
provider = "PROVIDER"
23+
provider =
24+
Provider(
25+
providerId = ProviderId("PROVIDER RENTED"),
26+
ownership = Ownership.Rented,
27+
)
2128
)
2229
private val DUMMY_RELAY_2 =
23-
net.mullvad.mullvadvpn.model.Relay(
24-
hostname = "Relay host 2",
30+
RelayItem.Location.Relay(
31+
id =
32+
GeoLocationId.Hostname(
33+
city = GeoLocationId.City(GeoLocationId.Country("RCo2"), "Relay City 2"),
34+
"Relay host 2"
35+
),
2536
active = true,
26-
endpointData = RelayEndpointData.Wireguard(WireguardRelayEndpointData),
27-
owned = true,
28-
provider = "PROVIDER"
37+
provider =
38+
Provider(providerId = ProviderId("PROVIDER OWNED"), ownership = Ownership.MullvadOwned)
39+
)
40+
private val DUMMY_RELAY_CITY_1 =
41+
RelayItem.Location.City(
42+
name = "Relay City 1",
43+
id = GeoLocationId.City(countryCode = GeoLocationId.Country("RCo1"), cityCode = "RCi1"),
44+
relays = listOf(DUMMY_RELAY_1),
45+
expanded = false
46+
)
47+
private val DUMMY_RELAY_CITY_2 =
48+
RelayItem.Location.City(
49+
name = "Relay City 2",
50+
id = GeoLocationId.City(countryCode = GeoLocationId.Country("RCo2"), cityCode = "RCi2"),
51+
relays = listOf(DUMMY_RELAY_2),
52+
expanded = false
2953
)
30-
private val DUMMY_RELAY_CITY_1 = RelayListCity("Relay City 1", "RCi1", arrayListOf(DUMMY_RELAY_1))
31-
private val DUMMY_RELAY_CITY_2 = RelayListCity("Relay City 2", "RCi2", arrayListOf(DUMMY_RELAY_2))
3254
private val DUMMY_RELAY_COUNTRY_1 =
33-
RelayListCountry("Relay Country 1", "RCo1", arrayListOf(DUMMY_RELAY_CITY_1))
55+
RelayItem.Location.Country(
56+
name = "Relay Country 1",
57+
id = GeoLocationId.Country("RCo1"),
58+
expanded = false,
59+
cities = listOf(DUMMY_RELAY_CITY_1)
60+
)
3461
private val DUMMY_RELAY_COUNTRY_2 =
35-
RelayListCountry("Relay Country 2", "RCo2", arrayListOf(DUMMY_RELAY_CITY_2))
62+
RelayItem.Location.Country(
63+
name = "Relay Country 2",
64+
id = GeoLocationId.Country("RCo2"),
65+
expanded = false,
66+
cities = listOf(DUMMY_RELAY_CITY_2)
67+
)
3668

3769
private val DUMMY_WIREGUARD_PORT_RANGES = ArrayList<PortRange>()
3870
private val DUMMY_WIREGUARD_ENDPOINT_DATA = WireguardEndpointData(DUMMY_WIREGUARD_PORT_RANGES)
3971

40-
val DUMMY_RELAY_COUNTRIES =
72+
val DUMMY_RELAY_COUNTRIES = listOf(DUMMY_RELAY_COUNTRY_1, DUMMY_RELAY_COUNTRY_2)
73+
74+
val DUMMY_RELAY_LIST =
4175
RelayList(
42-
arrayListOf(DUMMY_RELAY_COUNTRY_1, DUMMY_RELAY_COUNTRY_2),
43-
DUMMY_WIREGUARD_ENDPOINT_DATA,
44-
)
45-
.toRelayCountries()
76+
DUMMY_RELAY_COUNTRIES,
77+
DUMMY_WIREGUARD_ENDPOINT_DATA,
78+
)
4679

47-
val DUMMY_CUSTOM_LISTS =
80+
val DUMMY_RELAY_ITEM_CUSTOM_LISTS =
4881
listOf(
4982
RelayItem.CustomList(
50-
CustomListName.fromString("First list"),
51-
false,
52-
"1",
83+
customListName = CustomListName.fromString("First list"),
84+
expanded = false,
85+
id = CustomListId("1"),
5386
locations = DUMMY_RELAY_COUNTRIES
5487
),
5588
RelayItem.CustomList(
56-
CustomListName.fromString("Empty list"),
89+
customListName = CustomListName.fromString("Empty list"),
5790
expanded = false,
58-
"2",
91+
id = CustomListId("2"),
92+
locations = emptyList()
93+
)
94+
)
95+
96+
val DUMMY_CUSTOM_LISTS =
97+
listOf(
98+
CustomList(
99+
name = CustomListName.fromString("First list"),
100+
id = CustomListId("1"),
101+
locations = DUMMY_RELAY_COUNTRIES.map { it.id }
102+
),
103+
CustomList(
104+
name = CustomListName.fromString("Empty list"),
105+
id = CustomListId("2"),
59106
locations = emptyList()
60107
)
61108
)

android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/CreateCustomListDialogTest.kt

+16-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension
1212
import net.mullvad.mullvadvpn.compose.setContentWithTheme
1313
import net.mullvad.mullvadvpn.compose.state.CreateCustomListUiState
1414
import net.mullvad.mullvadvpn.compose.test.CREATE_CUSTOM_LIST_DIALOG_INPUT_TEST_TAG
15-
import net.mullvad.mullvadvpn.model.CustomListsError
15+
import net.mullvad.mullvadvpn.lib.model.CreateCustomListError
16+
import net.mullvad.mullvadvpn.usecase.customlists.CreateCustomListWithLocationsError
1617
import org.junit.jupiter.api.BeforeEach
1718
import org.junit.jupiter.api.Test
1819
import org.junit.jupiter.api.extension.RegisterExtension
@@ -44,7 +45,13 @@ class CreateCustomListDialogTest {
4445
fun givenCustomListExistsShouldShowCustomListExitsErrorText() =
4546
composeExtension.use {
4647
// Arrange
47-
val state = CreateCustomListUiState(error = CustomListsError.CustomListExists)
48+
val state =
49+
CreateCustomListUiState(
50+
error =
51+
CreateCustomListWithLocationsError.Create(
52+
CreateCustomListError.CustomListAlreadyExists
53+
)
54+
)
4855
setContentWithTheme { CreateCustomListDialog(state = state) }
4956

5057
// Assert
@@ -56,7 +63,13 @@ class CreateCustomListDialogTest {
5663
fun givenOtherCustomListErrorShouldShowAnErrorOccurredErrorText() =
5764
composeExtension.use {
5865
// Arrange
59-
val state = CreateCustomListUiState(error = CustomListsError.OtherError)
66+
val state =
67+
CreateCustomListUiState(
68+
error =
69+
CreateCustomListWithLocationsError.Create(
70+
CreateCustomListError.Unknown(Throwable())
71+
)
72+
)
6073
setContentWithTheme { CreateCustomListDialog(state = state) }
6174

6275
// Assert

android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/CustomPortDialogTest.kt

+8-8
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import io.mockk.MockKAnnotations
99
import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension
1010
import net.mullvad.mullvadvpn.compose.setContentWithTheme
1111
import net.mullvad.mullvadvpn.compose.test.CUSTOM_PORT_DIALOG_INPUT_TEST_TAG
12-
import net.mullvad.mullvadvpn.model.PortRange
12+
import net.mullvad.mullvadvpn.lib.model.Port
13+
import net.mullvad.mullvadvpn.lib.model.PortRange
1314
import net.mullvad.mullvadvpn.onNodeWithTagAndText
1415
import org.junit.jupiter.api.BeforeEach
1516
import org.junit.jupiter.api.Test
@@ -29,9 +30,9 @@ class CustomPortDialogTest {
2930
@SuppressLint("ComposableNaming")
3031
@Composable
3132
private fun testWireguardCustomPortDialog(
32-
initialPort: Int? = null,
33+
initialPort: Port? = null,
3334
allowedPortRanges: List<PortRange> = emptyList(),
34-
onSave: (Int?) -> Unit = { _ -> },
35+
onSave: (Port?) -> Unit = { _ -> },
3536
onDismiss: () -> Unit = {},
3637
) {
3738

@@ -47,21 +48,20 @@ class CustomPortDialogTest {
4748
fun testShowWireguardCustomPortDialogInvalidInt() =
4849
composeExtension.use {
4950
// Input a number to make sure that a too long number does not show and it does not
50-
// crash
51-
// the app
51+
// crash the app
5252

5353
// Arrange
5454
setContentWithTheme { testWireguardCustomPortDialog() }
5555

5656
// Act
57-
onNodeWithTag(CUSTOM_PORT_DIALOG_INPUT_TEST_TAG).performTextInput(invalidCustomPort)
57+
onNodeWithTag(CUSTOM_PORT_DIALOG_INPUT_TEST_TAG).performTextInput(INVALID_CUSTOM_PORT)
5858

5959
// Assert
60-
onNodeWithTagAndText(CUSTOM_PORT_DIALOG_INPUT_TEST_TAG, invalidCustomPort)
60+
onNodeWithTagAndText(CUSTOM_PORT_DIALOG_INPUT_TEST_TAG, INVALID_CUSTOM_PORT)
6161
.assertDoesNotExist()
6262
}
6363

6464
companion object {
65-
const val invalidCustomPort = "21474836471"
65+
const val INVALID_CUSTOM_PORT = "21474836471"
6666
}
6767
}

android/app/src/androidTest/kotlin/net/mullvad/mullvadvpn/compose/dialog/DeleteCustomListConfirmationDialogTest.kt

+21-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import io.mockk.mockk
88
import io.mockk.verify
99
import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension
1010
import net.mullvad.mullvadvpn.compose.setContentWithTheme
11+
import net.mullvad.mullvadvpn.compose.state.DeleteCustomListUiState
12+
import net.mullvad.mullvadvpn.lib.model.CustomListName
1113
import org.junit.jupiter.api.BeforeEach
1214
import org.junit.jupiter.api.Test
1315
import org.junit.jupiter.api.extension.RegisterExtension
@@ -27,8 +29,13 @@ class DeleteCustomListConfirmationDialogTest {
2729
fun givenNameShouldShowDeleteNameTitle() =
2830
composeExtension.use {
2931
// Arrange
30-
val name = "List should be deleted"
31-
setContentWithTheme { DeleteCustomListConfirmationDialog(name = name) }
32+
val name = CustomListName.fromString("List should be deleted")
33+
setContentWithTheme {
34+
DeleteCustomListConfirmationDialog(
35+
name = name,
36+
state = DeleteCustomListUiState(null)
37+
)
38+
}
3239

3340
// Assert
3441
onNodeWithText(DELETE_TITLE.format(name)).assertExists()
@@ -38,10 +45,14 @@ class DeleteCustomListConfirmationDialogTest {
3845
fun whenDeleteIsClickedShouldCallOnDelete() =
3946
composeExtension.use {
4047
// Arrange
41-
val name = "List should be deleted"
48+
val name = CustomListName.fromString("List should be deleted")
4249
val mockedOnDelete: () -> Unit = mockk(relaxed = true)
4350
setContentWithTheme {
44-
DeleteCustomListConfirmationDialog(name = name, onDelete = mockedOnDelete)
51+
DeleteCustomListConfirmationDialog(
52+
name = name,
53+
state = DeleteCustomListUiState(null),
54+
onDelete = mockedOnDelete
55+
)
4556
}
4657

4758
// Act
@@ -55,10 +66,14 @@ class DeleteCustomListConfirmationDialogTest {
5566
fun whenCancelIsClickedShouldCallOnBack() =
5667
composeExtension.use {
5768
// Arrange
58-
val name = "List should be deleted"
69+
val name = CustomListName.fromString("List should be deleted")
5970
val mockedOnBack: () -> Unit = mockk(relaxed = true)
6071
setContentWithTheme {
61-
DeleteCustomListConfirmationDialog(name = name, onBack = mockedOnBack)
72+
DeleteCustomListConfirmationDialog(
73+
name = name,
74+
state = DeleteCustomListUiState(null),
75+
onBack = mockedOnBack
76+
)
6277
}
6378

6479
// Act

0 commit comments

Comments
 (0)