package com.overlook.android.fing.engine.j.g; import android.util.Log; import com.overlook.android.fing.engine.j.h.b; import com.overlook.android.fing.engine.model.net.GeoIpInfo; import com.overlook.android.fing.engine.model.net.IpAddress; import com.overlook.android.fing.ui.mobiletools.traceroute.TracerouteActivity; import com.overlook.android.fing.ui.mobiletools.traceroute.d; import e.f.a.a.a.a2; import e.f.a.a.a.u9; import h.c0; import h.e0; import h.i0; import h.k0; import h.y; import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; import okhttp3.internal.connection.e; /* compiled from: GeoIpMultiResolver */ public class c { /* renamed from: a reason: collision with root package name */ private final Map<IpAddress, GeoIpInfo> f15181a = new HashMap(); private final Set<IpAddress> b = new HashSet(); /* renamed from: c reason: collision with root package name */ private final Object f15182c = new Object(); /* renamed from: d reason: collision with root package name */ private final ExecutorService f15183d; /* renamed from: e reason: collision with root package name */ private final String f15184e; /* renamed from: f reason: collision with root package name */ private final c0 f15185f; /* renamed from: g reason: collision with root package name */ private a f15186g; /* compiled from: GeoIpMultiResolver */ public interface a { } public c() { TimeUnit timeUnit = TimeUnit.SECONDS; this.f15183d = new ThreadPoolExecutor(0, 10, 10, timeUnit, new LinkedBlockingQueue()); this.f15184e = "fingdroid/11.1.0"; c0.a a2 = b.a(); a2.b(4, timeUnit); a2.L(4, timeUnit); a2.I(4, timeUnit); this.f15185f = new c0(a2); } public GeoIpInfo a(IpAddress ipAddress) { GeoIpInfo geoIpInfo; synchronized (this.f15182c) { geoIpInfo = this.f15181a.get(ipAddress); } return geoIpInfo; } /* JADX WARNING: Code restructure failed: missing block: B:34:0x00db, code lost: r2 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:35:0x00dc, code lost: if (r0 != null) goto L_0x00de; */ /* JADX WARNING: Code restructure failed: missing block: B:37:?, code lost: r0.close(); */ /* JADX WARNING: Code restructure failed: missing block: B:38:0x00e2, code lost: r0 = move-exception; */ /* JADX WARNING: Code restructure failed: missing block: B:39:0x00e3, code lost: r1.addSuppressed(r0); */ /* JADX WARNING: Code restructure failed: missing block: B:40:0x00e6, code lost: throw r2; */ public void b(IpAddress ipAddress) { Log.v("fing:geoip-multi", "Fetching GeoIP information for address " + ipAddress); try { y j = y.j("https://internetcheck.fing.com/geoip/v1/record?ip=" + ipAddress.toString() + "&full=true"); if (j != null) { y.a i2 = j.i(); e0.a aVar = new e0.a(); aVar.a("User-Agent", this.f15184e); aVar.a("Accept", "application/protobuf"); aVar.a("X-Api-Key", "7b0d3f48-a6df-48a9-80f7-0f5ca6868503"); aVar.i(i2.c()); i0 k = ((e) this.f15185f.A(aVar.b())).k(); if (k.x()) { k0 b2 = k.b(); if (b2 != null) { byte[] b3 = b2.b(); b2.close(); GeoIpInfo k2 = u9.k((a2) ((com.google.protobuf.c) a2.I).c(new ByteArrayInputStream(b3))); Log.i("fing:geoip-multi", "GeoIP resolution completed for address " + ipAddress + ": " + k2); synchronized (this.f15182c) { this.f15181a.put(ipAddress, k2); } synchronized (this.f15182c) { a aVar2 = this.f15186g; if (aVar2 != null) { TracerouteActivity tracerouteActivity = (TracerouteActivity) aVar2; tracerouteActivity.runOnUiThread(new d(tracerouteActivity)); } } return; } throw new IOException("HTTP response body is empty!"); } throw new IOException("HTTP response invalid (code=" + k.i() + ",message=" + k.y() + ")"); } throw new IOException("Invalid endpoint: https://internetcheck.fing.com/geoip/v1/record"); } catch (Throwable th) { Log.e("fing:geoip-multi", "Failed to perform GeoIP resolution for address " + ipAddress, th); } } public void c() { synchronized (this.f15182c) { this.b.clear(); } } public void d(IpAddress ipAddress) { synchronized (this.f15182c) { if (!this.f15181a.containsKey(ipAddress)) { if (!this.b.contains(ipAddress)) { if (!this.f15183d.isShutdown()) { if (!this.f15183d.isTerminated()) { this.b.add(ipAddress); this.f15183d.execute(new a(this, ipAddress)); } } } } } } public void e(a aVar) { synchronized (this.f15182c) { this.f15186g = aVar; } } /* JADX WARNING: Exception block dominator not found, dom blocks: [] */ /* JADX WARNING: Missing exception handler attribute for start block: B:4:0x0011 */ public void f() { synchronized (this.f15182c) { this.f15183d.shutdown(); this.f15185f.k().a(); } } }