Fix OpenVpn over Cloak
This commit is contained in:
parent
3afbc248b1
commit
cbd6755aa5
3 changed files with 14 additions and 3 deletions
|
|
@ -3,6 +3,9 @@ package org.amnezia.vpn.protocol.cloak
|
||||||
import android.util.Base64
|
import android.util.Base64
|
||||||
import net.openvpn.ovpn3.ClientAPI_Config
|
import net.openvpn.ovpn3.ClientAPI_Config
|
||||||
import org.amnezia.vpn.protocol.openvpn.OpenVpn
|
import org.amnezia.vpn.protocol.openvpn.OpenVpn
|
||||||
|
import org.amnezia.vpn.protocol.openvpn.OpenVpnConfig
|
||||||
|
import org.amnezia.vpn.util.net.InetNetwork
|
||||||
|
import org.amnezia.vpn.util.net.parseInetAddress
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -51,6 +54,13 @@ class Cloak : OpenVpn() {
|
||||||
return openVpnConfig
|
return openVpnConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun configPluggableTransport(configBuilder: OpenVpnConfig.Builder, config: JSONObject) {
|
||||||
|
// exclude remote server ip from vpn routes
|
||||||
|
val remoteServer = config.getString("hostName")
|
||||||
|
val remoteServerAddress = InetNetwork(parseInetAddress(remoteServer))
|
||||||
|
configBuilder.excludeRoute(remoteServerAddress)
|
||||||
|
}
|
||||||
|
|
||||||
private fun checkCloakJson(cloakConfigJson: JSONObject): JSONObject {
|
private fun checkCloakJson(cloakConfigJson: JSONObject): JSONObject {
|
||||||
cloakConfigJson.put("NumConn", 1)
|
cloakConfigJson.put("NumConn", 1)
|
||||||
cloakConfigJson.put("ProxyMethod", "openvpn")
|
cloakConfigJson.put("ProxyMethod", "openvpn")
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@ open class OpenVpn : Protocol() {
|
||||||
if (evalConfig.error) {
|
if (evalConfig.error) {
|
||||||
throw BadConfigException("OpenVPN config parse error: ${evalConfig.message}")
|
throw BadConfigException("OpenVPN config parse error: ${evalConfig.message}")
|
||||||
}
|
}
|
||||||
|
configPluggableTransport(configBuilder, config)
|
||||||
configBuilder.configSplitTunneling(config)
|
configBuilder.configSplitTunneling(config)
|
||||||
|
|
||||||
scope.launch {
|
scope.launch {
|
||||||
|
|
@ -111,6 +112,8 @@ open class OpenVpn : Protocol() {
|
||||||
return openVpnConfig
|
return openVpnConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected open fun configPluggableTransport(configBuilder: OpenVpnConfig.Builder, config: JSONObject) {}
|
||||||
|
|
||||||
private fun makeEstablish(vpnBuilder: Builder): (OpenVpnConfig.Builder) -> Int = { configBuilder ->
|
private fun makeEstablish(vpnBuilder: Builder): (OpenVpnConfig.Builder) -> Int = { configBuilder ->
|
||||||
val openVpnConfig = configBuilder.build()
|
val openVpnConfig = configBuilder.build()
|
||||||
buildVpnInterface(openVpnConfig, vpnBuilder)
|
buildVpnInterface(openVpnConfig, vpnBuilder)
|
||||||
|
|
|
||||||
|
|
@ -91,9 +91,7 @@ class OpenVpnClient(
|
||||||
// metric is optional and should be ignored if < 0
|
// metric is optional and should be ignored if < 0
|
||||||
override fun tun_builder_exclude_route(address: String, prefix_length: Int, metric: Int, ipv6: Boolean): Boolean {
|
override fun tun_builder_exclude_route(address: String, prefix_length: Int, metric: Int, ipv6: Boolean): Boolean {
|
||||||
Log.d(TAG, "tun_builder_exclude_route: $address, $prefix_length, $metric, $ipv6")
|
Log.d(TAG, "tun_builder_exclude_route: $address, $prefix_length, $metric, $ipv6")
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
configBuilder.excludeRoute(InetNetwork(address, prefix_length))
|
||||||
configBuilder.excludeRoute(InetNetwork(address, prefix_length))
|
|
||||||
}
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue