WroldPass Free VPN v2.0.3版本的 MD5 值为:a0f41ee97c0f84f39f29d3a80e386a29
以下内容为反编译后的 TunService.java 源代码,内容仅作参考
package com.worldpass.app.vpn.service;
import android.app.PendingIntent;
import android.content.Intent;
import android.net.Network;
import android.net.ProxyInfo;
import android.net.VpnService;
import android.os.Build;
import android.os.ParcelFileDescriptor;
import android.util.Log;
import com.worldpass.app.vpn.core.bridge.Bridge;
import com.worldpass.app.vpn.service.StatusProvider;
import defpackage.ge;
import defpackage.h;
import defpackage.lq0;
import defpackage.ok0;
import defpackage.tl0;
import defpackage.xb;
import java.net.InetSocketAddress;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import kotlin.Unit;
import org.vpndigger.R;
public final class TunService extends VpnService implements pf {
public static final List<String> g = ze0.m("localhost", "*.local", "127.*", "10.*", "172.16.*", "172.17.*", "172.18.*", "172.19.*", "172.2*", "172.30.*", "172.31.*", "192.168.*");
public static final List<String> h = ze0.m("*zhihu.com", "*zhimg.com", "*jd.com", "100ime-iat-api.xfyun.cn");
public final ze d = (ze) t6.a(vk.a);
public String e;
public final jb f;
@eh(c = "com.worldpass.app.vpn.service.TunService$runtime$1", f = "TunService.kt", l = {253, 81, 81, 81}, m = "invokeSuspend")
public static final class a extends gn0 implements ct<lb, cf<? super Unit>, Object> {
public lq0 h;
public ge i;
public f60 j;
public ok0 k;
public TunService l;
public int m;
public Object n;
@eh(c = "com.worldpass.app.vpn.service.TunService$runtime$1$1", f = "TunService.kt", l = {82}, m = "invokeSuspend")
public static final class C0046a extends gn0 implements ct<pf, cf<? super Unit>, Object> {
public int h;
public final lq0 i;
public final TunService j;
public C0046a(lq0 lq0Var, TunService tunService, cf<? super C0046a> cfVar) {
super(2, cfVar);
this.i = lq0Var;
this.j = tunService;
}
@Override
public final cf<Unit> e(Object obj, cf<?> cfVar) {
return new C0046a(this.i, this.j, cfVar);
}
@Override
public final Object i(Object obj) {
qf qfVar = qf.COROUTINE_SUSPENDED;
int i = this.h;
if (i == 0) {
t6.n(obj);
lq0 lq0Var = this.i;
this.h = 1;
ga<Unit> gaVar = lq0Var.f;
Unit unit = Unit.INSTANCE;
Object a = gaVar.a(unit, this);
if (a == qfVar) {
unit = a;
}
if (unit == qfVar) {
return qfVar;
}
} else if (i != 1) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
} else {
t6.n(obj);
}
this.j.stopSelf();
return Unit.INSTANCE;
}
@Override
public final Object t(pf pfVar, cf<? super Unit> cfVar) {
return new C0046a(this.i, this.j, cfVar).i(Unit.INSTANCE);
}
}
@eh(c = "com.worldpass.app.vpn.service.TunService$runtime$1$quit$1$1", f = "TunService.kt", l = {}, m = "invokeSuspend")
public static final class b extends gn0 implements ct<xb.a, cf<? super Boolean>, Object> {
public b(cf<? super b> cfVar) {
super(2, cfVar);
}
@Override
public final cf<Unit> e(Object obj, cf<?> cfVar) {
return new b(cfVar);
}
@Override
public final Object i(Object obj) {
t6.n(obj);
return Boolean.TRUE;
}
@Override
public final Object t(xb.a aVar, cf<? super Boolean> cfVar) {
new b(cfVar);
t6.n(Unit.INSTANCE);
return Boolean.TRUE;
}
}
@eh(c = "com.worldpass.app.vpn.service.TunService$runtime$1$quit$1$2", f = "TunService.kt", l = {}, m = "invokeSuspend")
public static final class c extends gn0 implements ct<ge.a, cf<? super Boolean>, Object> {
public Object h;
public final TunService i;
public c(TunService tunService, cf<? super c> cfVar) {
super(2, cfVar);
this.i = tunService;
}
@Override
public final cf<Unit> e(Object obj, cf<?> cfVar) {
c cVar = new c(this.i, cfVar);
cVar.h = obj;
return cVar;
}
@Override
public final Object i(Object obj) {
t6.n(obj);
this.i.e = ((ge.a) this.h).a;
return Boolean.TRUE;
}
@Override
public final Object t(ge.a aVar, cf<? super Boolean> cfVar) {
TunService tunService = this.i;
c cVar = new c(tunService, cfVar);
cVar.h = aVar;
t6.n(Unit.INSTANCE);
tunService.e = ((ge.a) cVar.h).a;
return Boolean.TRUE;
}
}
@eh(c = "com.worldpass.app.vpn.service.TunService$runtime$1$quit$1$3", f = "TunService.kt", l = {}, m = "invokeSuspend")
public static final class d extends gn0 implements ct<ok0.a, cf<? super Boolean>, Object> {
public Object h;
public final TunService i;
public d(TunService tunService, cf<? super d> cfVar) {
super(2, cfVar);
this.i = tunService;
}
@Override
public final cf<Unit> e(Object obj, cf<?> cfVar) {
d dVar = new d(this.i, cfVar);
dVar.h = obj;
return dVar;
}
@Override
public final Object i(Object obj) {
t6.n(obj);
this.i.e = ((ok0.a) this.h).a;
return Boolean.TRUE;
}
@Override
public final Object t(ok0.a aVar, cf<? super Boolean> cfVar) {
TunService tunService = this.i;
d dVar = new d(tunService, cfVar);
dVar.h = aVar;
t6.n(Unit.INSTANCE);
tunService.e = ((ok0.a) dVar.h).a;
return Boolean.TRUE;
}
}
@eh(c = "com.worldpass.app.vpn.service.TunService$runtime$1$quit$1$4", f = "TunService.kt", l = {}, m = "invokeSuspend")
public static final class e extends gn0 implements ct<Network, cf<? super Boolean>, Object> {
public Object h;
public final TunService i;
public e(TunService tunService, cf<? super e> cfVar) {
super(2, cfVar);
this.i = tunService;
}
@Override
public final cf<Unit> e(Object obj, cf<?> cfVar) {
e eVar = new e(this.i, cfVar);
eVar.h = obj;
return eVar;
}
@Override
public final Object i(Object obj) {
t6.n(obj);
Network network = (Network) this.h;
int i = Build.VERSION.SDK_INT;
if (22 <= i && i < 29) {
this.i.setUnderlyingNetworks(network != null ? new Network[]{network} : null);
}
return Boolean.FALSE;
}
@Override
public final Object t(Network network, cf<? super Boolean> cfVar) {
e eVar = new e(this.i, cfVar);
eVar.h = network;
eVar.i(Unit.INSTANCE);
return Boolean.FALSE;
}
}
public a(cf<? super a> cfVar) {
super(2, cfVar);
}
@Override
public final cf<Unit> e(Object obj, cf<?> cfVar) {
a aVar = new a(cfVar);
aVar.n = obj;
return aVar;
}
@Override
public final Object i(Object obj) {
a aVar;
f70 f70Var;
C0046a c0046a;
lq0 lq0Var;
ok0 ok0Var;
f60 f60Var;
xb xbVar;
ge geVar;
f70 f70Var2;
C0046a c0046a2;
qf qfVar = qf.COROUTINE_SUSPENDED;
int i = this.m;
int i2 = 1;
try {
} catch (Exception e2) {
e = e2;
aVar = this;
} catch (Throwable th) {
th = th;
aVar = this;
f70Var = f70.d;
c0046a = new C0046a(lq0Var, TunService.this, null);
aVar.n = th;
aVar.h = null;
aVar.i = null;
aVar.j = null;
aVar.k = null;
aVar.l = null;
aVar.m = 4;
if (mz0.x(f70Var, c0046a, aVar) != qfVar) {
}
}
if (i == 0) {
t6.n(obj);
lb lbVar = (lb) this.n;
TunService tunService = TunService.this;
List<String> list = TunService.g;
Objects.requireNonNull(tunService);
sj0 sj0Var = new sj0(tunService);
TunService tunService2 = TunService.this;
Objects.requireNonNull(tunService2);
xb xbVar2 = (xb) lbVar.a(new xb(tunService2));
TunService tunService3 = TunService.this;
Objects.requireNonNull(tunService3);
lq0Var = (lq0) lbVar.a(new lq0(tunService3));
TunService tunService4 = TunService.this;
Objects.requireNonNull(tunService4);
ge geVar2 = (ge) lbVar.a(new ge(tunService4));
TunService tunService5 = TunService.this;
Objects.requireNonNull(tunService5);
f60 f60Var2 = (f60) lbVar.a(new f60(tunService5));
TunService tunService6 = TunService.this;
Objects.requireNonNull(tunService6);
ok0Var = (ok0) lbVar.a(new ok0(tunService6));
if (sj0Var.d()) {
TunService tunService7 = TunService.this;
Objects.requireNonNull(tunService7);
lbVar.a(new em(tunService7));
} else {
TunService tunService8 = TunService.this;
Objects.requireNonNull(tunService8);
lbVar.a(new tl0(tunService8));
}
TunService tunService9 = TunService.this;
Objects.requireNonNull(tunService9);
lbVar.a(new r5(tunService9));
TunService tunService10 = TunService.this;
Objects.requireNonNull(tunService10);
lbVar.a(new gp0(tunService10));
TunService tunService11 = TunService.this;
Objects.requireNonNull(tunService11);
lbVar.a(new hn0(tunService11));
TunService.a(TunService.this, lq0Var);
f60Var = f60Var2;
aVar = this;
xbVar = xbVar2;
geVar = geVar2;
if (t6.h(TunService.this)) {
}
f70Var2 = f70.d;
c0046a2 = new C0046a(lq0Var, TunService.this, null);
aVar.n = null;
aVar.h = null;
aVar.i = null;
aVar.j = null;
aVar.k = null;
aVar.l = null;
aVar.m = 2;
if (mz0.x(f70Var2, c0046a2, aVar) == qfVar) {
}
return Unit.INSTANCE;
} else if (i != 1) {
if (i == 2 || i == 3) {
t6.n(obj);
return Unit.INSTANCE;
} else if (i != 4) {
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
} else {
Throwable th2 = (Throwable) this.n;
t6.n(obj);
throw th2;
}
} else {
ok0 ok0Var2 = this.k;
f60Var = this.j;
geVar = this.i;
lq0Var = this.h;
xbVar = (xb) this.n;
t6.n(obj);
ok0Var = ok0Var2;
aVar = this;
Object P = obj;
try {
try {
if (!((Boolean) P).booleanValue()) {
i2 = 1;
if (t6.h(TunService.this)) {
TunService tunService12 = TunService.this;
aVar.n = xbVar;
aVar.h = lq0Var;
aVar.i = geVar;
aVar.j = f60Var;
aVar.k = ok0Var;
aVar.l = tunService12;
aVar.m = i2;
wh0 wh0Var = new wh0(aVar);
try {
} catch (Throwable th3) {
wh0Var.Q(th3);
}
((h.g) xbVar.c()).a(wh0Var, new b(null));
((h.g) geVar.c()).a(wh0Var, new c(tunService12, null));
((h.g) ok0Var.c()).a(wh0Var, new d(tunService12, null));
((h.g) f60Var.c()).a(wh0Var, new e(tunService12, null));
P = wh0Var.P();
if (P == qfVar) {
return qfVar;
}
if (!((Boolean) P).booleanValue()) {
}
}
}
f70Var2 = f70.d;
c0046a2 = new C0046a(lq0Var, TunService.this, null);
aVar.n = null;
aVar.h = null;
aVar.i = null;
aVar.j = null;
aVar.k = null;
aVar.l = null;
aVar.m = 2;
if (mz0.x(f70Var2, c0046a2, aVar) == qfVar) {
return qfVar;
}
} catch (Exception e3) {
e = e3;
Log.e("VPN", "Create clash runtime: " + e.getMessage(), e);
TunService.this.e = e.getMessage();
f70 f70Var3 = f70.d;
C0046a c0046a3 = new C0046a(lq0Var, TunService.this, null);
aVar.n = null;
aVar.h = null;
aVar.i = null;
aVar.j = null;
aVar.k = null;
aVar.l = null;
aVar.m = 3;
if (mz0.x(f70Var3, c0046a3, aVar) == qfVar) {
return qfVar;
}
return Unit.INSTANCE;
}
return Unit.INSTANCE;
} catch (Throwable th4) {
th = th4;
f70Var = f70.d;
c0046a = new C0046a(lq0Var, TunService.this, null);
aVar.n = th;
aVar.h = null;
aVar.i = null;
aVar.j = null;
aVar.k = null;
aVar.l = null;
aVar.m = 4;
if (mz0.x(f70Var, c0046a, aVar) != qfVar) {
return qfVar;
}
throw th;
}
}
}
@Override
public final Object t(lb lbVar, cf<? super Unit> cfVar) {
a aVar = new a(cfVar);
aVar.n = lbVar;
return aVar.i(Unit.INSTANCE);
}
}
public TunService() {
a aVar = new a(null);
m50 m50Var = kb.a;
this.f = new jb(this, aVar);
}
public static final void a(TunService tunService, lq0 lq0Var) {
boolean z;
Objects.requireNonNull(tunService);
sj0 sj0Var = new sj0(tunService);
VpnService.Builder builder = new VpnService.Builder(tunService);
builder.addAddress("172.19.0.1", 30);
if (sj0Var.c()) {
String[] stringArray = tunService.getResources().getStringArray(R.array.bypass_private_route);
ArrayList arrayList = new ArrayList(stringArray.length);
for (String str : stringArray) {
List K = pm0.K(str, new String[]{"/"}, 2, 2);
if (K.size() == 2) {
arrayList.add(new nv((String) K.get(0), Integer.parseInt((String) K.get(1))));
} else {
throw new IllegalArgumentException("Invalid address");
}
}
Iterator it = arrayList.iterator();
while (it.hasNext()) {
nv nvVar = (nv) it.next();
builder.addRoute(nvVar.a, nvVar.b);
}
builder.addRoute("172.19.0.2", 32);
} else {
builder.addRoute("0.0.0.0", 0);
}
int ordinal = ((i0) sj0Var.c.a(sj0Var, sj0.j[2])).ordinal();
if (ordinal == 1) {
Set<String> a2 = sj0Var.a();
String packageName = tunService.getPackageName();
LinkedHashSet<String> linkedHashSet = new LinkedHashSet(wf.o(a2.size() + 1));
linkedHashSet.addAll(a2);
linkedHashSet.add(packageName);
for (String str2 : linkedHashSet) {
try {
builder.addAllowedApplication(str2);
} catch (Throwable unused) {
}
}
} else if (ordinal == 2) {
Set<String> a3 = sj0Var.a();
String packageName2 = tunService.getPackageName();
LinkedHashSet<String> linkedHashSet2 = new LinkedHashSet(wf.o(a3.size()));
boolean z2 = false;
for (Object obj : a3) {
if (z2 || !sx0.c(obj, packageName2)) {
z = true;
} else {
z2 = true;
z = false;
}
if (z) {
linkedHashSet2.add(obj);
}
}
for (String str3 : linkedHashSet2) {
try {
builder.addDisallowedApplication(str3);
} catch (Throwable unused2) {
}
}
}
builder.setBlocking(false);
builder.setMtu(9000);
builder.setSession("VPN");
builder.addDnsServer("172.19.0.2");
Intent intent = new Intent();
td tdVar = td.a;
builder.setConfigureIntent(PendingIntent.getActivity(tunService, R.id.nf_vpn_status, intent.setComponent(td.b), ye.f()));
int i = Build.VERSION.SDK_INT;
if (i >= 29) {
builder.setMetered(false);
}
if (i >= 29 && ((Boolean) sj0Var.f.a(sj0Var, sj0.j[5])).booleanValue()) {
Objects.requireNonNull(lq0Var);
StringBuilder sb = new StringBuilder();
sb.append("127.");
SecureRandom secureRandom = lq0.h;
sb.append(Integer.valueOf(secureRandom.nextInt(199) + 1).intValue());
sb.append('.');
sb.append(Integer.valueOf(secureRandom.nextInt(199) + 1).intValue());
sb.append('.');
sb.append(Integer.valueOf(secureRandom.nextInt(199) + 1).intValue());
sb.append(":0");
String sb2 = sb.toString();
db dbVar = db.a;
String nativeStartHttp = Bridge.INSTANCE.nativeStartHttp(sb2);
InetSocketAddress o = nativeStartHttp != null ? ze0.o(nativeStartHttp) : null;
if (o != null) {
builder.setHttpProxy(ProxyInfo.buildDirectProxy(o.getAddress().getHostAddress(), o.getPort(), oc.G(h, sj0Var.c() ? g : co.d)));
}
}
ul0 ul0Var = sj0Var.g;
oz<Object>[] ozVarArr = sj0.j;
if (((Boolean) ul0Var.a(sj0Var, ozVarArr[6])).booleanValue()) {
builder.allowBypass();
}
ParcelFileDescriptor establish = builder.establish();
Objects.requireNonNull(establish, "Establish VPN rejected by system");
int detachFd = establish.detachFd();
String str4 = ((Boolean) sj0Var.e.a(sj0Var, ozVarArr[4])).booleanValue() ? "0.0.0.0" : "172.19.0.2";
Objects.requireNonNull(lq0Var);
db dbVar2 = db.a;
Bridge.INSTANCE.nativeStartTun(detachFd, "172.19.0.1/30", "172.19.0.2", str4, new fb(new mq0(lq0Var.d), new nq0(lq0Var)));
}
@Override
public final Cif n() {
return this.d.d;
}
@Override
public final void onCreate() {
super.onCreate();
StatusProvider.a aVar = StatusProvider.d;
if (StatusProvider.e) {
stopSelf();
return;
}
aVar.a(true);
tl0.a aVar2 = tl0.e;
aVar2.a(this);
aVar2.b(this);
jb jbVar = this.f;
mz0.s(jbVar.a, vk.c, new ib(jbVar.b, null), 2);
}
@Override
public final void onDestroy() {
lq0.a aVar = lq0.g;
db dbVar = db.a;
Bridge bridge = Bridge.INSTANCE;
bridge.nativeStopHttp();
bridge.nativeStopTun();
StatusProvider.d.a(false);
String str = this.e;
hx hxVar = hx.a;
ze0.q(this, new Intent(hx.e).putExtra("stop_reason", str));
nf.a(this);
StringBuilder sb = new StringBuilder();
sb.append("TunService destroyed: ");
String str2 = this.e;
if (str2 == null) {
str2 = "successfully";
}
sb.append(str2);
Log.i("VPN", sb.toString(), null);
super.onDestroy();
}
@Override
public final int onStartCommand(Intent intent, int i, int i2) {
hx hxVar = hx.a;
ze0.q(this, new Intent(hx.d));
return super.onStartCommand(intent, i, i2);
}
@Override
public final void onTrimMemory(int i) {
super.onTrimMemory(i);
Objects.requireNonNull(this.f);
db.a.c();
}
}