diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 41fac01c..485eec5e 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -32,7 +32,7 @@ jobs: uses: actions/setup-go@v2 if: steps.cache.outputs.cache-hit != 'true' with: - go-version: 1.16 + go-version: 1.17 - name: Native Build if: steps.cache.outputs.cache-hit != 'true' run: ./run lib core diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 960cf43d..64e5f6c1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,7 +45,7 @@ jobs: uses: actions/setup-go@v2 if: steps.cache.outputs.cache-hit != 'true' with: - go-version: 1.16 + go-version: 1.17 - name: Gradle cache uses: actions/cache@v2 if: steps.cache.outputs.cache-hit != 'true' diff --git a/app/src/main/java/io/nekohasekai/sagernet/ui/ConfigurationFragment.kt b/app/src/main/java/io/nekohasekai/sagernet/ui/ConfigurationFragment.kt index 8df78a73..fd1539ff 100644 --- a/app/src/main/java/io/nekohasekai/sagernet/ui/ConfigurationFragment.kt +++ b/app/src/main/java/io/nekohasekai/sagernet/ui/ConfigurationFragment.kt @@ -74,6 +74,7 @@ import io.nekohasekai.sagernet.ui.profile.* import io.nekohasekai.sagernet.widget.QRCodeDialog import io.nekohasekai.sagernet.widget.UndoSnackbarManager import kotlinx.coroutines.* +import libcore.Libcore import java.io.IOException import java.net.InetAddress import java.net.InetSocketAddress @@ -577,9 +578,6 @@ class ConfigurationFragment @JvmOverloads constructor( } val profiles = ConcurrentLinkedQueue(profilesUnfiltered) val testPool = newFixedThreadPoolContext(5, "Connection test pool") - val icmpTestMethod by lazy { - InetAddress::class.java.getDeclaredMethod("isReachableByICMP", Int::class.java) - } repeat(5) { testJobs.add(launch(testPool) { while (isActive) { @@ -623,14 +621,13 @@ class ConfigurationFragment @JvmOverloads constructor( } try { if (icmpPing) { - val start = SystemClock.elapsedRealtime() - val result = icmpTestMethod.invoke( - InetAddress.getByName(address), 5000 - ) as Boolean + val result = Libcore.icmpPing( + address, 5000 + ) if (!isActive) break - if (result) { + if (result != -1L) { profile.status = 1 - profile.ping = (SystemClock.elapsedRealtime() - start).toInt() + profile.ping = result.toInt() } else { profile.status = 2 profile.error = getString(R.string.connection_test_unreachable) @@ -643,7 +640,7 @@ class ConfigurationFragment @JvmOverloads constructor( val start = SystemClock.elapsedRealtime() socket.connect( InetSocketAddress( - address, profile.requireBean().serverPort + address, 7 ), 5000 ) if (!isActive) break @@ -652,7 +649,7 @@ class ConfigurationFragment @JvmOverloads constructor( test.update(profile) socket.close() } - } catch (e: IOException) { + } catch (e: Exception) { if (!isActive) break val message = e.readableMessage diff --git a/library/libcore b/library/libcore index cb1fa101..cbf5cda0 160000 --- a/library/libcore +++ b/library/libcore @@ -1 +1 @@ -Subproject commit cb1fa101946e511db09998ace14093256b65113f +Subproject commit cbf5cda0df2455dfc20e59da3351c33663c97189