Skip to content

Commit

Permalink
Add support Encrypted DNS Proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Oct 22, 2024
1 parent c2476d9 commit 4e09fa4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ internal fun ApiAccessMethod.fromDomain(): ManagementInterface.AccessMethod =
it.setDirect(ManagementInterface.AccessMethod.Direct.getDefaultInstance())
ApiAccessMethod.Bridges ->
it.setBridges(ManagementInterface.AccessMethod.Bridges.getDefaultInstance())
is ApiAccessMethod.CustomProxy -> it.setCustom(this.fromDomain())
is ApiAccessMethod.CustomProxy -> it.setCustom(fromDomain())
is ApiAccessMethod.EncryptedDns ->
it.setEncryptedDnsProxy(
ManagementInterface.AccessMethod.EncryptedDnsProxy.getDefaultInstance()
)
}
}
.build()
Expand All @@ -197,8 +201,8 @@ internal fun ApiAccessMethod.CustomProxy.fromDomain(): ManagementInterface.Custo
ManagementInterface.CustomProxy.newBuilder()
.let {
when (this) {
is ApiAccessMethod.CustomProxy.Shadowsocks -> it.setShadowsocks(this.fromDomain())
is ApiAccessMethod.CustomProxy.Socks5Remote -> it.setSocks5Remote(this.fromDomain())
is ApiAccessMethod.CustomProxy.Shadowsocks -> it.setShadowsocks(fromDomain())
is ApiAccessMethod.CustomProxy.Socks5Remote -> it.setSocks5Remote(fromDomain())
}
}
.build()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,12 @@ internal fun ManagementInterface.PlayPurchasePaymentToken.toDomain(): PlayPurcha
PlayPurchasePaymentToken(value = token)

internal fun ManagementInterface.ApiAccessMethodSettings.toDomain(): List<ApiAccessMethodSetting> =
listOf(direct.toDomain(), mullvadBridges.toDomain()).plus(customList.map { it.toDomain() })
buildList {
add(direct.toDomain())
add(mullvadBridges.toDomain())
add(encryptedDnsProxy.toDomain())
addAll(customList.map { it.toDomain() })
}

internal fun ManagementInterface.AccessMethodSetting.toDomain(): ApiAccessMethodSetting =
ApiAccessMethodSetting(
Expand All @@ -571,6 +576,7 @@ internal fun ManagementInterface.AccessMethod.toDomain(): ApiAccessMethod =
when {
hasDirect() -> ApiAccessMethod.Direct
hasBridges() -> ApiAccessMethod.Bridges
hasEncryptedDnsProxy() -> ApiAccessMethod.EncryptedDns
hasCustom() -> custom.toDomain()
else -> error("Type not found")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ sealed interface ApiAccessMethod : Parcelable {

@Parcelize data object Bridges : ApiAccessMethod

@Parcelize data object EncryptedDns : ApiAccessMethod

sealed interface CustomProxy : ApiAccessMethod {
@Parcelize
data class Socks5Remote(val ip: String, val port: Port, val auth: SocksAuth?) : CustomProxy
Expand Down

0 comments on commit 4e09fa4

Please sign in to comment.