Fing.apk(点击下载) / k.java


package com.overlook.android.fing.engine.services.agent.desktop;

import android.text.TextUtils;
import com.overlook.android.fing.engine.j.a.b;
import com.overlook.android.fing.engine.l.q;
import com.overlook.android.fing.engine.model.net.Node;
import com.overlook.android.fing.engine.model.net.p;
import com.overlook.android.fing.engine.services.agent.hsp.HailstormApiException;
import com.overlook.android.fing.engine.services.agent.hsp.a;
import com.overlook.android.fing.engine.services.netbox.NetBoxApiException;
import e.f.a.a.a.c;
import e.f.a.a.a.c1;
import e.f.a.a.a.d1;
import e.f.a.a.a.e8;
import e.f.a.a.a.m2;
import e.f.a.a.a.n2;
import e.f.a.a.a.s4;
import e.f.a.a.a.u6;
import e.f.a.a.a.u9;
import e.f.a.a.a.v6;
import e.f.a.a.a.w3;
import e.f.a.a.a.x3;
import e.f.a.a.a.y2;
import e.f.a.a.a.z2;
import h.e0;
import h.i0;
import h.k0;
import h.y;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/* compiled from: DesktopApiClient */
public class k extends com.overlook.android.fing.engine.services.agent.hsp.a {

    /* access modifiers changed from: package-private */
    /* compiled from: DesktopApiClient */
    public class a implements a.AbstractC0154a<n2> {

        /* renamed from: a  reason: collision with root package name */
        final /* synthetic */ String f16033a;
        final /* synthetic */ String b;

        a(k kVar, String str, String str2) {
            this.f16033a = str;
            this.b = str2;
        }

        @Override // com.overlook.android.fing.engine.services.agent.hsp.a.AbstractC0154a
        public void a(s4.b bVar) {
            m2.b W = m2.W();
            String str = this.f16033a;
            if (str != null) {
                W.C(str);
            }
            String str2 = this.b;
            if (str2 != null) {
                W.D(str2);
            }
            W.E("");
            bVar.o0(W);
        }

        /* Return type fixed from 'com.google.protobuf.m' to match base method */
        @Override // com.overlook.android.fing.engine.services.agent.hsp.a.AbstractC0154a
        public n2 b(s4 s4Var) {
            if (s4Var.i3()) {
                return s4Var.A1();
            }
            return null;
        }
    }

    /* access modifiers changed from: package-private */
    /* compiled from: DesktopApiClient */
    public class b implements a.AbstractC0154a<z2> {

        /* renamed from: a  reason: collision with root package name */
        final /* synthetic */ String f16034a;
        final /* synthetic */ boolean b;

        /* renamed from: c  reason: collision with root package name */
        final /* synthetic */ int f16035c;

        /* renamed from: d  reason: collision with root package name */
        final /* synthetic */ long f16036d;

        b(k kVar, String str, boolean z, int i2, long j) {
            this.f16034a = str;
            this.b = z;
            this.f16035c = i2;
            this.f16036d = j;
        }

        @Override // com.overlook.android.fing.engine.services.agent.hsp.a.AbstractC0154a
        public void a(s4.b bVar) {
            y2.b d0 = y2.d0();
            d0.C(this.f16034a);
            d0.G(this.b);
            d0.F(this.f16035c);
            long j = this.f16036d;
            if (j > 0) {
                d0.E(j);
            }
            Calendar instance = Calendar.getInstance();
            instance.set(11, 0);
            instance.set(12, 0);
            instance.set(13, 0);
            instance.set(14, 0);
            d0.D(instance.getTimeInMillis());
            bVar.t0(d0);
        }

        /* Return type fixed from 'com.google.protobuf.m' to match base method */
        @Override // com.overlook.android.fing.engine.services.agent.hsp.a.AbstractC0154a
        public z2 b(s4 s4Var) {
            if (s4Var.s3()) {
                return s4Var.K1();
            }
            return null;
        }
    }

    /* access modifiers changed from: package-private */
    /* compiled from: DesktopApiClient */
    public class c implements a.AbstractC0154a<x3> {

        /* renamed from: a  reason: collision with root package name */
        final /* synthetic */ String f16037a;
        final /* synthetic */ d1 b;

        /* renamed from: c  reason: collision with root package name */
        final /* synthetic */ p f16038c;

        /* renamed from: d  reason: collision with root package name */
        final /* synthetic */ boolean f16039d;

        c(k kVar, String str, d1 d1Var, p pVar, boolean z) {
            this.f16037a = str;
            this.b = d1Var;
            this.f16038c = pVar;
            this.f16039d = z;
        }

        @Override // com.overlook.android.fing.engine.services.agent.hsp.a.AbstractC0154a
        public void a(s4.b bVar) {
            w3.b i0 = w3.i0();
            i0.I(this.f16037a);
            i0.J(((c1) this.b).e(this.f16038c));
            i0.K(this.f16039d);
            bVar.A0(i0);
        }

        /* Return type fixed from 'com.google.protobuf.m' to match base method */
        @Override // com.overlook.android.fing.engine.services.agent.hsp.a.AbstractC0154a
        public x3 b(s4 s4Var) {
            if (s4Var.Q3()) {
                return s4Var.i2();
            }
            return null;
        }
    }

    /* access modifiers changed from: package-private */
    /* compiled from: DesktopApiClient */
    public class d implements a.AbstractC0154a<x3> {

        /* renamed from: a  reason: collision with root package name */
        final /* synthetic */ String f16040a;
        final /* synthetic */ d1 b;

        /* renamed from: c  reason: collision with root package name */
        final /* synthetic */ p f16041c;

        /* renamed from: d  reason: collision with root package name */
        final /* synthetic */ boolean f16042d;

        /* renamed from: e  reason: collision with root package name */
        final /* synthetic */ List f16043e;

        /* renamed from: f  reason: collision with root package name */
        final /* synthetic */ List f16044f;

        /* renamed from: g  reason: collision with root package name */
        final /* synthetic */ List f16045g;

        d(k kVar, String str, d1 d1Var, p pVar, boolean z, List list, List list2, List list3) {
            this.f16040a = str;
            this.b = d1Var;
            this.f16041c = pVar;
            this.f16042d = z;
            this.f16043e = list;
            this.f16044f = list2;
            this.f16045g = list3;
        }

        @Override // com.overlook.android.fing.engine.services.agent.hsp.a.AbstractC0154a
        public void a(s4.b bVar) {
            w3.b i0 = w3.i0();
            i0.I(this.f16040a);
            i0.J(((c1) this.b).e(this.f16041c));
            i0.K(this.f16042d);
            for (Node node : this.f16043e) {
                e8 I = u9.I(node);
                if (I != null) {
                    i0.z(I);
                }
            }
            for (Node node2 : this.f16044f) {
                e8 I2 = u9.I(node2);
                if (I2 != null) {
                    i0.A(I2);
                }
            }
            for (Node node3 : this.f16045g) {
                e8 I3 = u9.I(node3);
                if (I3 != null) {
                    i0.B(I3);
                }
            }
            bVar.A0(i0);
        }

        /* Return type fixed from 'com.google.protobuf.m' to match base method */
        @Override // com.overlook.android.fing.engine.services.agent.hsp.a.AbstractC0154a
        public x3 b(s4 s4Var) {
            if (s4Var.Q3()) {
                return s4Var.i2();
            }
            return null;
        }
    }

    /* access modifiers changed from: package-private */
    /* compiled from: DesktopApiClient */
    public class e implements a.AbstractC0154a<x3> {

        /* renamed from: a  reason: collision with root package name */
        final /* synthetic */ String f16046a;
        final /* synthetic */ List b;

        /* renamed from: c  reason: collision with root package name */
        final /* synthetic */ List f16047c;

        /* renamed from: d  reason: collision with root package name */
        final /* synthetic */ List f16048d;

        e(k kVar, String str, List list, List list2, List list3) {
            this.f16046a = str;
            this.b = list;
            this.f16047c = list2;
            this.f16048d = list3;
        }

        @Override // com.overlook.android.fing.engine.services.agent.hsp.a.AbstractC0154a
        public void a(s4.b bVar) {
            w3.b i0 = w3.i0();
            i0.I(this.f16046a);
            for (Node node : this.b) {
                e8 I = u9.I(node);
                if (I != null) {
                    i0.z(I);
                }
            }
            for (Node node2 : this.f16047c) {
                e8 I2 = u9.I(node2);
                if (I2 != null) {
                    i0.A(I2);
                }
            }
            for (Node node3 : this.f16048d) {
                e8 I3 = u9.I(node3);
                if (I3 != null) {
                    i0.B(I3);
                }
            }
            bVar.A0(i0);
        }

        /* Return type fixed from 'com.google.protobuf.m' to match base method */
        @Override // com.overlook.android.fing.engine.services.agent.hsp.a.AbstractC0154a
        public x3 b(s4 s4Var) {
            if (s4Var.Q3()) {
                return s4Var.i2();
            }
            return null;
        }
    }

    /* access modifiers changed from: private */
    /* compiled from: DesktopApiClient */
    public interface f {
    }

    public k() {
        super(null);
    }

