OurPlay v5.5.9版本的 MD5 值为:d4e139798f4c2243a1145c8af5e21046
以下内容为反编译后的 VpnService.java 源代码,内容仅作参考
package com.github.shadowsocks.bg;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.net.LocalSocket;
import android.net.LocalSocketAddress;
import android.net.Network;
import android.net.VpnService;
import android.os.Build;
import android.os.IBinder;
import android.os.ParcelFileDescriptor;
import android.system.ErrnoException;
import android.system.Os;
import android.util.Log;
import com.excelliance.kxqp.sdk.StatisticsBase;
import com.excelliance.kxqp.ui.detail.category.CategoryListActivity;
import com.github.shadowsocks.Core;
import com.github.shadowsocks.CustomProfile;
import com.github.shadowsocks.VpnRequestActivity;
import com.github.shadowsocks.bg.BaseService;
import com.github.shadowsocks.bg.LocalDnsService;
import com.github.shadowsocks.core.R;
import com.github.shadowsocks.database.Profile;
import com.github.shadowsocks.net.ConcurrentLocalSocketListener;
import com.github.shadowsocks.net.DefaultNetworkListener;
import com.github.shadowsocks.net.Subnet;
import com.github.shadowsocks.preference.DataStore;
import com.google.android.gms.common.ConnectionResult;
import com.tencent.open.SocialConstants;
import java.io.Closeable;
import java.io.File;
import java.io.FileDescriptor;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.reflect.Method;
import java.net.InetAddress;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import kotlin.Metadata;
import kotlin.Result;
import kotlin.TypeCastException;
import kotlin.coroutines.Continuation;
import kotlin.coroutines.jvm.internal.ContinuationImpl;
import kotlin.coroutines.jvm.internal.DebugMetadata;
import kotlin.coroutines.jvm.internal.SuspendLambda;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.functions.Function2;
import kotlin.jvm.internal.Lambda;
import kotlin.text.m;
import kotlin.u;
import kotlinx.coroutines.BuildersKt__Builders_commonKt;
import kotlinx.coroutines.CoroutineScope;
import kotlinx.coroutines.DelayKt;
import org.apache.http.cookie.ClientCookie;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0094\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\u000e\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u0011\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\b\u0018\u0000 B2\u00020\u00012\u00020\u0002:\u0004ABCDB\u0005¢\u0006\u0002\u0010\u0003J\u001c\u0010\u001b\u001a\b\u0012\u0004\u0012\u00020\r0\u001c2\f\u0010\u001d\u001a\b\u0012\u0004\u0012\u00020\r0\u001cH\u0016J\u0010\u0010\u001e\u001a\u00020\u001f2\u0006\u0010 \u001a\u00020\rH\u0016J\u0010\u0010!\u001a\u00020\"2\u0006\u0010#\u001a\u00020$H\u0016J\u0012\u0010%\u001a\u0004\u0018\u00010&2\u0006\u0010'\u001a\u00020(H\u0016J\b\u0010)\u001a\u00020\"H\u0016J\b\u0010*\u001a\u00020\"H\u0016J\"\u0010+\u001a\u00020,2\b\u0010'\u001a\u0004\u0018\u00010(2\u0006\u0010-\u001a\u00020,2\u0006\u0010.\u001a\u00020,H\u0016J!\u0010/\u001a\n 1*\u0004\u0018\u000100002\u0006\u00102\u001a\u000203H\u0096@ø\u0001\u0000¢\u0006\u0002\u00104J\u0011\u00105\u001a\u00020\"H\u0096@ø\u0001\u0000¢\u0006\u0002\u00106J?\u00107\u001a(\u0012\f\u0012\n 1*\u0004\u0018\u00010808 1*\u0014\u0012\u000e\b\u0001\u0012\n 1*\u0004\u0018\u00010808\u0018\u00010\u00160\u00162\u0006\u00109\u001a\u00020\rH\u0096@ø\u0001\u0000¢\u0006\u0002\u0010:J\u0019\u0010;\u001a\u00020\"2\u0006\u0010<\u001a\u00020=H\u0082@ø\u0001\u0000¢\u0006\u0002\u0010>J\u0011\u0010?\u001a\u00020\"H\u0096@ø\u0001\u0000¢\u0006\u0002\u00106J\u0011\u0010@\u001a\u00020=H\u0082@ø\u0001\u0000¢\u0006\u0002\u00106R\u000e\u0010\u0004\u001a\u00020\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0006\u001a\u0004\u0018\u00010\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\b\u001a\u00020\tX\u0096\u0004¢\u0006\b\n\u0000\u001a\u0004\b\n\u0010\u000bR\u0014\u0010\f\u001a\u00020\r8VX\u0096\u0004¢\u0006\u0006\u001a\u0004\b\u000e\u0010\u000fR\"\u0010\u0012\u001a\u0004\u0018\u00010\u00112\b\u0010\u0010\u001a\u0004\u0018\u00010\u0011@BX\u0082\u000e¢\u0006\b\n\u0000\"\u0004\b\u0013\u0010\u0014R\u001c\u0010\u0015\u001a\n\u0012\u0004\u0012\u00020\u0011\u0018\u00010\u00168BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\u0017\u0010\u0018R\u0014\u0010\u0019\u001a\b\u0018\u00010\u001aR\u00020\u0000X\u0082\u000e¢\u0006\u0002\n\u0000\u0082\u0002\u0004\n\u0002\b\u0019¨\u0006E"}, d2 = {"Lcom/github/shadowsocks/bg/VpnService;", "Landroid/net/VpnService;", "Lcom/github/shadowsocks/bg/LocalDnsService$Interface;", "()V", "active", "", "conn", "Landroid/os/ParcelFileDescriptor;", "data", "Lcom/github/shadowsocks/bg/BaseService$Data;", "getData", "()Lcom/github/shadowsocks/bg/BaseService$Data;", CategoryListActivity.TAG_NAME, "", "getTag", "()Ljava/lang/String;", "value", "Landroid/net/Network;", "underlyingNetwork", "setUnderlyingNetwork", "(Landroid/net/Network;)V", "underlyingNetworks", "", "getUnderlyingNetworks", "()[Landroid/net/Network;", "worker", "Lcom/github/shadowsocks/bg/VpnService$ProtectWorker;", "buildAdditionalArguments", "Ljava/util/ArrayList;", "cmd", "createNotification", "Lcom/github/shadowsocks/bg/ServiceNotification;", "profileName", "killProcesses", "", "scope", "Lkotlinx/coroutines/CoroutineScope;", "onBind", "Landroid/os/IBinder;", "intent", "Landroid/content/Intent;", "onDestroy", "onRevoke", "onStartCommand", "", "flags", "startId", "openConnection", "Ljava/net/URLConnection;", "kotlin.jvm.PlatformType", SocialConstants.PARAM_URL, "Ljava/net/URL;", "(Ljava/net/URL;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "preInit", "(Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "resolver", "Ljava/net/InetAddress;", com.alipay.sdk.cons.c.f, "(Ljava/lang/String;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "sendFd", "fd", "Ljava/io/FileDescriptor;", "(Ljava/io/FileDescriptor;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;", "startProcesses", "startVpn", "CloseableFd", "Companion", "NullConnectionException", "ProtectWorker", "core_release"}, k = 1, mv = {1, 1, 13})
public final class VpnService extends android.net.VpnService implements LocalDnsService.a {
public static final b f15833a = new b(null);
private static final Method g = FileDescriptor.class.getDeclaredMethod("getInt$", new Class[0]);
@NotNull
private final BaseService.a f15834b = new BaseService.a(this);
private ParcelFileDescriptor c;
private d d;
private boolean e;
private Network f;
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0018\n\u0000\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\u0010\u0000\u001a\u0004\u0018\u00010\u00012\u0006\u0010\u0002\u001a\u00020\u00032\u0014\u0010\u0004\u001a\u0010\u0012\f\u0012\n \u0007*\u0004\u0018\u00010\u00060\u00060\u0005H\u0096@ø\u0001\u0000"}, d2 = {"openConnection", "", SocialConstants.PARAM_URL, "Ljava/net/URL;", "continuation", "Lkotlin/coroutines/Continuation;", "Ljava/net/URLConnection;", "kotlin.jvm.PlatformType"}, k = 3, mv = {1, 1, 13})
@DebugMetadata(c = "com.github.shadowsocks.bg.VpnService", f = "VpnService.kt", i = {0, 0}, l = {StatisticsBase.UA_EXIT_XSPACE}, m = "openConnection", n = {"this", SocialConstants.PARAM_URL}, s = {"L$0", "L$1"})
public static final class f extends ContinuationImpl {
Object f15840a;
int f15841b;
Object d;
Object e;
f(Continuation continuation) {
super(continuation);
}
@Override
@Nullable
public final Object invokeSuspend(@NotNull Object obj) {
this.f15840a = obj;
this.f15841b |= Integer.MIN_VALUE;
return VpnService.this.a((URL) null, this);
}
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u001c\n\u0000\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u0011\n\u0002\u0018\u0002\n\u0000\u0010\u0000\u001a\u0004\u0018\u00010\u00012\u0006\u0010\u0002\u001a\u00020\u000322\u0010\u0004\u001a.\u0012*\u0012(\u0012\f\u0012\n \b*\u0004\u0018\u00010\u00070\u0007 \b*\u0014\u0012\u000e\b\u0001\u0012\n \b*\u0004\u0018\u00010\u00070\u0007\u0018\u00010\u00060\u00060\u0005H\u0096@ø\u0001\u0000"}, d2 = {"resolver", "", com.alipay.sdk.cons.c.f, "", "continuation", "Lkotlin/coroutines/Continuation;", "", "Ljava/net/InetAddress;", "kotlin.jvm.PlatformType"}, k = 3, mv = {1, 1, 13})
@DebugMetadata(c = "com.github.shadowsocks.bg.VpnService", f = "VpnService.kt", i = {0, 0}, l = {StatisticsBase.UA_LAUNCH_XSPACE}, m = "resolver", n = {"this", com.alipay.sdk.cons.c.f}, s = {"L$0", "L$1"})
public static final class h extends ContinuationImpl {
Object f15843a;
int f15844b;
Object d;
Object e;
h(Continuation continuation) {
super(continuation);
}
@Override
@Nullable
public final Object invokeSuspend(@NotNull Object obj) {
this.f15843a = obj;
this.f15844b |= Integer.MIN_VALUE;
return VpnService.this.a((String) null, this);
}
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0016\n\u0000\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u0002\u0010\u0000\u001a\u0004\u0018\u00010\u00012\u0006\u0010\u0002\u001a\u00020\u00032\f\u0010\u0004\u001a\b\u0012\u0004\u0012\u00020\u00060\u0005H\u0082@ø\u0001\u0000"}, d2 = {"sendFd", "", "fd", "Ljava/io/FileDescriptor;", "continuation", "Lkotlin/coroutines/Continuation;", ""}, k = 3, mv = {1, 1, 13})
@DebugMetadata(c = "com.github.shadowsocks.bg.VpnService", f = "VpnService.kt", i = {0, 0, 0, 0}, l = {234}, m = "sendFd", n = {"this", "fd", "tries", ClientCookie.PATH_ATTR}, s = {"L$0", "L$1", "I$0", "L$2"})
public static final class i extends ContinuationImpl {
Object f15845a;
int f15846b;
Object d;
Object e;
Object f;
int g;
i(Continuation continuation) {
super(continuation);
}
@Override
@Nullable
public final Object invokeSuspend(@NotNull Object obj) {
this.f15845a = obj;
this.f15846b |= Integer.MIN_VALUE;
return VpnService.this.a((FileDescriptor) null, this);
}
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0010\n\u0000\n\u0002\u0010\u0000\n\u0000\n\u0002\u0018\u0002\n\u0002\u0010\u0002\u0010\u0000\u001a\u0004\u0018\u00010\u00012\f\u0010\u0002\u001a\b\u0012\u0004\u0012\u00020\u00040\u0003H\u0096@ø\u0001\u0000"}, d2 = {"startProcesses", "", "continuation", "Lkotlin/coroutines/Continuation;", ""}, k = 3, mv = {1, 1, 13})
@DebugMetadata(c = "com.github.shadowsocks.bg.VpnService", f = "VpnService.kt", i = {0, 1, 2}, l = {StatisticsBase.UA_START_APP_INFO, StatisticsBase.UA_OPEN_FRIDAY_ACTIVITY, StatisticsBase.UA_OPEN_FRIDAY_ACTIVITY}, m = "startProcesses", n = {"this", "this", "this"}, s = {"L$0", "L$0", "L$0"})
public static final class j extends ContinuationImpl {
Object f15847a;
int f15848b;
Object d;
Object e;
j(Continuation continuation) {
super(continuation);
}
@Override
@Nullable
public final Object invokeSuspend(@NotNull Object obj) {
this.f15847a = obj;
this.f15848b |= Integer.MIN_VALUE;
return VpnService.this.a(this);
}
}
@Override
@NotNull
public String b() {
return "ShadowsocksVpnService";
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u000e\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\u0010\u0000\u001a\u00020\u00012\b\u0010\u0002\u001a\u0004\u0018\u00010\u0003H\n¢\u0006\u0002\b\u0004"}, d2 = {"<anonymous>", "", "it", "Landroid/net/Network;", "invoke"}, k = 3, mv = {1, 1, 13})
static final class g extends Lambda implements Function1<Network, u> {
g() {
super(1);
}
@Override
public u invoke(Network network) {
a(network);
return u.f19091a;
}
public final void a(@Nullable Network network) {
VpnService.this.a(network);
}
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\"\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0004\n\u0002\u0010\b\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002R\u000e\u0010\u0003\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u0006\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\u0004X\u0082T¢\u0006\u0002\n\u0000R\u000e\u0010\b\u001a\u00020\tX\u0082T¢\u0006\u0002\n\u0000R\u0016\u0010\n\u001a\n \f*\u0004\u0018\u00010\u000b0\u000bX\u0082\u0004¢\u0006\u0002\n\u0000¨\u0006\r"}, d2 = {"Lcom/github/shadowsocks/bg/VpnService$Companion;", "", "()V", "PRIVATE_VLAN4_CLIENT", "", "PRIVATE_VLAN4_ROUTER", "PRIVATE_VLAN6_CLIENT", "PRIVATE_VLAN6_ROUTER", "VPN_MTU", "", "getInt", "Ljava/lang/reflect/Method;", "kotlin.jvm.PlatformType", "core_release"}, k = 1, mv = {1, 1, 13})
public static final class b {
private b() {
}
public b(kotlin.jvm.internal.g gVar) {
this();
}
}
@Override
public void a(boolean z, @Nullable String str) {
LocalDnsService.a.C0634a.a(this, z, str);
}
@Override
public void c() {
LocalDnsService.a.C0634a.a(this);
}
@Override
public void d() {
LocalDnsService.a.C0634a.b(this);
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010\u0002\n\u0000\u0018\u00002\u00020\u0001B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004J\b\u0010\u0007\u001a\u00020\bH\u0016R\u0011\u0010\u0002\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\u0005\u0010\u0006¨\u0006\t"}, d2 = {"Lcom/github/shadowsocks/bg/VpnService$CloseableFd;", "Ljava/io/Closeable;", "fd", "Ljava/io/FileDescriptor;", "(Ljava/io/FileDescriptor;)V", "getFd", "()Ljava/io/FileDescriptor;", "close", "", "core_release"}, k = 1, mv = {1, 1, 13})
public static final class a implements Closeable {
@NotNull
private final FileDescriptor f15835a;
public a(@NotNull FileDescriptor fileDescriptor) {
kotlin.jvm.internal.k.b(fileDescriptor, "fd");
this.f15835a = fileDescriptor;
}
@Override
public void close() {
Os.close(this.f15835a);
}
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\b\u0082\u0004\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002J\u0010\u0010\u0003\u001a\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0006H\u0014¨\u0006\u0007"}, d2 = {"Lcom/github/shadowsocks/bg/VpnService$ProtectWorker;", "Lcom/github/shadowsocks/net/ConcurrentLocalSocketListener;", "(Lcom/github/shadowsocks/bg/VpnService;)V", "acceptInternal", "", "socket", "Landroid/net/LocalSocket;", "core_release"}, k = 1, mv = {1, 1, 13})
public final class d extends ConcurrentLocalSocketListener {
public d() {
super("ShadowsocksVpnThread", new File(Core.d.d().getNoBackupFilesDir(), "protect_path"));
}
@Override
protected void a(@NotNull LocalSocket localSocket) {
boolean protect;
kotlin.jvm.internal.k.b(localSocket, "socket");
localSocket.getInputStream().read();
FileDescriptor[] ancillaryFileDescriptors = localSocket.getAncillaryFileDescriptors();
if (ancillaryFileDescriptors == null) {
kotlin.jvm.internal.k.a();
}
Object c = kotlin.collections.f.c(ancillaryFileDescriptors);
if (c == null) {
kotlin.jvm.internal.k.a();
}
FileDescriptor fileDescriptor = (FileDescriptor) c;
a aVar = new a(fileDescriptor);
Throwable th = null;
Throwable th2 = (Throwable) null;
try {
a aVar2 = aVar;
OutputStream outputStream = localSocket.getOutputStream();
Network network = VpnService.this.f;
if (network != null && Build.VERSION.SDK_INT >= 23) {
try {
network.bindSocket(fileDescriptor);
protect = true;
} catch (IOException e) {
Throwable cause = e.getCause();
if (cause instanceof ErrnoException) {
th = cause;
}
ErrnoException errnoException = (ErrnoException) th;
if (errnoException == null || errnoException.errno != 64) {
com.github.shadowsocks.utils.h.a(e);
}
protect = false;
}
} else {
VpnService vpnService = VpnService.this;
Object invoke = VpnService.g.invoke(fileDescriptor, new Object[0]);
if (invoke == null) {
throw new TypeCastException("null cannot be cast to non-null type kotlin.Int");
}
protect = vpnService.protect(((Integer) invoke).intValue());
}
outputStream.write(protect ? 0 : 1);
u uVar = u.f19091a;
} finally {
kotlin.io.c.a(aVar, th2);
}
}
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u0018\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\u0002\b\u0086\u0004\u0018\u00002\u00060\u0001j\u0002`\u0002B\u0005¢\u0006\u0002\u0010\u0003J\u0010\u0010\u0004\u001a\n \u0006*\u0004\u0018\u00010\u00050\u0005H\u0016¨\u0006\u0007"}, d2 = {"Lcom/github/shadowsocks/bg/VpnService$NullConnectionException;", "Ljava/lang/NullPointerException;", "Lkotlin/NullPointerException;", "(Lcom/github/shadowsocks/bg/VpnService;)V", "getLocalizedMessage", "", "kotlin.jvm.PlatformType", "core_release"}, k = 1, mv = {1, 1, 13})
public final class c extends NullPointerException {
public c() {
}
@Override
public String getLocalizedMessage() {
return VpnService.this.getString(R.string.reboot_required);
}
}
@Override
@NotNull
public BaseService.a getF15834b() {
return this.f15834b;
}
@Override
@NotNull
public ServiceNotification a(@NotNull String str) {
kotlin.jvm.internal.k.b(str, "profileName");
return new ServiceNotification(this, str, "service-vpn", false, 8, null);
}
public final void a(Network network) {
this.f = network;
if (!this.e || Build.VERSION.SDK_INT < 22) {
return;
}
setUnderlyingNetworks(f());
}
private final Network[] f() {
Network network = this.f;
if (network != null) {
return new Network[]{network};
}
return null;
}
@Override
@Nullable
public IBinder onBind(@NotNull Intent intent) {
kotlin.jvm.internal.k.b(intent, "intent");
String action = intent.getAction();
if (action != null && action.hashCode() == -700396143 && action.equals("android.net.VpnService")) {
return super.onBind(intent);
}
return LocalDnsService.a.C0634a.a(this, intent);
}
@Override
public void onRevoke() {
BaseService.b.a.a(this, false, null, 3, null);
}
@Override
public void a(@NotNull CoroutineScope coroutineScope) {
kotlin.jvm.internal.k.b(coroutineScope, "scope");
LocalDnsService.a.C0634a.a(this, coroutineScope);
this.e = false;
BuildersKt__Builders_commonKt.launch$default(coroutineScope, null, null, new e(null), 3, null);
d dVar = this.d;
if (dVar != null) {
dVar.a(coroutineScope);
}
this.d = (d) null;
ParcelFileDescriptor parcelFileDescriptor = this.c;
if (parcelFileDescriptor != null) {
parcelFileDescriptor.close();
}
this.c = (ParcelFileDescriptor) null;
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\u000e\n\u0000\n\u0002\u0010\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\u0010\u0000\u001a\u00020\u0001*\u00020\u0002H\u008a@ø\u0001\u0000¢\u0006\u0004\b\u0003\u0010\u0004"}, d2 = {"<anonymous>", "", "Lkotlinx/coroutines/CoroutineScope;", "invoke", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"}, k = 3, mv = {1, 1, 13})
@DebugMetadata(c = "com.github.shadowsocks.bg.VpnService$killProcesses$1", f = "VpnService.kt", i = {}, l = {123}, m = "invokeSuspend", n = {}, s = {})
static final class e extends SuspendLambda implements Function2<CoroutineScope, Continuation<? super u>, Object> {
int f15838a;
private CoroutineScope f15839b;
e(Continuation continuation) {
super(2, continuation);
}
@Override
@NotNull
public final Continuation<u> create(@Nullable Object obj, @NotNull Continuation<?> continuation) {
kotlin.jvm.internal.k.b(continuation, "completion");
e eVar = new e(continuation);
eVar.f15839b = (CoroutineScope) obj;
return eVar;
}
@Override
public final Object invoke(CoroutineScope coroutineScope, Continuation<? super u> continuation) {
return ((e) create(coroutineScope, continuation)).invokeSuspend(u.f19091a);
}
@Override
@Nullable
public final Object invokeSuspend(@NotNull Object obj) {
Object a2 = kotlin.coroutines.intrinsics.b.a();
switch (this.f15838a) {
case 0:
if (obj instanceof Result.Failure) {
throw ((Result.Failure) obj).f19083a;
}
CoroutineScope coroutineScope = this.f15839b;
DefaultNetworkListener defaultNetworkListener = DefaultNetworkListener.f15980a;
this.f15838a = 1;
if (defaultNetworkListener.a(coroutineScope, this) == a2) {
return a2;
}
break;
case 1:
if (obj instanceof Result.Failure) {
throw ((Result.Failure) obj).f19083a;
}
break;
default:
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
return u.f19091a;
}
}
@Override
public int onStartCommand(@Nullable Intent intent, int flags, int startId) {
if (kotlin.jvm.internal.k.a((Object) DataStore.f16084b.g(), (Object) "vpn")) {
VpnService vpnService = this;
if (android.net.VpnService.prepare(vpnService) != null) {
startActivity(new Intent(vpnService, (Class<?>) VpnRequestActivity.class).addFlags(268435456));
} else {
return LocalDnsService.a.C0634a.a(this, intent, flags, startId);
}
}
BaseService.b.a.a(this, false, null, 3, null);
return 2;
}
@Override
@Nullable
public Object b(@NotNull Continuation<? super u> continuation) {
return DefaultNetworkListener.f15980a.a(this, new g(), continuation);
}
@Override
@Nullable
public Object a(@NotNull String str, @NotNull Continuation<? super InetAddress[]> continuation) {
h hVar;
if (continuation instanceof h) {
hVar = (h) continuation;
if ((hVar.f15844b & Integer.MIN_VALUE) != 0) {
hVar.f15844b -= Integer.MIN_VALUE;
Object obj = hVar.f15843a;
Object a2 = kotlin.coroutines.intrinsics.b.a();
switch (hVar.f15844b) {
case 0:
if (obj instanceof Result.Failure) {
throw ((Result.Failure) obj).f19083a;
}
DefaultNetworkListener defaultNetworkListener = DefaultNetworkListener.f15980a;
hVar.d = this;
hVar.e = str;
hVar.f15844b = 1;
obj = defaultNetworkListener.a(hVar);
if (obj == a2) {
return a2;
}
break;
case 1:
str = (String) hVar.e;
if (obj instanceof Result.Failure) {
throw ((Result.Failure) obj).f19083a;
}
break;
default:
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
return ((Network) obj).getAllByName(str);
}
}
hVar = new h(continuation);
Object obj2 = hVar.f15843a;
Object a22 = kotlin.coroutines.intrinsics.b.a();
switch (hVar.f15844b) {
}
return ((Network) obj2).getAllByName(str);
}
@Override
@Nullable
public Object a(@NotNull URL url, @NotNull Continuation<? super URLConnection> continuation) {
f fVar;
if (continuation instanceof f) {
fVar = (f) continuation;
if ((fVar.f15841b & Integer.MIN_VALUE) != 0) {
fVar.f15841b -= Integer.MIN_VALUE;
Object obj = fVar.f15840a;
Object a2 = kotlin.coroutines.intrinsics.b.a();
switch (fVar.f15841b) {
case 0:
if (obj instanceof Result.Failure) {
throw ((Result.Failure) obj).f19083a;
}
DefaultNetworkListener defaultNetworkListener = DefaultNetworkListener.f15980a;
fVar.d = this;
fVar.e = url;
fVar.f15841b = 1;
obj = defaultNetworkListener.a(fVar);
if (obj == a2) {
return a2;
}
break;
case 1:
url = (URL) fVar.e;
if (obj instanceof Result.Failure) {
throw ((Result.Failure) obj).f19083a;
}
break;
default:
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
return ((Network) obj).openConnection(url);
}
}
fVar = new f(continuation);
Object obj2 = fVar.f15840a;
Object a22 = kotlin.coroutines.intrinsics.b.a();
switch (fVar.f15841b) {
}
return ((Network) obj2).openConnection(url);
}
@Override
@Nullable
public Object a(@NotNull Continuation<? super u> continuation) {
j jVar;
VpnService vpnService;
VpnService vpnService2;
if (continuation instanceof j) {
jVar = (j) continuation;
if ((jVar.f15848b & Integer.MIN_VALUE) != 0) {
jVar.f15848b -= Integer.MIN_VALUE;
Object obj = jVar.f15847a;
Object a2 = kotlin.coroutines.intrinsics.b.a();
switch (jVar.f15848b) {
case 0:
if (obj instanceof Result.Failure) {
throw ((Result.Failure) obj).f19083a;
}
d dVar = new d();
dVar.start();
this.d = dVar;
jVar.d = this;
jVar.f15848b = 1;
if (LocalDnsService.a.C0634a.a(this, jVar) == a2) {
return a2;
}
vpnService = this;
jVar.d = vpnService;
jVar.e = vpnService;
jVar.f15848b = 2;
obj = vpnService.c(jVar);
if (obj != a2) {
return a2;
}
vpnService2 = vpnService;
jVar.d = vpnService2;
jVar.f15848b = 3;
obj = vpnService.a((FileDescriptor) obj, jVar);
return obj != a2 ? a2 : obj;
case 1:
vpnService = (VpnService) jVar.d;
if (obj instanceof Result.Failure) {
throw ((Result.Failure) obj).f19083a;
}
jVar.d = vpnService;
jVar.e = vpnService;
jVar.f15848b = 2;
obj = vpnService.c(jVar);
if (obj != a2) {
}
break;
case 2:
vpnService = (VpnService) jVar.e;
vpnService2 = (VpnService) jVar.d;
if (obj instanceof Result.Failure) {
throw ((Result.Failure) obj).f19083a;
}
jVar.d = vpnService2;
jVar.f15848b = 3;
obj = vpnService.a((FileDescriptor) obj, jVar);
if (obj != a2) {
}
break;
case 3:
if (obj instanceof Result.Failure) {
throw ((Result.Failure) obj).f19083a;
}
default:
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
}
}
jVar = new j(continuation);
Object obj2 = jVar.f15847a;
Object a22 = kotlin.coroutines.intrinsics.b.a();
switch (jVar.f15848b) {
}
}
@Override
@NotNull
public ArrayList<String> a(@NotNull ArrayList<String> arrayList) {
kotlin.jvm.internal.k.b(arrayList, "cmd");
arrayList.add("-V");
return arrayList;
}
@Nullable
final Object c(@NotNull Continuation<? super FileDescriptor> continuation) {
ProxyInstance c2 = getF15834b().getC();
if (c2 == null) {
kotlin.jvm.internal.k.a();
}
Profile f2 = c2.getF();
VpnService.Builder addDnsServer = new VpnService.Builder(this).setConfigureIntent(Core.d.b().invoke(this)).setSession(f2.y()).setMtu(ConnectionResult.DRIVE_EXTERNAL_STORAGE_REQUIRED).addAddress("172.19.0.1", 30).addDnsServer("172.19.0.2");
if (f2.getM()) {
addDnsServer.addAddress("fdfe:dcba:9876::1", StatisticsBase.UA_MAKE_MONEY_TO_MAKE_MONEY);
addDnsServer.addRoute("::", 0);
}
if (f2.getJ()) {
String packageName = getPackageName();
List b2 = m.b((CharSequence) f2.getN(), new char[]{'\n'}, false, 0, 6, (Object) null);
ArrayList<String> arrayList = new ArrayList();
for (Object obj : b2) {
if (kotlin.coroutines.jvm.internal.b.a(!kotlin.jvm.internal.k.a(obj, (Object) packageName)).booleanValue()) {
arrayList.add(obj);
}
}
for (String str : arrayList) {
try {
if (f2.getK()) {
addDnsServer.addDisallowedApplication(str);
} else {
addDnsServer.addAllowedApplication(str);
Log.d(CustomProfile.f15802a.a(), "addAllowedApplication " + str);
}
} catch (PackageManager.NameNotFoundException e2) {
com.github.shadowsocks.utils.h.a(e2);
}
}
if (f2.getK()) {
addDnsServer.addDisallowedApplication(packageName);
}
}
String h2 = f2.getH();
int hashCode = h2.hashCode();
if (hashCode == -701902949 ? h2.equals("custom-rules") : !(hashCode == 96673 ? !h2.equals("all") : hashCode != 539699250 || !h2.equals("bypass-china"))) {
addDnsServer.addRoute("0.0.0.0", 0);
} else {
String[] stringArray = getResources().getStringArray(R.array.bypass_private_route);
kotlin.jvm.internal.k.a((Object) stringArray, "resources.getStringArray…ray.bypass_private_route)");
for (String str2 : stringArray) {
Subnet.a aVar = Subnet.f16038a;
kotlin.jvm.internal.k.a((Object) str2, "it");
Subnet a2 = aVar.a(str2);
if (a2 == null) {
kotlin.jvm.internal.k.a();
}
addDnsServer.addRoute(a2.getF16039b().getHostAddress(), a2.getC());
}
addDnsServer.addRoute("172.19.0.2", 32);
}
this.e = true;
if (Build.VERSION.SDK_INT >= 22) {
addDnsServer.setUnderlyingNetworks(f());
}
ParcelFileDescriptor establish = addDnsServer.establish();
if (establish == null) {
throw new c();
}
this.c = establish;
ArrayList c3 = kotlin.collections.m.c(new File(getApplicationInfo().nativeLibraryDir, "libtun2socks.so").getAbsolutePath(), "--netif-ipaddr", "172.19.0.2", "--netif-netmask", "255.255.255.0", "--socks-server-addr", DataStore.f16084b.i() + ':' + DataStore.f16084b.j(), "--tunfd", String.valueOf(establish.getFd()), "--tunmtu", String.valueOf(ConnectionResult.DRIVE_EXTERNAL_STORAGE_REQUIRED), "--sock-path", "sock_path", "--dnsgw", "127.0.0.1:" + DataStore.f16084b.l(), "--loglevel", "3", "--app-name", DataStore.f16084b.n());
if (f2.getM()) {
ArrayList arrayList2 = c3;
arrayList2.add("--netif-ip6addr");
arrayList2.add("fdfe:dcba:9876::2");
}
c3.add("--enable-udprelay");
GuardedProcessPool f15813b = getF15834b().getF15813b();
if (f15813b == null) {
kotlin.jvm.internal.k.a();
}
f15813b.a(c3, new k(establish, null));
FileDescriptor fileDescriptor = establish.getFileDescriptor();
kotlin.jvm.internal.k.a((Object) fileDescriptor, "conn.fileDescriptor");
return fileDescriptor;
}
@Metadata(bv = {1, 0, 3}, d1 = {"\u0000\n\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0002\u0010\u0000\u001a\u00020\u0001H\u008a@ø\u0001\u0000¢\u0006\u0004\b\u0002\u0010\u0003"}, d2 = {"<anonymous>", "", "invoke", "(Ljava/lang/Object;)Ljava/lang/Object;"}, k = 3, mv = {1, 1, 13})
@DebugMetadata(c = "com.github.shadowsocks.bg.VpnService$startVpn$5", f = "VpnService.kt", i = {}, l = {222}, m = "invokeSuspend", n = {}, s = {})
public static final class k extends SuspendLambda implements Function1<Continuation<? super u>, Object> {
int f15849a;
final ParcelFileDescriptor c;
k(ParcelFileDescriptor parcelFileDescriptor, Continuation continuation) {
super(1, continuation);
this.c = parcelFileDescriptor;
}
@Override
@NotNull
public final Continuation<u> create(@NotNull Continuation<?> continuation) {
kotlin.jvm.internal.k.b(continuation, "completion");
return new k(this.c, continuation);
}
@Override
public final Object invoke(Continuation<? super u> continuation) {
return ((k) create(continuation)).invokeSuspend(u.f19091a);
}
@Override
@Nullable
public final Object invokeSuspend(@NotNull Object obj) {
Object a2 = kotlin.coroutines.intrinsics.b.a();
try {
switch (this.f15849a) {
case 0:
if (obj instanceof Result.Failure) {
throw ((Result.Failure) obj).f19083a;
}
VpnService vpnService = VpnService.this;
FileDescriptor fileDescriptor = this.c.getFileDescriptor();
kotlin.jvm.internal.k.a((Object) fileDescriptor, "conn.fileDescriptor");
this.f15849a = 1;
if (vpnService.a(fileDescriptor, this) == a2) {
return a2;
}
break;
case 1:
if (!(obj instanceof Result.Failure)) {
break;
} else {
throw ((Result.Failure) obj).f19083a;
}
default:
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
} catch (ErrnoException e) {
VpnService.this.a(false, e.getMessage());
}
return u.f19091a;
}
}
@Nullable
final Object a(@NotNull FileDescriptor fileDescriptor, @NotNull Continuation<? super u> continuation) {
i iVar;
VpnService vpnService;
FileDescriptor fileDescriptor2;
String absolutePath;
int i2;
LocalSocket localSocket;
Throwable th;
if (continuation instanceof i) {
iVar = (i) continuation;
if ((iVar.f15846b & Integer.MIN_VALUE) != 0) {
iVar.f15846b -= Integer.MIN_VALUE;
Object obj = iVar.f15845a;
Object a2 = kotlin.coroutines.intrinsics.b.a();
switch (iVar.f15846b) {
case 0:
if (obj instanceof Result.Failure) {
throw ((Result.Failure) obj).f19083a;
}
vpnService = this;
fileDescriptor2 = fileDescriptor;
absolutePath = new File(Core.d.d().getNoBackupFilesDir(), "sock_path").getAbsolutePath();
i2 = 0;
long j2 = 50 << i2;
iVar.d = vpnService;
iVar.e = fileDescriptor2;
iVar.g = i2;
iVar.f = absolutePath;
iVar.f15846b = 1;
if (DelayKt.delay(j2, iVar) == a2) {
return a2;
}
localSocket = new LocalSocket();
th = (Throwable) null;
try {
LocalSocket localSocket2 = localSocket;
localSocket2.connect(new LocalSocketAddress(absolutePath, LocalSocketAddress.Namespace.FILESYSTEM));
localSocket2.setFileDescriptorsForSend(new FileDescriptor[]{fileDescriptor2});
localSocket2.getOutputStream().write(42);
u uVar = u.f19091a;
kotlin.io.c.a(localSocket, th);
return u.f19091a;
} catch (Throwable th2) {
kotlin.io.c.a(localSocket, th);
throw th2;
}
case 1:
absolutePath = (String) iVar.f;
i2 = iVar.g;
fileDescriptor2 = (FileDescriptor) iVar.e;
vpnService = (VpnService) iVar.d;
try {
} catch (IOException e2) {
if (i2 > 5) {
throw e2;
}
i2++;
break;
}
if (obj instanceof Result.Failure) {
throw ((Result.Failure) obj).f19083a;
}
localSocket = new LocalSocket();
th = (Throwable) null;
LocalSocket localSocket22 = localSocket;
localSocket22.connect(new LocalSocketAddress(absolutePath, LocalSocketAddress.Namespace.FILESYSTEM));
localSocket22.setFileDescriptorsForSend(new FileDescriptor[]{fileDescriptor2});
localSocket22.getOutputStream().write(42);
u uVar2 = u.f19091a;
kotlin.io.c.a(localSocket, th);
return u.f19091a;
default:
throw new IllegalStateException("call to 'resume' before 'invoke' with coroutine");
}
}
}
iVar = new i(continuation);
Object obj2 = iVar.f15845a;
Object a22 = kotlin.coroutines.intrinsics.b.a();
switch (iVar.f15846b) {
}
}
@Override
public void onDestroy() {
super.onDestroy();
getF15834b().getH().close();
}
}