GOUTY SSH V2 🌐 v4.2.5版本的 MD5 值为:635449b1ebcf1b9e08b24bdcbf1c404a
以下内容为反编译后的 V2RayVpnService.java 源代码,内容仅作参考
package com.v2ray.ang.service;
import a4.d;
import a4.o;
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.v2ray.ang.dto.ServerConfig;
import com.v2ray.ang.dto.V2rayConfig;
import ea.r1;
import go.Seq;
import ic.n;
import java.io.File;
import java.io.FileDescriptor;
import java.lang.ref.SoftReference;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import k9.i;
import k9.k;
import kc.c0;
import kc.c1;
import kc.i1;
import kc.w;
import kotlin.Metadata;
import libv2ray.Libv2ray;
import libv2ray.V2RayPoint;
import o9.f;
import o9.j;
import s8.a;
import s8.b;
import s8.c;
import s8.e;
@Metadata(d1 = {"\u0000\u0010\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\u0018\u00002\u00020\u00012\u00020\u0002:\u0001\u0005B\u0007¢\u0006\u0004\b\u0003\u0010\u0004¨\u0006\u0006"}, d2 = {"Lcom/v2ray/ang/service/V2RayVpnService;", "Landroid/net/VpnService;", "Ls8/a;", "<init>", "()V", "k7/g", "v2rayLib_release"}, k = 1, mv = {1, V2rayConfig.DEFAULT_LEVEL, 0})
public final class V2RayVpnService extends VpnService implements a {
public Process f3258x;
public ParcelFileDescriptor f3259y;
public final m2.a f3257w = new m2.a();
public final k f3260z = new k(d.D);
public final k A = new k(new c(this, 0));
public final k B = new k(new c(this, 1));
public final void a() {
Process start;
try {
ProcessBuilder processBuilder = new ProcessBuilder(w.c(new File(getApplicationContext().getApplicationInfo().nativeLibraryDir, "libtun2socks.so").getAbsolutePath(), "--netif-ipaddr", "26.26.26.2", "--netif-netmask", "255.255.255.252", "--socks-server-addr", o.i("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();
f.k("proBuilder.directory(app…Context.filesDir).start()", start);
} catch (Exception e10) {
e = e10;
}
try {
this.f3258x = start;
b();
} catch (Exception e11) {
e = e11;
e.printStackTrace();
}
}
public final void b() {
ParcelFileDescriptor parcelFileDescriptor = this.f3259y;
if (parcelFileDescriptor == null) {
f.d0("mInterface");
throw null;
}
FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
f.K(r1.a(c0.f6820b), null, new e(new File(getApplicationContext().getFilesDir(), "sock_path").getAbsolutePath(), fileDescriptor, null), 3);
}
public final void c() {
ParcelFileDescriptor parcelFileDescriptor;
if (VpnService.prepare(this) != null) {
return;
}
m2.a aVar = this.f3257w;
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);
List w02 = n.w0("1.1.1.1,1.0.0.1", new String[]{","}, 0, 6);
ArrayList arrayList = new ArrayList();
for (Object obj : w02) {
if (f.I((String) obj)) {
arrayList.add(obj);
}
}
Iterator it = arrayList.iterator();
while (it.hasNext()) {
String str = (String) it.next();
if (f.I(str)) {
builder.addDnsServer(str);
}
}
aVar.c("LBL_DNS_SERVER_INFO", l9.o.M0(arrayList, ", ", null, null, null, 62));
aVar.c("LBL_ROUTES_INFO_INCL", l9.k.b0(new String[]{"0.0.0.0"}, ", ", null, null, null, 62));
ServerConfig serverConfig = V2RayServiceManager.f3253d;
String remarks = serverConfig != null ? serverConfig.getRemarks() : null;
if (remarks == null) {
remarks = "";
}
builder.setSession(remarks);
try {
parcelFileDescriptor = this.f3259y;
} catch (Throwable th) {
i.l(th);
}
if (parcelFileDescriptor == null) {
f.d0("mInterface");
throw null;
}
parcelFileDescriptor.close();
if (Build.VERSION.SDK_INT >= 28) {
try {
((ConnectivityManager) this.A.getValue()).requestNetwork((NetworkRequest) this.f3260z.getValue(), (s8.d) this.B.getValue());
} catch (Exception e10) {
e10.printStackTrace();
}
}
try {
ParcelFileDescriptor establish = builder.establish();
f.i(establish);
this.f3259y = establish;
a();
} catch (Exception unused) {
d(true);
}
}
public final void d(boolean z10) {
a aVar;
Process process;
if (Build.VERSION.SDK_INT >= 28) {
try {
((ConnectivityManager) this.A.getValue()).unregisterNetworkCallback((s8.d) this.B.getValue());
} catch (Throwable th) {
i.l(th);
}
}
try {
Log.d(getPackageName(), "tun2socks destroy");
process = this.f3258x;
} catch (Exception e10) {
Log.d(getPackageName(), e10.toString());
}
if (process == null) {
f.d0("process");
throw null;
}
process.destroy();
SoftReference softReference = V2RayServiceManager.f3252c;
if (softReference != null && (aVar = (a) softReference.get()) != null) {
V2RayVpnService v2RayVpnService = (V2RayVpnService) aVar;
if (V2RayServiceManager.f3250a.getIsRunning()) {
o9.i iVar = c0.f6819a;
b bVar = new b(null);
int i10 = 2 & 1;
o9.i iVar2 = j.f8296w;
if (i10 != 0) {
iVar = iVar2;
}
int i11 = (2 & 2) != 0 ? 1 : 0;
o9.i r10 = com.bumptech.glide.f.r(iVar2, iVar, true);
qc.d dVar = c0.f6819a;
if (r10 != dVar && r10.c(i0.a.K) == null) {
r10 = r10.V(dVar);
}
if (i11 == 0) {
throw null;
}
kc.a c1Var = i11 == 2 ? new c1(r10, bVar) : new i1(r10, true);
c1Var.R(i11, c1Var, bVar);
}
V2RayServiceManager.a();
try {
v2RayVpnService.unregisterReceiver(V2RayServiceManager.f3251b);
V2RayServiceManager.f3255f.c("LBL_DISCONNECTED", new Object[0]);
l2.a.I.b(v2RayVpnService);
} catch (Throwable th2) {
i.l(th2);
}
}
if (z10) {
stopSelf();
try {
ParcelFileDescriptor parcelFileDescriptor = this.f3259y;
if (parcelFileDescriptor != null) {
parcelFileDescriptor.close();
} else {
f.d0("mInterface");
throw null;
}
} catch (Throwable th3) {
i.l(th3);
}
}
}
@Override
public final void onCreate() {
String absolutePath;
String str;
super.onCreate();
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build());
V2RayPoint v2RayPoint = V2RayServiceManager.f3250a;
SoftReference softReference = new SoftReference(this);
V2RayServiceManager.f3252c = softReference;
a aVar = (a) softReference.get();
Seq.setContext(aVar != null ? ((V2RayVpnService) aVar).getApplicationContext() : null);
a aVar2 = (a) softReference.get();
V2RayVpnService v2RayVpnService = aVar2 != null ? (V2RayVpnService) aVar2 : null;
if (v2RayVpnService == null) {
absolutePath = "";
} else {
File externalFilesDir = v2RayVpnService.getExternalFilesDir("assets");
if (externalFilesDir == null) {
absolutePath = v2RayVpnService.getDir("assets", 0).getAbsolutePath();
str = "context.getDir(AppConfig…R_ASSETS, 0).absolutePath";
} else {
absolutePath = externalFilesDir.getAbsolutePath();
str = "extDir.absolutePath";
}
f.k(str, 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) {
if (f.d(intent != null ? intent.getAction() : null, "STOP_VPN_SERVICE")) {
d(true);
return 2;
}
l2.a aVar = l2.a.A;
Context applicationContext = getApplicationContext();
f.k("applicationContext", applicationContext);
aVar.b(applicationContext);
V2RayServiceManager.b();
return 1;
}
}