package d.d.a.j; import android.os.Handler; import android.os.Message; import android.text.TextUtils; import com.efs.sdk.base.core.util.NetworkUtil; import d.d.a.g.f; import d.d.a.g.g; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.regex.Matcher; import java.util.regex.Pattern; import okhttp3.ResponseBody; public class k { private String a; Handler b; class a extends Handler { a(k kVar) { } public void handleMessage(Message message) { super.handleMessage(message); if (message.arg1 == 1) { d.d.a.h.a.b().g(f.c().l()); } } } /* access modifiers changed from: package-private */ public class b implements d.d.a.i.d<ResponseBody> { b() { } @Override // d.d.a.i.d public void a(String str) { } /* renamed from: b */ public void onNext(ResponseBody responseBody) { if (responseBody != null) { try { k.this.a = responseBody.string(); } catch (IOException e2) { e2.printStackTrace(); } } } } /* access modifiers changed from: package-private */ public class c implements Runnable { c() { } public void run() { URL url; synchronized (k.class) { try { url = new URL(d.d.a.e.d.f2721d); } catch (MalformedURLException e2) { e2.printStackTrace(); url = null; } String host = url.getHost(); d.d.a.g.c.c(" ------ 开始MTR " + host); String e3 = k.this.e(host); d.d.a.g.c.c(" ------ MTR结果 " + e3); i0.b(e3, 0); Message message = new Message(); message.arg1 = 1; k.this.b.sendMessage(message); } } } /* access modifiers changed from: private */ public static class d { private static final k a = new k(null); } /* synthetic */ k(a aVar) { this(); } public static k d() { return d.a; } /* access modifiers changed from: private */ /* access modifiers changed from: public */ /* JADX WARNING: Removed duplicated region for block: B:56:0x01ac */ /* JADX WARNING: Removed duplicated region for block: B:61:0x01d1 */ private String e(String str) { Exception e2; Runtime runtime; String str2; Runtime runtime2; String str3; try { ArrayList arrayList = new ArrayList(); Runtime runtime3 = Runtime.getRuntime(); String str4 = null; for (int i = 1; i < 31; i++) { d.d.a.g.c.c("ping -n -c 1 -t " + i + " " + str); Process exec = runtime3.exec("ping -n -c 1 -t " + i + " " + str); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(exec.getInputStream())); while (true) { String readLine = bufferedReader.readLine(); if (readLine == null) { str3 = NetworkUtil.NETWORK_CLASS_UNKNOWN; break; } else if (TextUtils.isEmpty(str4) && readLine.toLowerCase().startsWith("ping")) { Matcher matcher = Pattern.compile(".*\\((\\d+\\.\\d+\\.\\d+\\.\\d+).*").matcher(readLine); if (matcher.find()) { str4 = matcher.group(1); } } else if (readLine.toLowerCase().startsWith("from")) { Matcher matcher2 = Pattern.compile("[fF]rom (.*\\(.*\\)|.*): .*").matcher(readLine); if (matcher2.find()) { str3 = matcher2.group(1); break; } } else if (readLine.contains(" bytes from ")) { Matcher matcher3 = Pattern.compile("\\d+ bytes from (\\d+\\.\\d+.\\d+.\\d+):.*").matcher(readLine); if (matcher3.find()) { str3 = matcher3.group(1); break; } } else { continue; } } d.d.a.g.c.c("ping 的返回数据 " + str3); arrayList.add(str3); if (!TextUtils.isEmpty(str4) && arrayList.size() > 0 && str4.equals(arrayList.get(arrayList.size() - 1))) { break; } if (exec != null) { try { exec.exitValue(); } catch (IllegalThreadStateException unused) { exec.destroy(); } } } StringBuilder sb = new StringBuilder(); sb.append("域名:"); sb.append(str); sb.append("\n"); sb.append("IP地址:"); sb.append(str4); sb.append("\n"); sb.append("格式: IP 丢包率 最低延迟 平均延迟 最高延迟\n"); int i2 = 0; while (i2 < arrayList.size()) { if (NetworkUtil.NETWORK_CLASS_UNKNOWN.equals(arrayList.get(i2))) { str2 = i2 + ",unknown"; runtime = runtime3; } else { Process exec2 = runtime3.exec("ping -c 10 " + ((String) arrayList.get(i2))); BufferedReader bufferedReader2 = new BufferedReader(new InputStreamReader(exec2.getInputStream())); String str5 = "faild"; String str6 = str5; String str7 = str6; String str8 = str7; while (true) { String readLine2 = bufferedReader2.readLine(); if (readLine2 == null) { break; } if (readLine2.contains("packet loss")) { Matcher matcher4 = Pattern.compile(".*, (\\d+)\\% packet loss,.*").matcher(readLine2); if (matcher4.find()) { runtime2 = runtime3; str5 = matcher4.group(1); if (!readLine2.contains("min/avg/max/")) { Matcher matcher5 = Pattern.compile(".*min/avg/max/mdev = (.*)/(.*)/(.*)/(.*) .*").matcher(readLine2); if (matcher5.find()) { str6 = matcher5.group(1); str7 = matcher5.group(2); str8 = matcher5.group(3); } runtime3 = runtime2; } else { runtime3 = runtime2; } } } runtime2 = runtime3; if (!readLine2.contains("min/avg/max/")) { } } runtime = runtime3; exec2.destroy(); str2 = i2 + " , " + ((String) arrayList.get(i2)) + " " + str5 + "% " + str6 + " " + str7 + " " + str8 + " "; } sb.append(str2); sb.append("\n"); i2++; runtime3 = runtime; } sb.append("用户IP信息:"); try { sb.append(this.a); sb.append("\n"); return sb.toString(); } catch (Exception e3) { e2 = e3; e2.printStackTrace(); return e2.getMessage(); } } catch (Exception e4) { e2 = e4; e2.printStackTrace(); return e2.getMessage(); } } public void c() { d.d.a.e.d.y().z(new d.d.a.i.c(new b()), "http://ip.taobao.com/service/getIpInfo.php?ip=myip"); d.d.a.h.a.b().f(f.c().l()); g.d("mtr").a(new c()); } private k() { this.a = " 获取IP信息失败"; this.b = new a(this); } }