Skip to content

Commit bb9d7e7

Browse files
author
uoosef
committed
fix connection intrupt issue, better connection state handling
1 parent 1b6a707 commit bb9d7e7

File tree

4 files changed

+5
-46
lines changed

4 files changed

+5
-46
lines changed

app/build.gradle

+2-3
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ android {
1111
applicationId "org.bepass.oblivion"
1212
minSdk 21
1313
targetSdk 34
14-
versionCode 8
15-
versionName "1.7"
14+
versionCode 9
15+
versionName "1.8"
1616

1717
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1818
vectorDrawables {
@@ -49,7 +49,6 @@ dependencies {
4949
implementation 'androidx.appcompat:appcompat:1.6.1'
5050
implementation 'com.google.android.material:material:1.11.0'
5151
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
52-
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
5352
implementation 'com.github.zcweng:switch-button:0.0.3@aar'
5453
implementation fileTree(dir: 'libs', include: ['*.aar', '*.jar'])
5554
}

app/libs/go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ replace github.com/Psiphon-Labs/psiphon-tunnel-core => github.com/uoosef/psiphon
77
replace github.com/eycorsican/go-tun2socks => github.com/trojan-gfw/go-tun2socks v1.16.3-0.20210702214000-083d49176e05
88

99
require (
10-
github.com/bepass-org/wireguard-go v1.0.2-rc1
10+
github.com/bepass-org/wireguard-go v1.0.3-rc2
1111
github.com/eycorsican/go-tun2socks v1.16.11
1212
github.com/songgao/water v0.0.0-20200317203138-2b4b6d7c09d8
1313
github.com/xjasonlyu/tun2socks/v2 v2.5.2

app/src/main/java/org/bepass/oblivion/OblivionVpnService.java

+1-41
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,15 @@
2323
import androidx.core.app.NotificationCompat;
2424
import androidx.core.app.NotificationManagerCompat;
2525

26-
import okhttp3.OkHttpClient;
27-
import okhttp3.Request;
28-
import okhttp3.Response;
2926
import tun2socks.Tun2socks;
3027
import tun2socks.StartOptions;
3128

3229
import java.io.FileOutputStream;
3330
import java.io.IOException;
3431
import java.lang.ref.WeakReference;
35-
import java.net.InetSocketAddress;
36-
import java.net.Proxy;
3732
import java.net.ServerSocket;
3833
import java.util.HashMap;
3934
import java.util.Map;
40-
import java.util.Objects;
41-
import java.util.concurrent.TimeUnit;
4235

4336
public class OblivionVpnService extends VpnService {
4437
private static final String TAG = "oblivionVPN";
@@ -135,39 +128,6 @@ public static Map<String, Integer> splitHostAndPort(String hostPort) {
135128
return result;
136129
}
137130

138-
139-
public static String pingOverHTTP(String bindAddress) {
140-
Map<String, Integer> result = splitHostAndPort(bindAddress);
141-
if (result == null) {
142-
return "exception";
143-
}
144-
String socksHost = result.keySet().iterator().next();
145-
int socksPort = result.values().iterator().next();
146-
147-
// Set up the SOCKS proxy
148-
Proxy proxy = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(socksHost, socksPort));
149-
150-
// Create OkHttpClient with SOCKS proxy
151-
OkHttpClient client = new OkHttpClient.Builder()
152-
.proxy(proxy)
153-
.connectTimeout(5, TimeUnit.SECONDS) // 5 seconds connection timeout
154-
.readTimeout(5, TimeUnit.SECONDS) // 5 seconds read timeout
155-
.build();
156-
157-
// Build the request
158-
Request request = new Request.Builder()
159-
.url("https://1.1.1.1") // Replace with actual URL
160-
.build();
161-
162-
// Execute the request
163-
try (Response response = client.newCall(request).execute()) {
164-
return response.isSuccessful() ? "true" : "false";
165-
} catch (IOException e) {
166-
//e.printStackTrace();
167-
return Objects.requireNonNull(e.getMessage()).contains("ECONNREFUSED") || e.getMessage().contains("general failure") || e.getMessage().contains("timed out") ? "false" : "exception";
168-
}
169-
}
170-
171131
private static int findFreePort() {
172132
ServerSocket socket = null;
173133
try {
@@ -473,7 +433,7 @@ private void createNotification() {
473433
this, 2, new Intent(this, MainActivity.class), PendingIntent.FLAG_IMMUTABLE);
474434
notification = new NotificationCompat.Builder(this, notificationChannel.getId())
475435
.setContentTitle("Vpn service")
476-
.setContentText("Testing Tun2Socks")
436+
.setContentText("Oblivion WARP")
477437
.setSmallIcon(R.mipmap.ic_launcher)
478438
.setOnlyAlertOnce(true)
479439
.setOngoing(true)

app/src/main/res/layout/activity_info.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
android:fontFamily="@font/shabnam"
9797
android:textColor="@color/black"
9898
android:gravity="center"
99-
android:text="App Version: 0.0.7-test" />
99+
android:text="App Version: 0.0.8-test" />
100100

101101

102102
</LinearLayout>

0 commit comments

Comments
 (0)