MD5 校验值:d47de9d0b292a5cbd7377502c33607ba
V2RayVpnService.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package com.v2ray.ang.service; import android.content.Intent; import android.content.pm.PackageManager; 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 android.widget.Toast; import c5.a; import c5.d; import c5.f; import c5.g; import c5.h; import com.bumptech.glide.e; import com.tencent.mmkv.MMKV; import com.v2ray.ang.dto.ERoutingMode; import com.v2ray.ang.dto.ServerConfig; import com.v2ray.ang.dto.V2rayConfigModel; import go.libv2ray.gojni.R; 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 java.util.Set; import kotlin.Metadata; import p8.m; import r5.i; import r8.r; @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;", "Lc5/a;", "<init>", "()V", "com/bumptech/glide/manager/o", "v2rayLib_release"}, k = 1, mv = {1, 7, 1}) public final class V2RayVpnService extends VpnService implements a { public Process f2031n; public ParcelFileDescriptor f2032o; public final i f2030m = new i(d.f1419q); public final i f2033p = new i(d.f1418p); public final i f2034q = new i(new f(this, 0)); public final i f2035r = new i(new f(this, 1)); public final MMKV a() { return (MMKV) this.f2030m.getValue(); } public final void b() { String str; boolean z9; String str2; i iVar = d5.a.f2258a; MMKV a10 = a(); if (a10 != null) { str = a10.e("pref_socks_port"); } else { str = null; } int parseInt = Integer.parseInt("10808"); if (str != null) { try { parseInt = Integer.parseInt(str); } catch (Exception e10) { e10.printStackTrace(); } } boolean z10 = false; ArrayList a11 = com.bumptech.glide.f.a(new File(getApplicationContext().getApplicationInfo().nativeLibraryDir, "libtun2socks.so").getAbsolutePath(), "--netif-ipaddr", "26.26.26.2", "--netif-netmask", "255.255.255.252", "--socks-server-addr", a.a.j("127.0.0.1:", parseInt), "--tunmtu", "1500", "--sock-path", "sock_path", "--enable-udprelay", "--loglevel", "notice"); MMKV a12 = a(); if (a12 != null && a12.b("pref_prefer_ipv6")) { z9 = true; } else { z9 = false; } if (z9) { a11.add("--netif-ip6addr"); a11.add("da26:2626::2"); } MMKV a13 = a(); if (a13 != null && a13.b("pref_local_dns_enabled")) { z10 = true; } if (z10) { MMKV a14 = a(); if (a14 != null) { str2 = a14.e("pref_local_dns_port"); } else { str2 = null; } int parseInt2 = Integer.parseInt("10853"); if (str2 != null) { try { parseInt2 = Integer.parseInt(str2); } catch (Exception e11) { e11.printStackTrace(); } } a11.add("--dnsgw"); a11.add("127.0.0.1:" + parseInt2); } Log.d(getPackageName(), a11.toString()); try { ProcessBuilder processBuilder = new ProcessBuilder(a11); processBuilder.redirectErrorStream(true); Process start = processBuilder.directory(getApplicationContext().getFilesDir()).start(); e.l("proBuilder\n …\n .start()", start); this.f2031n = start; String packageName = getPackageName(); Process process = this.f2031n; if (process != null) { Log.d(packageName, process.toString()); c(); } else { e.b0("process"); throw null; } } catch (Exception e12) { Log.d(getPackageName(), e12.toString()); } } public final void c() { ParcelFileDescriptor parcelFileDescriptor = this.f2032o; if (parcelFileDescriptor != null) { FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor(); String absolutePath = new File(getApplicationContext().getFilesDir(), "sock_path").getAbsolutePath(); Log.d(getPackageName(), absolutePath); com.bumptech.glide.f.z(r.f7863b, new h(this, absolutePath, fileDescriptor, null)); return; } e.b0("mInterface"); throw null; } public final void d() { String value; boolean z9; boolean z10; String str; String str2; boolean z11; ParcelFileDescriptor parcelFileDescriptor; Set<String> set; if (VpnService.prepare(this) == null) { VpnService.Builder builder = new VpnService.Builder(this); MMKV a10 = a(); if (a10 == null || (value = a10.e("pref_routing_mode")) == null) { value = ERoutingMode.GLOBAL_PROXY.getValue(); } e.l("settingsStorage?.decodeS…ngMode.GLOBAL_PROXY.value", value); builder.setMtu(1500); builder.addAddress("26.26.26.1", 30); boolean z12 = false; if (!e.h(value, ERoutingMode.BYPASS_LAN.getValue()) && !e.h(value, ERoutingMode.BYPASS_LAN_MAINLAND.getValue())) { builder.addRoute("0.0.0.0", 0); } else { String[] stringArray = getResources().getStringArray(R.array.bypass_private_ip_address); e.l("resources.getStringArray…ypass_private_ip_address)", stringArray); for (String str3 : stringArray) { e.l("it", str3); List j12 = m.j1(str3, new char[]{'/'}); builder.addRoute((String) j12.get(0), Integer.parseInt((String) j12.get(1))); } } MMKV a11 = a(); if (a11 != null && a11.b("pref_prefer_ipv6")) { z9 = true; } else { z9 = false; } if (z9) { builder.addAddress("da26:2626::1", 126); if (!e.h(value, ERoutingMode.BYPASS_LAN.getValue()) && !e.h(value, ERoutingMode.BYPASS_LAN_MAINLAND.getValue())) { builder.addRoute("::", 0); } else { builder.addRoute("2000::", 3); } } MMKV a12 = a(); if (a12 != null && a12.b("pref_local_dns_enabled")) { z10 = true; } else { z10 = false; } if (z10) { builder.addDnsServer("26.26.26.2"); } else { i iVar = d5.a.f2258a; MMKV mmkv = (MMKV) iVar.getValue(); if (mmkv == null || (str = mmkv.e("pref_vpn_dns")) == null) { MMKV mmkv2 = (MMKV) iVar.getValue(); if (mmkv2 != null) { str = mmkv2.e("pref_remote_dns"); } else { str = null; } if (str == null) { str = "1.1.1.1"; } } List k12 = m.k1(str, new String[]{","}); ArrayList arrayList = new ArrayList(); for (Object obj : k12) { if (d5.a.h((String) obj)) { arrayList.add(obj); } } Iterator it = arrayList.iterator(); while (it.hasNext()) { String str4 = (String) it.next(); if (d5.a.h(str4)) { builder.addDnsServer(str4); } } } ServerConfig currentConfig = V2RayServiceManager.INSTANCE.getCurrentConfig(); if (currentConfig != null) { str2 = currentConfig.getRemarks(); } else { str2 = null; } if (str2 == null) { str2 = ""; } builder.setSession(str2); MMKV a13 = a(); if (a13 != null && a13.b("pref_per_app_proxy")) { z11 = true; } else { z11 = false; } if (z11) { MMKV a14 = a(); if (a14 != null) { set = a14.f("pref_per_app_proxy_set", null); } else { set = null; } MMKV a15 = a(); if (a15 != null) { z12 = a15.b("pref_bypass_apps"); } if (set != null) { for (String str5 : set) { if (z12) { try { builder.addDisallowedApplication(str5); } catch (PackageManager.NameNotFoundException unused) { } } else { builder.addAllowedApplication(str5); } } } } try { parcelFileDescriptor = this.f2032o; } catch (Exception unused2) { } if (parcelFileDescriptor != null) { parcelFileDescriptor.close(); if (Build.VERSION.SDK_INT >= 28) { try { ((ConnectivityManager) this.f2034q.getValue()).requestNetwork((NetworkRequest) this.f2033p.getValue(), (g) this.f2035r.getValue()); } catch (Exception e10) { e10.printStackTrace(); } } if (Build.VERSION.SDK_INT >= 29) { builder.setMetered(false); } try { ParcelFileDescriptor establish = builder.establish(); e.j(establish); this.f2032o = establish; b(); return; } catch (Exception e11) { e11.printStackTrace(); e(true); return; } } e.b0("mInterface"); throw null; } } public final void e(boolean z9) { Process process; if (Build.VERSION.SDK_INT >= 28) { try { ((ConnectivityManager) this.f2034q.getValue()).unregisterNetworkCallback((g) this.f2035r.getValue()); } catch (Exception unused) { } } try { Log.d(getPackageName(), "tun2socks destroy"); process = this.f2031n; } catch (Exception e10) { Log.d(getPackageName(), e10.toString()); } if (process != null) { process.destroy(); V2RayServiceManager.INSTANCE.stopV2rayPoint(); if (z9) { stopSelf(); try { ParcelFileDescriptor parcelFileDescriptor = this.f2032o; if (parcelFileDescriptor != null) { parcelFileDescriptor.close(); return; } else { e.b0("mInterface"); throw null; } } catch (Exception unused2) { return; } } return; } e.b0("process"); throw null; } @Override public final void onCreate() { super.onCreate(); StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().permitAll().build()); V2RayServiceManager.INSTANCE.setServiceControl(new SoftReference<>(this)); } @Override public final void onDestroy() { super.onDestroy(); e(true); } @Override public final void onLowMemory() { e(true); super.onLowMemory(); } @Override public final void onRevoke() { e(true); } @Override public final int onStartCommand(Intent intent, int i10, int i11) { String str; if (intent != null && m.P0(intent.getAction(), "STOP_VPN_SERVICE", false)) { e(true); return 2; } if (intent != null) { str = intent.getStringExtra("config"); } else { str = null; } if (str == null) { Toast.makeText(this, "V2Ray config is null", 0).show(); e(true); return 2; } V2RayServiceManager.INSTANCE.startV2rayPoint(V2rayConfigModel.INSTANCE.fromJson(str)); return 1; } }