Fix errors
This commit is contained in:
parent
e1eec55f62
commit
06776ebe8f
9 changed files with 122 additions and 127 deletions
|
|
@ -1,58 +1,50 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<manifest
|
<!-- Leave package attribute for androiddeployqt -->
|
||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.amnezia.vpn"
|
package="org.amnezia.vpn"
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:versionName="-- %%INSERT_VERSION_NAME%% --"
|
android:versionName="-- %%INSERT_VERSION_NAME%% --"
|
||||||
android:versionCode="-- %%INSERT_VERSION_CODE%% --"
|
android:versionCode="-- %%INSERT_VERSION_CODE%% --"
|
||||||
android:installLocation="auto">
|
android:installLocation="auto">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-feature android:name="android.hardware.camera" android:required="false" />
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
<uses-feature android:name="android.hardware.camera.any" android:required="false" />
|
||||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
|
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />
|
||||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
|
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
|
|
||||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
|
|
||||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE" />
|
|
||||||
|
|
||||||
<!-- Enable when VPN-per-app mode will be implemented -->
|
<!-- The following comment will be replaced upon deployment with default features based on the dependencies
|
||||||
<!-- <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/> -->
|
of the application. Remove the comment if you do not require these default features. -->
|
||||||
<uses-permission android:name="android.permission.CAMERA"/>
|
|
||||||
|
|
||||||
<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
|
|
||||||
Remove the comment if you do not require these default features. -->
|
|
||||||
<!-- %%INSERT_FEATURES -->
|
<!-- %%INSERT_FEATURES -->
|
||||||
|
|
||||||
<supports-screens
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
android:largeScreens="true"
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
android:normalScreens="true"
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
android:anyDensity="true"
|
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||||
android:smallScreens="true"/>
|
<uses-permission android:name="android.permission.CAMERA" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||||
|
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
|
||||||
|
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||||
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
|
|
||||||
|
<!-- Enable when VPN-per-app mode will be implemented -->
|
||||||
|
<!-- <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"/> -->
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:name=".qt.AmneziaApp"
|
android:name=".qt.AmneziaApp"
|
||||||
android:hardwareAccelerated="true"
|
|
||||||
android:label="-- %%INSERT_APP_NAME%% --"
|
android:label="-- %%INSERT_APP_NAME%% --"
|
||||||
android:extractNativeLibs="true"
|
|
||||||
android:requestLegacyExternalStorage="true"
|
|
||||||
android:allowNativeHeapPointerTagging="false"
|
android:allowNativeHeapPointerTagging="false"
|
||||||
android:theme="@style/Theme.AppCompat.NoActionBar"
|
|
||||||
android:icon="@drawable/icon"
|
android:icon="@drawable/icon"
|
||||||
android:roundIcon="@drawable/icon_round">
|
android:roundIcon="@drawable/icon_round"
|
||||||
|
android:theme="@style/Theme.AppCompat.NoActionBar">
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
|
|
||||||
android:name=".qt.VPNActivity"
|
android:name=".qt.VPNActivity"
|
||||||
android:label="-- %%INSERT_APP_NAME%% --"
|
android:configChanges="uiMode|screenSize|smallestScreenSize|screenLayout|orientation|density
|
||||||
android:screenOrientation="unspecified"
|
|fontScale|layoutDirection|locale|keyboard|keyboardHidden|navigation|mcc|mnc"
|
||||||
android:launchMode="singleInstance"
|
android:launchMode="singleInstance"
|
||||||
android:windowSoftInputMode="adjustResize"
|
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
|
|
||||||
<!-- android:theme="@style/splashScreenTheme"-->
|
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
|
|
@ -62,20 +54,11 @@
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.app.lib_name"
|
android:name="android.app.lib_name"
|
||||||
android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
|
android:value="-- %%INSERT_APP_LIB_NAME%% --" />
|
||||||
|
|
||||||
<meta-data
|
<meta-data
|
||||||
android:name="android.app.extract_android_style"
|
android:name="android.app.extract_android_style"
|
||||||
android:value="minimal" />
|
android:value="minimal" />
|
||||||
|
|
||||||
<meta-data
|
|
||||||
android:name="android.app.background_running"
|
|
||||||
android:value="false"/>
|
|
||||||
|
|
||||||
<meta-data
|
|
||||||
android:name="android.app.arguments"
|
|
||||||
android:value="-- %%INSERT_APP_ARGUMENTS%% --" />
|
|
||||||
|
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
|
|
@ -84,51 +67,57 @@
|
||||||
|
|
||||||
<activity
|
<activity
|
||||||
android:name=".qt.ImportConfigActivity"
|
android:name=".qt.ImportConfigActivity"
|
||||||
android:exported="true" >
|
android:exported="true">
|
||||||
|
|
||||||
<intent-filter android:label="AmneziaVPN">
|
<intent-filter android:label="AmneziaVPN">
|
||||||
<action android:name="android.intent.action.SEND"/>
|
<action android:name="android.intent.action.SEND" />
|
||||||
<action android:name="android.intent.action.VIEW"/>
|
<action android:name="android.intent.action.VIEW" />
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
|
||||||
<data android:scheme="file"/>
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<data android:scheme="content"/>
|
|
||||||
<data android:mimeType="*/*"/>
|
<data android:scheme="file" />
|
||||||
<data android:host="*"/>
|
<data android:scheme="content" />
|
||||||
<data android:pathPattern=".*\\.vpn"/>
|
<data android:mimeType="*/*" />
|
||||||
<data android:pathPattern=".*\\..*\\.vpn"/>
|
<data android:host="*" />
|
||||||
<data android:pathPattern=".*\\..*\\..*\\.vpn"/>
|
<data android:pathPattern=".*\\.vpn" />
|
||||||
<data android:pathPattern=".*\\..*\\..*\\..*\\.vpn"/>
|
<data android:pathPattern=".*\\..*\\.vpn" />
|
||||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.vpn"/>
|
<data android:pathPattern=".*\\..*\\..*\\.vpn" />
|
||||||
|
<data android:pathPattern=".*\\..*\\..*\\..*\\.vpn" />
|
||||||
|
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.vpn" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
<intent-filter android:label="AmneziaVPN">
|
<intent-filter android:label="AmneziaVPN">
|
||||||
<action android:name="android.intent.action.SEND"/>
|
<action android:name="android.intent.action.SEND" />
|
||||||
<action android:name="android.intent.action.VIEW"/>
|
<action android:name="android.intent.action.VIEW" />
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
|
||||||
<data android:scheme="file"/>
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<data android:scheme="content"/>
|
|
||||||
<data android:mimeType="*/*"/>
|
<data android:scheme="file" />
|
||||||
<data android:host="*"/>
|
<data android:scheme="content" />
|
||||||
<data android:pathPattern=".*\\.cfg"/>
|
<data android:mimeType="*/*" />
|
||||||
<data android:pathPattern=".*\\..*\\.cfg"/>
|
<data android:host="*" />
|
||||||
<data android:pathPattern=".*\\..*\\..*\\.cfg"/>
|
<data android:pathPattern=".*\\.cfg" />
|
||||||
<data android:pathPattern=".*\\..*\\..*\\..*\\.cfg"/>
|
<data android:pathPattern=".*\\..*\\.cfg" />
|
||||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.cfg"/>
|
<data android:pathPattern=".*\\..*\\..*\\.cfg" />
|
||||||
|
<data android:pathPattern=".*\\..*\\..*\\..*\\.cfg" />
|
||||||
|
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.cfg" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
<intent-filter android:label="AmneziaVPN">
|
<intent-filter android:label="AmneziaVPN">
|
||||||
<action android:name="android.intent.action.SEND"/>
|
<action android:name="android.intent.action.SEND" />
|
||||||
<action android:name="android.intent.action.VIEW"/>
|
<action android:name="android.intent.action.VIEW" />
|
||||||
<category android:name="android.intent.category.DEFAULT"/>
|
|
||||||
<data android:scheme="file"/>
|
<category android:name="android.intent.category.DEFAULT" />
|
||||||
<data android:scheme="content"/>
|
|
||||||
<data android:mimeType="*/*"/>
|
<data android:scheme="file" />
|
||||||
<data android:host="*"/>
|
<data android:scheme="content" />
|
||||||
<data android:pathPattern=".*\\.conf"/>
|
<data android:mimeType="*/*" />
|
||||||
<data android:pathPattern=".*\\..*\\.conf"/>
|
<data android:host="*" />
|
||||||
<data android:pathPattern=".*\\..*\\..*\\.conf"/>
|
<data android:pathPattern=".*\\.conf" />
|
||||||
<data android:pathPattern=".*\\..*\\..*\\..*\\.conf"/>
|
<data android:pathPattern=".*\\..*\\.conf" />
|
||||||
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.conf"/>
|
<data android:pathPattern=".*\\..*\\..*\\.conf" />
|
||||||
|
<data android:pathPattern=".*\\..*\\..*\\..*\\.conf" />
|
||||||
|
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.conf" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
|
@ -136,21 +125,23 @@
|
||||||
android:name=".VPNService"
|
android:name=".VPNService"
|
||||||
android:process=":QtOnlyProcess"
|
android:process=":QtOnlyProcess"
|
||||||
android:permission="android.permission.BIND_VPN_SERVICE"
|
android:permission="android.permission.BIND_VPN_SERVICE"
|
||||||
android:foregroundServiceType="connectedDevice"
|
android:foregroundServiceType="specialUse"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
|
|
||||||
|
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.net.VpnService"/>
|
<action android:name="android.net.VpnService" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
|
|
||||||
|
<property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE" android:value="vpn" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service
|
<service
|
||||||
android:name=".qt.VPNPermissionHelper"
|
android:name=".qt.VPNPermissionHelper"
|
||||||
android:permission="android.permission.BIND_VPN_SERVICE"
|
android:permission="android.permission.BIND_VPN_SERVICE"
|
||||||
android:foregroundServiceType="connectedDevice"
|
android:foregroundServiceType="specialUse"
|
||||||
android:exported="true">
|
android:exported="true">
|
||||||
<meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/>
|
|
||||||
|
<property android:name="android.app.PROPERTY_SPECIAL_USE_FGS_SUBTYPE" android:value="vpn" />
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
|
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
|
||||||
|
|
@ -159,7 +150,7 @@
|
||||||
android:authorities="org.amnezia.vpn.fileprovider"
|
android:authorities="org.amnezia.vpn.fileprovider"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:grantUriPermissions="true">
|
android:grantUriPermissions="true">
|
||||||
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/fileprovider"/>
|
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/fileprovider" />
|
||||||
</provider>
|
</provider>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,17 @@
|
||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
apply plugin: 'kotlin-android'
|
apply plugin: 'kotlin-android'
|
||||||
apply plugin: 'kotlin-android-extensions'
|
|
||||||
apply plugin: 'kotlin-kapt'
|
apply plugin: 'kotlin-kapt'
|
||||||
|
apply plugin: 'kotlin-parcelize'
|
||||||
//apply plugin: 'com.novoda.bintray-release'
|
//apply plugin: 'com.novoda.bintray-release'
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 30
|
buildFeatures {
|
||||||
|
aidl true
|
||||||
|
androidResources true
|
||||||
|
}
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
minSdkVersion 24
|
namespace "org.amnezia.vpn.shadowsocks.core"
|
||||||
targetSdkVersion 30
|
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0.0"
|
versionName "1.0.0"
|
||||||
|
|
||||||
|
|
@ -30,10 +33,6 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
androidExtensions {
|
|
||||||
experimental = true
|
|
||||||
}
|
|
||||||
|
|
||||||
//def lifecycleVersion = '2.0.0'
|
//def lifecycleVersion = '2.0.0'
|
||||||
def roomVersion = "2.4.3"
|
def roomVersion = "2.4.3"
|
||||||
//def preferencexVersion = '1.0.0'
|
//def preferencexVersion = '1.0.0'
|
||||||
|
|
@ -46,10 +45,9 @@ dependencies {
|
||||||
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0"
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0"
|
||||||
|
|
||||||
implementation "androidx.core:core-ktx:1.2.0"
|
implementation "androidx.core:core-ktx:1.2.0"
|
||||||
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
|
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1"
|
||||||
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0"
|
implementation "androidx.lifecycle:lifecycle-livedata-core-ktx:2.5.1"
|
||||||
implementation "androidx.lifecycle:lifecycle-livedata-core-ktx:2.4.0"
|
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1"
|
||||||
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
|
|
||||||
implementation "androidx.room:room-runtime:$roomVersion" // runtime
|
implementation "androidx.room:room-runtime:$roomVersion" // runtime
|
||||||
implementation "androidx.preference:preference:1.1.0"
|
implementation "androidx.preference:preference:1.1.0"
|
||||||
implementation "androidx.work:work-runtime-ktx:2.7.1"
|
implementation "androidx.work:work-runtime-ktx:2.7.1"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="org.amnezia.vpn.shadowsocks.core"
|
|
||||||
tools:ignore="MissingLeanbackLauncher">
|
tools:ignore="MissingLeanbackLauncher">
|
||||||
|
|
||||||
<uses-feature
|
<uses-feature
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@ class VpnRequestActivity : AppCompatActivity() {
|
||||||
Toast.makeText(this, R.string.vpn_permission_denied, Toast.LENGTH_LONG).show()
|
Toast.makeText(this, R.string.vpn_permission_denied, Toast.LENGTH_LONG).show()
|
||||||
}
|
}
|
||||||
finish()
|
finish()
|
||||||
|
super.onActivityResult(requestCode, resultCode, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroy() {
|
override fun onDestroy() {
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ import kotlinx.coroutines.channels.sendBlocking
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
import java.nio.ByteBuffer
|
import java.nio.ByteBuffer
|
||||||
import java.nio.channels.*
|
import java.nio.channels.*
|
||||||
|
import kotlinx.coroutines.channels.trySendBlocking
|
||||||
|
|
||||||
class ChannelMonitor : Thread("ChannelMonitor") {
|
class ChannelMonitor : Thread("ChannelMonitor") {
|
||||||
private data class Registration(val channel: SelectableChannel,
|
private data class Registration(val channel: SelectableChannel,
|
||||||
|
|
@ -52,7 +53,7 @@ class ChannelMonitor : Thread("ChannelMonitor") {
|
||||||
registerInternal(this, SelectionKey.OP_READ) {
|
registerInternal(this, SelectionKey.OP_READ) {
|
||||||
val junk = ByteBuffer.allocateDirect(1)
|
val junk = ByteBuffer.allocateDirect(1)
|
||||||
while (read(junk) > 0) {
|
while (read(junk) > 0) {
|
||||||
pendingRegistrations.poll()!!.apply {
|
pendingRegistrations.tryReceive().getOrNull()!!.apply {
|
||||||
try {
|
try {
|
||||||
result.complete(registerInternal(channel, ops, listener))
|
result.complete(registerInternal(channel, ops, listener))
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
|
@ -112,7 +113,7 @@ class ChannelMonitor : Thread("ChannelMonitor") {
|
||||||
(key.attachment() as (SelectionKey) -> Unit)(key)
|
(key.attachment() as (SelectionKey) -> Unit)(key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closeChannel.sendBlocking(Unit)
|
closeChannel.trySendBlocking(Unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun close(scope: CoroutineScope) {
|
fun close(scope: CoroutineScope) {
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,7 @@ import kotlinx.coroutines.channels.sendBlocking
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.IOException
|
import java.io.IOException
|
||||||
|
import kotlinx.coroutines.channels.trySendBlocking
|
||||||
|
|
||||||
abstract class LocalSocketListener(name: String, socketFile: File) : Thread(name) {
|
abstract class LocalSocketListener(name: String, socketFile: File) : Thread(name) {
|
||||||
private val localSocket = LocalSocket().apply {
|
private val localSocket = LocalSocket().apply {
|
||||||
|
|
@ -60,7 +61,7 @@ abstract class LocalSocketListener(name: String, socketFile: File) : Thread(name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
closeChannel.sendBlocking(Unit)
|
closeChannel.trySendBlocking(Unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun shutdown(scope: CoroutineScope) {
|
open fun shutdown(scope: CoroutineScope) {
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ public final class InetEndpoint {
|
||||||
private final boolean isResolved;
|
private final boolean isResolved;
|
||||||
private final Object lock = new Object();
|
private final Object lock = new Object();
|
||||||
private final int port;
|
private final int port;
|
||||||
private Instant lastResolution = Instant.EPOCH;
|
private long lastResolution;
|
||||||
@Nullable private InetEndpoint resolved;
|
@Nullable private InetEndpoint resolved;
|
||||||
|
|
||||||
private InetEndpoint(final String host, final boolean isResolved, final int port) {
|
private InetEndpoint(final String host, final boolean isResolved, final int port) {
|
||||||
|
|
@ -89,7 +89,7 @@ public final class InetEndpoint {
|
||||||
return Optional.of(this);
|
return Optional.of(this);
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
// TODO(zx2c4): Implement a real timeout mechanism using DNS TTL
|
// TODO(zx2c4): Implement a real timeout mechanism using DNS TTL
|
||||||
if (Duration.between(lastResolution, Instant.now()).toMinutes() > 1) {
|
if (System.currentTimeMillis() - lastResolution > 60000L) {
|
||||||
try {
|
try {
|
||||||
// Prefer v4 endpoints over v6 to work around DNS64 and IPv6 NAT issues.
|
// Prefer v4 endpoints over v6 to work around DNS64 and IPv6 NAT issues.
|
||||||
final InetAddress[] candidates = InetAddress.getAllByName(host);
|
final InetAddress[] candidates = InetAddress.getAllByName(host);
|
||||||
|
|
@ -101,7 +101,7 @@ public final class InetEndpoint {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
resolved = new InetEndpoint(address.getHostAddress(), true, port);
|
resolved = new InetEndpoint(address.getHostAddress(), true, port);
|
||||||
lastResolution = Instant.now();
|
lastResolution = System.currentTimeMillis();
|
||||||
} catch (final UnknownHostException e) {
|
} catch (final UnknownHostException e) {
|
||||||
resolved = null;
|
resolved = null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import android.content.Intent
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Parcel
|
import android.os.Parcel
|
||||||
import androidx.core.app.NotificationCompat
|
import androidx.core.app.NotificationCompat
|
||||||
|
import org.amnezia.vpn.shadowsocks.core.R
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
|
|
||||||
object NotificationUtil {
|
object NotificationUtil {
|
||||||
|
|
@ -102,7 +103,7 @@ object NotificationUtil {
|
||||||
val pendingIntent = PendingIntent.getActivity(service, 0, intent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
|
val pendingIntent = PendingIntent.getActivity(service, 0, intent, PendingIntent.FLAG_IMMUTABLE or PendingIntent.FLAG_UPDATE_CURRENT)
|
||||||
// Build our notification
|
// Build our notification
|
||||||
sNotificationBuilder?.let {
|
sNotificationBuilder?.let {
|
||||||
it.setSmallIcon(org.amnezia.vpn.R.drawable.ic_amnezia_round)
|
it.setSmallIcon(R.drawable.ic_amnezia_round)
|
||||||
.setContentTitle(header)
|
.setContentTitle(header)
|
||||||
.setContentText(message)
|
.setContentText(message)
|
||||||
.setOnlyAlertOnce(true)
|
.setOnlyAlertOnce(true)
|
||||||
|
|
|
||||||
|
|
@ -83,29 +83,32 @@ class OpenVPNThreadv3(var service: VPNService): ClientAPI_OpenVPNClient(), Runna
|
||||||
if (jsonVpnConfig.getString("protocol") == "cloak") {
|
if (jsonVpnConfig.getString("protocol") == "cloak") {
|
||||||
val cloakConfigJson: JSONObject = jsonVpnConfig.getJSONObject("cloak_config_data")
|
val cloakConfigJson: JSONObject = jsonVpnConfig.getJSONObject("cloak_config_data")
|
||||||
|
|
||||||
if (cloakConfigJson.keySet().contains("NumConn")) {
|
if (cloakConfigJson.has("NumConn")) {
|
||||||
cloakConfigJson.put("NumConn", 1)
|
cloakConfigJson.put("NumConn", 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cloakConfigJson.keySet().contains("ProxyMethod")) {
|
if (cloakConfigJson.has("ProxyMethod")) {
|
||||||
cloakConfigJson.put("ProxyMethod", "openvpn")
|
cloakConfigJson.put("ProxyMethod", "openvpn")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cloakConfigJson.keySet().contains("port")) {
|
if (cloakConfigJson.has("port")) {
|
||||||
val portValue = cloakConfigJson.get("port")
|
val portValue = cloakConfigJson.get("port")
|
||||||
cloakConfigJson.remove("port")
|
cloakConfigJson.remove("port")
|
||||||
cloakConfigJson.put("RemotePort", portValue)
|
cloakConfigJson.put("RemotePort", portValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cloakConfigJson.keySet().contains("remote")) {
|
if (cloakConfigJson.has("remote")) {
|
||||||
val hostValue = cloakConfigJson.get("remote")
|
val hostValue = cloakConfigJson.get("remote")
|
||||||
cloakConfigJson.remove("remote")
|
cloakConfigJson.remove("remote")
|
||||||
cloakConfigJson.put("RemoteHost", hostValue)
|
cloakConfigJson.put("RemoteHost", hostValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
val cloakConfig = Base64.getEncoder().encodeToString(
|
val cloakConfigData = jsonVpnConfig.getJSONObject("cloak_config_data").toString().toByteArray()
|
||||||
jsonVpnConfig.getJSONObject("cloak_config_data").toString().toByteArray()
|
val cloakConfig = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||||
)
|
Base64.getEncoder().encodeToString(cloakConfigData)
|
||||||
|
} else {
|
||||||
|
android.util.Base64.encodeToString(cloakConfigData, android.util.Base64.DEFAULT)
|
||||||
|
}
|
||||||
|
|
||||||
resultingConfig.append("\n<cloak>\n")
|
resultingConfig.append("\n<cloak>\n")
|
||||||
resultingConfig.append(cloakConfig)
|
resultingConfig.append(cloakConfig)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue