CONECTA PRO v4.2.8版本的 MD5 值为:ad88cf9e66d8cdaae8c40233e50eb389
以下内容为反编译后的 V2RayVpnService.java 源代码,内容仅作参考
package com.v2ray.ang.service;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkRequest;
import android.net.VpnService;
import android.os.Build;
import android.os.ParcelFileDescriptor;
import android.os.StrictMode;
import android.util.Log;
import com.bumptech.glide.e;
import com.bumptech.glide.f;
import com.google.android.gms.internal.measurement.m4;
import com.v2ray.ang.dto.ServerConfig;
import da.m;
import fa.e0;
import fa.o0;
import go.Seq;
import j.i0;
import java.io.File;
import java.io.FileDescriptor;
import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.Iterator;
import k9.j;
import l9.h;
import l9.l;
import libv2ray.Libv2ray;
import libv2ray.V2RayPoint;
import s8.a;
import s8.c;
import s8.d;
import t5.b;
import z8.b1;
public final class V2RayVpnService extends VpnService implements a {
public Process f2975s;
public ParcelFileDescriptor f2976t;
public final p2.a f2974r = new p2.a();
public final j f2977u = new j(d8.a.f3130x);
public final j f2978v = new j(new c(this, 0));
public final j f2979w = new j(new c(this, 1));
public final void a() {
Process start;
try {
ProcessBuilder processBuilder = new ProcessBuilder(b.a(new File(getApplicationContext().getApplicationInfo().nativeLibraryDir, "libtun2socks.so").getAbsolutePath(), "--netif-ipaddr", "26.26.26.2", "--netif-netmask", "255.255.255.252", "--socks-server-addr", i0.n("127.0.0.1:", Integer.parseInt("10808")), "--tunmtu", "1500", "--sock-path", "sock_path", "--enable-udprelay", "--loglevel", "notice"));
processBuilder.redirectErrorStream(true);
start = processBuilder.directory(getApplicationContext().getFilesDir()).start();
b1.n("start(...)", start);
} catch (Exception e10) {
e = e10;
}
try {
this.f2975s = start;
b();
} catch (Exception e11) {
e = e11;
e.printStackTrace();
}
}
public final void b() {
ParcelFileDescriptor parcelFileDescriptor = this.f2976t;
if (parcelFileDescriptor != null) {
FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
f.q(e.a(e0.f4189b), null, new s8.e(new File(getApplicationContext().getFilesDir(), "sock_path").getAbsolutePath(), fileDescriptor, null), 3);
return;
}
b1.V("mInterface");
throw null;
}
public final void c() {
String str;
ParcelFileDescriptor parcelFileDescriptor;
if (VpnService.prepare(this) == null) {
p2.a aVar = this.f2974r;
aVar.c("LBL_OPENING_INTERFACE_TUN", new Object[0]);
VpnService.Builder builder = new VpnService.Builder(this);
if (Build.VERSION.SDK_INT >= 29) {
builder.setMetered(false);
}
builder.setMtu(1500);
builder.addAddress("26.26.26.1", 30);
builder.addRoute("0.0.0.0", 0);
aVar.c("LBL_LOCAL_IP_INFO", "26.26.26.1", 30, 1500);
ArrayList arrayList = new ArrayList();
for (Object obj : m.K0("1.1.1.1,1.0.0.1", new String[]{","}, 0, 6)) {
if (z4.a.k((String) obj)) {
arrayList.add(obj);
}
}
Iterator it = arrayList.iterator();
while (it.hasNext()) {
String str2 = (String) it.next();
if (z4.a.k(str2)) {
builder.addDnsServer(str2);
}
}
aVar.c("LBL_DNS_SERVER_INFO", l.x(arrayList, ", ", null, null, null, 62));
aVar.c("LBL_ROUTES_INFO_INCL", h.h0(new String[]{"0.0.0.0"}, ", ", 62));
ServerConfig serverConfig = V2RayServiceManager.f2969d;
if (serverConfig != null) {
str = serverConfig.getRemarks();
} else {
str = null;
}
if (str == null) {
str = "";
}
builder.setSession(str);
try {
parcelFileDescriptor = this.f2976t;
} catch (Throwable th) {
m4.f(th);
}
if (parcelFileDescriptor != null) {
parcelFileDescriptor.close();
if (Build.VERSION.SDK_INT >= 28) {
try {
((ConnectivityManager) this.f2978v.getValue()).requestNetwork((NetworkRequest) this.f2977u.getValue(), (d) this.f2979w.getValue());
} catch (Exception e10) {
e10.printStackTrace();
}
}
try {
ParcelFileDescriptor establish = builder.establish();
b1.l(establish);
this.f2976t = establish;
a();
return;
} catch (Exception unused) {
d(true);
return;
}
}
b1.V("mInterface");
throw null;
}
}
public final void d(boolean z10) {
a aVar;
Process process;
if (Build.VERSION.SDK_INT >= 28) {
try {
((ConnectivityManager) this.f2978v.getValue()).unregisterNetworkCallback((d) this.f2979w.getValue());
} catch (Throwable th) {
m4.f(th);
}
}
try {
Log.d(getPackageName(), "tun2socks destroy");
process = this.f2975s;
} catch (Exception e10) {
Log.d(getPackageName(), e10.toString());
}
if (process != null) {
process.destroy();
SoftReference softReference = V2RayServiceManager.f2968c;
if (softReference != null && (aVar = (a) softReference.get()) != null) {
V2RayVpnService v2RayVpnService = (V2RayVpnService) aVar;
if (V2RayServiceManager.f2966a.getIsRunning()) {
f.q(o0.f4216r, e0.f4188a, new s8.b(null), 2);
}
V2RayServiceManager.a();
try {
V2RayServiceManager.f2972g.c();
v2RayVpnService.unregisterReceiver(V2RayServiceManager.f2967b);
o2.a.E.b(v2RayVpnService, "");
} catch (Throwable th2) {
m4.f(th2);
}
}
if (z10) {
stopSelf();
try {
ParcelFileDescriptor parcelFileDescriptor = this.f2976t;
if (parcelFileDescriptor != null) {
parcelFileDescriptor.close();
return;
} else {
b1.V("mInterface");
throw null;
}
} catch (Throwable th3) {
m4.f(th3);
return;
}
}
return;
}
b1.V("process");
throw null;
}
@Override
public final void onCreate() {
Context context;
String absolutePath;
super.onCreate();
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build());
V2RayPoint v2RayPoint = V2RayServiceManager.f2966a;
SoftReference softReference = new SoftReference(this);
V2RayServiceManager.f2968c = softReference;
a aVar = (a) softReference.get();
V2RayVpnService v2RayVpnService = null;
if (aVar != null) {
context = ((V2RayVpnService) aVar).getApplicationContext();
} else {
context = null;
}
Seq.setContext(context);
a aVar2 = (a) softReference.get();
if (aVar2 != null) {
v2RayVpnService = (V2RayVpnService) aVar2;
}
if (v2RayVpnService == null) {
absolutePath = "";
} else {
File externalFilesDir = v2RayVpnService.getExternalFilesDir("assets");
if (externalFilesDir == null) {
absolutePath = v2RayVpnService.getDir("assets", 0).getAbsolutePath();
} else {
absolutePath = externalFilesDir.getAbsolutePath();
}
b1.n("getAbsolutePath(...)", absolutePath);
}
Libv2ray.initV2Env(absolutePath);
}
@Override
public final void onDestroy() {
super.onDestroy();
V2RayServiceManager.a();
}
@Override
public final void onLowMemory() {
d(true);
super.onLowMemory();
}
@Override
public final void onRevoke() {
d(true);
}
@Override
public final int onStartCommand(Intent intent, int i10, int i11) {
String str;
if (intent != null) {
str = intent.getAction();
} else {
str = null;
}
if (b1.g(str, "STOP_VPN_SERVICE")) {
d(true);
return 2;
}
o2.a aVar = o2.a.f7839w;
Context applicationContext = getApplicationContext();
b1.n("getApplicationContext(...)", applicationContext);
aVar.b(applicationContext, "");
V2RayServiceManager.b();
return 1;
}
}