    /* JADX WARNING: Code restructure failed: missing block: B:41:0x00f0, code lost:
        r0 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:42:0x00f1, code lost:
        if (r5 != null) goto L_0x00f3;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:44:?, code lost:
        r5.close();
     */
    /* JADX WARNING: Code restructure failed: missing block: B:45:0x00f7, code lost:
        r5 = move-exception;
     */
    /* JADX WARNING: Code restructure failed: missing block: B:46:0x00f8, code lost:
        r6.addSuppressed(r5);
     */
    /* JADX WARNING: Code restructure failed: missing block: B:47:0x00fb, code lost:
        throw r0;
     */
    private InputStream f(String str, f fVar) throws DesktopApiException {
        try {
            y j = y.j(str);
            if (j != null) {
                y.a i2 = j.i();
                if (!TextUtils.isEmpty(this.b)) {
                    i2.b("ci", this.b);
                }
                if (!TextUtils.isEmpty(this.f16149d)) {
                    i2.b("uai", this.f16149d);
                }
                i2.b("aenc", c.d.CODEC_LZ4.toString());
                e0.a aVar = new e0.a();
                if (this.f16148c != null) {
                    aVar.a("Authorization", "Bearer " + com.overlook.android.fing.engine.i.a.e(this.f16148c.getBytes(StandardCharsets.UTF_8)));
                }
                aVar.i(i2.c());
                i0 k = ((okhttp3.internal.connection.e) this.f16147a.A(aVar.b())).k();
                if (k.x()) {
                    k0 b2 = k.b();
                    if (b2 != null) {
                        byte[] b3 = b2.b();
                        b2.close();
                        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(b3);
                        e.f.a.a.a.c b0 = e.f.a.a.a.c.b0(byteArrayInputStream);
                        if (b0.P() == c.EnumC0200c.OK) {
                            return q.x(b0, byteArrayInputStream);
                        }
                        if (b0.P() == c.EnumC0200c.AUTHFAIL) {
                            throw NetBoxApiException.g("Auth error", b0.U());
                        } else if (b0.P() == c.EnumC0200c.ACCOUNTEXPIRED) {
                            throw NetBoxApiException.e("Account expired", b0.U());
                        } else if (b0.P() == c.EnumC0200c.NETLIMITHIT) {
                            throw NetBoxApiException.i("Network limit reached", b0.U());
                        } else {
                            throw NetBoxApiException.h("Api error", String.valueOf(b0.P()));
                        }
                    } else {
                        throw new IOException("HTTP response body is empty!");
                    }
                } else {
                    throw new IOException("HTTP response invalid (code=" + k.i() + ",message=" + k.y() + ")");
                }
            } else {
                throw new DesktopApiException("Invalid endpoint: " + str);
            }
        } catch (DesktopApiException e2) {
            throw e2;
        } catch (Throwable th) {
            throw new DesktopApiException(th);
        }
    }

    public void e(String str, String str2) throws DesktopApiException {
        try {
            a("https://api.fing.io/1/desktopDeactivateAgent", new a(this, str, str2));
        } catch (HailstormApiException e2) {
            throw new DesktopApiException(e2);
        }
    }

    public List<com.overlook.android.fing.engine.j.a.b> g() throws DesktopApiException {
        try {
            u6 u6Var = (u6) ((com.google.protobuf.c) u6.f21924i).c(f("https://api.fing.io/1/desktopGetAgents", a.f16012a));
            ArrayList arrayList = new ArrayList();
            for (int i2 = 0; i2 < u6Var.S(); i2++) {
                v6 P = u6Var.P(i2);
                b.C0142b y = com.overlook.android.fing.engine.j.a.b.y();
                y.k(P.a0());
                y.n(P.c0());
                y.l(P.b0());
                y.o(P.X());
                y.q(b.d.DESKTOP);
                int ordinal = P.W().ordinal();
                if (ordinal == 0) {
                    y.p(b.c.CONNECTED);
                } else if (ordinal == 1) {
                    y.p(b.c.UNREACHABLE);
                } else if (ordinal == 2) {
                    y.p(b.c.DISCONNECTED);
                }
                arrayList.add(y.i());
            }
            return arrayList;
        } catch (DesktopApiException e2) {
            throw e2;
        } catch (Throwable th) {
            throw new DesktopApiException(th);
        }
    }

    public p h(String str, long j, boolean z, int i2, d1 d1Var) throws DesktopApiException {
        try {
            z2 z2Var = (z2) a("https://api.fing.io/1/desktopGetNetwork", new b(this, str, z, i2, j));
            if (!z2Var.f0()) {
                return null;
            }
            return ((c1) d1Var).c(z2Var.e0(), z2Var.c0(), z2Var.Y(), z2Var.d0(), z2Var.a0(), z2Var.X());
        } catch (HailstormApiException e2) {
            throw new DesktopApiException(e2);
        }
    }

    public void i(String str, p pVar, d1 d1Var, boolean z) throws DesktopApiException {
        try {
            a("https://api.fing.io/1/desktopPutNetwork", new c(this, str, d1Var, pVar, z));
        } catch (HailstormApiException e2) {
            throw new DesktopApiException(e2);
        }
    }

    public void j(String str, p pVar, d1 d1Var, List<Node> list, List<Node> list2, List<Node> list3, boolean z) throws DesktopApiException {
        HailstormApiException e2;
        try {
            try {
                a("https://api.fing.io/1/desktopPutNetwork", new d(this, str, d1Var, pVar, z, list, list2, list3));
            } catch (HailstormApiException e3) {
                e2 = e3;
                throw new DesktopApiException(e2);
            }
        } catch (HailstormApiException e4) {
            e2 = e4;
            throw new DesktopApiException(e2);
        }
    }

    public void k(String str, List<Node> list, List<Node> list2, List<Node> list3) throws DesktopApiException {
        try {
            a("https://api.fing.io/1/desktopPutNetwork", new e(this, str, list, list2, list3));
        } catch (HailstormApiException e2) {
            throw new DesktopApiException(e2);
        }
    }
}