CONECTA PRO v4.2.8版本的 MD5 值为:ad88cf9e66d8cdaae8c40233e50eb389
以下内容为反编译后的 DtVpnService.java 源代码,内容仅作参考
package com.sshlib.service;
import android.app.NotificationManager;
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.PowerManager;
import android.os.StrictMode;
import c8.k;
import com.bumptech.glide.e;
import d8.b;
import da.m;
import e8.d;
import e8.h;
import f8.c;
import f8.f;
import fa.e0;
import fa.v0;
import java.lang.ref.SoftReference;
import java.math.BigInteger;
import java.net.Inet6Address;
import java.net.InetAddress;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.Vector;
import k9.j;
import l9.l;
import p2.a;
import z8.b1;
public final class DtVpnService extends VpnService implements d {
public f f2924u;
public f8.d f2925v;
public b f2926w;
public ParcelFileDescriptor f2927x;
public PowerManager.WakeLock f2928y;
public final Vector f2921r = new Vector();
public final c f2922s = new c();
public final a f2923t = new a();
public final j f2929z = new j(d8.a.f3127u);
public final j A = new j(new e8.a(this, 0));
public final j B = new j(new e8.a(this, 1));
public final void a() {
f fVar = this.f2924u;
if (fVar != null) {
fVar.f4159k = false;
Process process = fVar.f4158j;
if (process != null) {
process.destroy();
}
ParcelFileDescriptor parcelFileDescriptor = fVar.f4150b;
if (parcelFileDescriptor != null) {
parcelFileDescriptor.close();
}
fVar.f4150b = null;
}
this.f2924u = null;
f8.d dVar = this.f2925v;
if (dVar != null) {
dVar.f4144h = false;
}
this.f2925v = null;
try {
ParcelFileDescriptor parcelFileDescriptor2 = this.f2927x;
if (parcelFileDescriptor2 != null) {
if (parcelFileDescriptor2 != null) {
parcelFileDescriptor2.close();
} else {
b1.V("iFace");
throw null;
}
}
} catch (Exception e10) {
e10.printStackTrace();
}
}
public final void b() {
a aVar;
boolean z10;
b bVar;
boolean z11;
String str;
b bVar2;
String str2;
ParcelFileDescriptor establish;
Integer num;
Integer num2;
Object obj;
String str3;
String str4;
boolean z12;
boolean z13;
boolean z14;
VpnService.Builder builder = new VpnService.Builder(this);
if (Build.VERSION.SDK_INT >= 29) {
builder.setMetered(false);
}
builder.addAddress("172.16.0.1", 12);
b bVar3 = this.f2926w;
b1.l(bVar3);
String d10 = bVar3.a().d();
f8.a aVar2 = new f8.a("0.0.0.0", 0);
c cVar = this.f2922s;
cVar.a(aVar2, true);
cVar.a(new f8.a("10.0.0.0", 8), false);
cVar.a(new f8.a("192.168.0.1", 16), false);
cVar.a(new f8.a("172.16.0.0", 12), false);
InetAddress byName = InetAddress.getByName(d10);
boolean z15 = byName instanceof Inet6Address;
TreeSet treeSet = cVar.f4136a;
if (z15) {
Inet6Address inet6Address = (Inet6Address) byName;
b1.o("address", inet6Address);
treeSet.add(new f8.b(inet6Address));
} else {
cVar.a(new f8.a(d10, 32), false);
}
f8.b bVar4 = new f8.b(new f8.a("224.0.0.0", 3), true);
PriorityQueue priorityQueue = new PriorityQueue((SortedSet) treeSet);
TreeSet treeSet2 = new TreeSet();
f8.b bVar5 = (f8.b) priorityQueue.poll();
int i10 = -1;
if (bVar5 != null) {
while (bVar5 != null) {
f8.b bVar6 = (f8.b) priorityQueue.poll();
if (bVar6 != null) {
BigInteger c10 = bVar5.c();
b1.l(c10);
BigInteger a10 = bVar6.a();
b1.l(a10);
if (c10.compareTo(a10) != i10) {
boolean g10 = b1.g(bVar5.a(), bVar6.a());
boolean z16 = bVar5.f4130r;
int i11 = bVar6.f4131s;
boolean z17 = bVar6.f4130r;
if (g10 && bVar5.f4131s >= i11) {
if (z16 != z17) {
f8.b[] e10 = bVar6.e();
if (!priorityQueue.contains(e10[1])) {
priorityQueue.add(e10[1]);
}
if (!b1.g(e10[0].c(), bVar5.c()) && !priorityQueue.contains(e10[0])) {
priorityQueue.add(e10[0]);
}
}
bVar5 = bVar6;
} else if (z16 != z17) {
f8.b[] e11 = bVar5.e();
f8.b bVar7 = e11[1];
if (bVar7.f4131s != i11) {
priorityQueue.add(bVar7);
}
priorityQueue.add(bVar6);
bVar5 = e11[0];
}
i10 = -1;
}
}
treeSet2.add(bVar5);
bVar5 = bVar6;
i10 = -1;
}
}
Vector vector = new Vector();
Iterator it = treeSet2.iterator();
while (it.hasNext()) {
f8.b bVar8 = (f8.b) it.next();
if (bVar8.f4130r) {
vector.add(bVar8);
}
}
Iterator it2 = vector.iterator();
while (true) {
boolean hasNext = it2.hasNext();
aVar = this.f2923t;
if (!hasNext) {
break;
}
f8.b bVar9 = (f8.b) it2.next();
try {
b1.o("network", bVar9);
BigInteger a11 = bVar4.a();
BigInteger c11 = bVar4.c();
BigInteger a12 = bVar9.a();
BigInteger c12 = bVar9.c();
b1.l(a11);
b1.l(a12);
if (a11.compareTo(a12) != 1) {
z12 = true;
} else {
z12 = false;
}
b1.l(c11);
b1.l(c12);
if (c11.compareTo(c12) != -1) {
z13 = true;
} else {
z13 = false;
}
if (z12 && z13) {
z14 = true;
} else {
z14 = false;
}
if (!z14) {
try {
builder.addRoute(bVar9.b(), bVar9.f4131s);
} catch (IllegalArgumentException unused) {
aVar.c("LBL_ROUTES_INFO_EXCL", bVar9.b());
}
}
} catch (IllegalArgumentException unused2) {
}
}
b bVar10 = this.f2926w;
Vector vector2 = this.f2921r;
String str5 = null;
if (bVar10 != null && (str4 = bVar10.f3137f) != null) {
if (!(!b1.g(str4, "0.0.0.0"))) {
str4 = null;
}
if (str4 != null) {
builder.addDnsServer(str4);
if (!(InetAddress.getByName(str4) instanceof Inet6Address)) {
vector2.add(str4);
cVar.a(new f8.a(str4, 32), true);
z10 = true;
bVar = this.f2926w;
if (bVar != null && (str3 = bVar.f3138g) != null) {
if (!(!b1.g(str3, "0.0.0.0"))) {
str3 = null;
}
if (str3 != null) {
builder.addDnsServer(str3);
if (!(InetAddress.getByName(str3) instanceof Inet6Address)) {
vector2.add(str3);
cVar.a(new f8.a(str3, 32), true);
z11 = true;
if (z11) {
str = "LBL_DNS_FORWARDING_ENABLED";
} else {
str = "LBL_DNS_FORWARDING_DISABLED";
}
aVar.c(str, new Object[0]);
aVar.c("LBL_LOCAL_IP_INFO", "172.16.0.1", 12, 1500);
if (!vector2.isEmpty()) {
aVar.c("LBL_DNS_SERVER_INFO", l.x(vector2, ", ", null, null, null, 62));
}
aVar.c("LBL_ROUTES_INFO_INCL", l.x(cVar.b(true), ", ", null, null, null, 62));
aVar.c("LBL_ROUTES_INFO_EXCL", m.F0(l.x(cVar.b(false), ", ", null, null, null, 62), d10, "***", false));
builder.setMtu(1500);
bVar2 = this.f2926w;
if (bVar2 != null) {
str2 = bVar2.f3132a;
} else {
str2 = null;
}
b1.l(str2);
builder.setSession(str2);
establish = builder.establish();
if (establish != null) {
this.f2927x = establish;
if (this.f2926w == null) {
a();
return;
}
StringBuilder sb2 = new StringBuilder("127.0.0.1:");
b bVar11 = this.f2926w;
if (bVar11 != null) {
num = Integer.valueOf(((Number) bVar11.f3141j.getValue()).intValue());
} else {
num = null;
}
b1.l(num);
sb2.append(num.intValue());
String sb3 = sb2.toString();
StringBuilder sb4 = new StringBuilder("127.0.0.1:");
b bVar12 = this.f2926w;
if (bVar12 != null) {
List list = bVar12.f3140i;
y9.c cVar2 = y9.d.f10720r;
b1.o("<this>", list);
b1.o("random", cVar2);
if (!list.isEmpty()) {
List list2 = list;
int c13 = cVar2.c(list.size());
boolean z18 = list2 instanceof List;
if (z18) {
obj = list2.get(c13);
} else {
t7.a aVar3 = new t7.a(c13, 1);
if (z18) {
List list3 = list2;
if (c13 >= 0 && c13 <= t5.b.d(list3)) {
obj = list3.get(c13);
}
obj = aVar3.k(Integer.valueOf(c13));
} else {
if (c13 >= 0) {
int i12 = 0;
for (Object obj2 : list2) {
int i13 = i12 + 1;
if (c13 == i12) {
obj = obj2;
break;
}
i12 = i13;
}
}
obj = aVar3.k(Integer.valueOf(c13));
}
}
num2 = Integer.valueOf(((Number) obj).intValue());
} else {
throw new NoSuchElementException("Collection is empty.");
}
} else {
num2 = null;
}
b1.l(num2);
sb4.append(num2.intValue());
String sb5 = sb4.toString();
if (z11) {
f8.d dVar = new f8.d(this, (String[]) vector2.toArray(new String[0]));
this.f2925v = dVar;
dVar.a();
str5 = "172.16.0.1:5502";
}
f fVar = new f(this, establish, sb3, sb5, str5, z11);
this.f2924u = fVar;
fVar.b();
return;
}
throw new IllegalStateException("Failed to establish VPN connection");
}
}
}
z11 = z10;
if (z11) {
}
aVar.c(str, new Object[0]);
aVar.c("LBL_LOCAL_IP_INFO", "172.16.0.1", 12, 1500);
if (!vector2.isEmpty()) {
}
aVar.c("LBL_ROUTES_INFO_INCL", l.x(cVar.b(true), ", ", null, null, null, 62));
aVar.c("LBL_ROUTES_INFO_EXCL", m.F0(l.x(cVar.b(false), ", ", null, null, null, 62), d10, "***", false));
builder.setMtu(1500);
bVar2 = this.f2926w;
if (bVar2 != null) {
}
b1.l(str2);
builder.setSession(str2);
establish = builder.establish();
if (establish != null) {
}
}
}
}
z10 = false;
bVar = this.f2926w;
if (bVar != null) {
if (!(!b1.g(str3, "0.0.0.0"))) {
}
if (str3 != null) {
}
}
z11 = z10;
if (z11) {
}
aVar.c(str, new Object[0]);
aVar.c("LBL_LOCAL_IP_INFO", "172.16.0.1", 12, 1500);
if (!vector2.isEmpty()) {
}
aVar.c("LBL_ROUTES_INFO_INCL", l.x(cVar.b(true), ", ", null, null, null, 62));
aVar.c("LBL_ROUTES_INFO_EXCL", m.F0(l.x(cVar.b(false), ", ", null, null, null, 62), d10, "***", false));
builder.setMtu(1500);
bVar2 = this.f2926w;
if (bVar2 != null) {
}
b1.l(str2);
builder.setSession(str2);
establish = builder.establish();
if (establish != null) {
}
}
public final void c(b bVar) {
Vector vector = this.f2921r;
c cVar = this.f2922s;
this.f2926w = bVar;
a aVar = this.f2923t;
aVar.c("LBL_OPENING_INTERFACE_TUN", new Object[0]);
try {
try {
b();
} catch (Exception e10) {
aVar.c("LBL_ERROR_INTERFACE_TUN", new Object[0]);
Object[] objArr = new Object[1];
String message = e10.getMessage();
if (message == null) {
message = "Failed to create TUN interface";
}
objArr[0] = message;
aVar.c("LBL_ERROR", objArr);
throw e10;
}
} finally {
cVar.f4136a.clear();
vector.clear();
}
}
public final void d() {
d dVar;
boolean z10;
if (Build.VERSION.SDK_INT >= 28) {
try {
((ConnectivityManager) this.A.getValue()).unregisterNetworkCallback((e8.c) this.B.getValue());
} catch (Exception e10) {
e10.printStackTrace();
}
}
this.f2926w = null;
a();
SoftReference softReference = VpnServiceManager.f2930a;
if (softReference != null && (dVar = (d) softReference.get()) != null) {
DtVpnService dtVpnService = (DtVpnService) dVar;
a aVar = VpnServiceManager.f2932c;
aVar.c("LBL_STATE_STOPPING", new Object[0]);
o2.a.c(o2.a.D, dtVpnService);
b bVar = VpnServiceManager.f2934e;
if (bVar != null) {
z10 = true;
}
z10 = false;
if (z10) {
aVar.c("LBL_PING_STOPPED", new Object[0]);
VpnServiceManager.f2931b.c();
}
VpnServiceManager.f2934e = null;
VpnServiceManager.f2939j = false;
c8.m mVar = VpnServiceManager.f2935f;
if (mVar != null) {
mVar.f1852h = null;
}
if (mVar != null) {
mVar.f1851g = null;
}
if (mVar != null) {
mVar.f1853i = c8.a.f1813u;
com.bumptech.glide.f.q(e.a(e0.f4188a), null, new k(mVar, null), 3);
}
VpnServiceManager.f2935f = null;
v0 v0Var = VpnServiceManager.f2938i;
if (v0Var != null) {
b1.j(v0Var);
}
com.bumptech.glide.f.q(e.a(e0.f4188a), null, new h(dtVpnService, null), 3);
e8.e eVar = VpnServiceManager.f2937h;
if (eVar != null) {
dtVpnService.unregisterReceiver(eVar);
VpnServiceManager.f2937h = null;
}
}
stopSelf();
}
@Override
public final void onCreate() {
super.onCreate();
SoftReference softReference = VpnServiceManager.f2930a;
VpnServiceManager.f2930a = new SoftReference(this);
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build());
Object systemService = getSystemService("power");
b1.m("null cannot be cast to non-null type android.os.PowerManager", systemService);
PowerManager.WakeLock newWakeLock = ((PowerManager) systemService).newWakeLock(1, "DTunnelVPN:tag");
b1.n("newWakeLock(...)", newWakeLock);
this.f2928y = newWakeLock;
newWakeLock.acquire();
}
@Override
public final void onDestroy() {
super.onDestroy();
SoftReference softReference = VpnServiceManager.f2930a;
Object systemService = getSystemService("notification");
b1.m("null cannot be cast to non-null type android.app.NotificationManager", systemService);
((NotificationManager) systemService).cancel(1663);
stopForeground(true);
VpnServiceManager.f2936g = null;
PowerManager.WakeLock wakeLock = this.f2928y;
if (wakeLock != null) {
if (wakeLock.isHeld()) {
PowerManager.WakeLock wakeLock2 = this.f2928y;
if (wakeLock2 != null) {
wakeLock2.release();
return;
} else {
b1.V("wakeLock");
throw null;
}
}
return;
}
b1.V("wakeLock");
throw null;
}
@Override
public final void onRevoke() {
d();
}
@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();
return 2;
}
if (Build.VERSION.SDK_INT >= 28) {
try {
((ConnectivityManager) this.A.getValue()).requestNetwork((NetworkRequest) this.f2929z.getValue(), (e8.c) this.B.getValue());
} catch (Exception e10) {
e10.printStackTrace();
}
}
SoftReference softReference = VpnServiceManager.f2930a;
VpnServiceManager.b();
return 1;
}
}