CarrotChat v2.8.80.240429版本的 MD5 值为:fdf98761f01e715a89df24b85b0d206e
以下内容为反编译后的 AKCDiscoverNode.java 源代码,内容仅作参考
package ak.im.module;
import ak.application.AKApplication;
import ak.im.BuildConfig;
import ak.im.module.AKCDiscoverGlobal;
import ak.im.module.AKCDiscoverNode;
import ak.im.sdk.manager.AKCDiscoverManager;
import ak.im.sdk.manager.f1;
import ak.im.uitls.AKCAppConfiguration;
import ak.im.uitls.AKCCheckPoint;
import ak.im.utils.AkeyChatUtils;
import ak.im.utils.HttpURLTools;
import ak.im.utils.Log;
import android.annotation.SuppressLint;
import android.os.Build;
import android.text.TextUtils;
import com.meizu.cloud.pushsdk.notification.model.NotifyType;
import com.mobile.auth.gatewayauth.Constant;
import fc.b0;
import fc.c0;
import fc.z;
import j.y1;
import j0.t;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import kd.s;
import kotlin.Metadata;
import kotlin.Pair;
import kotlin.collections.CollectionsKt__CollectionsKt;
import kotlin.collections.CollectionsKt___CollectionsKt;
import kotlin.collections.x;
import kotlin.jvm.internal.Ref$BooleanRef;
import kotlin.jvm.internal.o;
import kotlin.jvm.internal.r;
import kotlin.text.StringsKt__StringsKt;
import okhttp3.internal.http2.ErrorCode;
import okhttp3.internal.http2.StreamResetException;
import okhttp3.p;
import org.apache.commons.httpclient.cookie.Cookie2;
import org.apache.http.HttpHost;
import org.apache.http.client.cache.HeaderConstants;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jivesoftware.smack.roster.packet.RosterVer;
import retrofit2.HttpException;
@Metadata(bv = {}, d1 = {"\u0000D\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010$\n\u0002\u0010\t\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b3\n\u0002\u0018\u0002\n\u0002\b#\u0018\u0000 h2\u00020\u0001:\u0002hiB\u0007¢\u0006\u0004\bf\u0010gJ\b\u0010\u0003\u001a\u00020\u0002H\u0016J\u0012\u0010\u0006\u001a\u000e\u0012\u0004\u0012\u00020\u0002\u0012\u0004\u0012\u00020\u00050\u0004J\u0006\u0010\u0007\u001a\u00020\u0005J\u0006\u0010\t\u001a\u00020\bJ\u0016\u0010\r\u001a\b\u0012\u0004\u0012\u00020\n0\f2\b\b\u0002\u0010\u000b\u001a\u00020\nJ\u000e\u0010\u0010\u001a\u00020\b2\u0006\u0010\u000f\u001a\u00020\u000eJ\u0016\u0010\u0014\u001a\u00020\u00132\u0006\u0010\u0011\u001a\u00020\u000e2\u0006\u0010\u0012\u001a\u00020\u0002J\u000e\u0010\u0016\u001a\u00020\b2\u0006\u0010\u0015\u001a\u00020\u000eR\"\u0010\u0017\u001a\u00020\u00028\u0006@\u0006X\u0087\u000e¢\u0006\u0012\n\u0004\b\u0017\u0010\u0018\u001a\u0004\b\u0019\u0010\u001a\"\u0004\b\u001b\u0010\u001cR\"\u0010\u001d\u001a\u00020\u00028\u0006@\u0006X\u0087\u000e¢\u0006\u0012\n\u0004\b\u001d\u0010\u0018\u001a\u0004\b\u001e\u0010\u001a\"\u0004\b\u001f\u0010\u001cR\"\u0010 \u001a\u00020\u00028\u0006@\u0006X\u0087\u000e¢\u0006\u0012\n\u0004\b \u0010\u0018\u001a\u0004\b!\u0010\u001a\"\u0004\b\"\u0010\u001cR\"\u0010#\u001a\u00020\u00028\u0006@\u0006X\u0087\u000e¢\u0006\u0012\n\u0004\b#\u0010\u0018\u001a\u0004\b$\u0010\u001a\"\u0004\b%\u0010\u001cR.\u0010&\u001a\u000e\u0012\u0004\u0012\u00020\u0002\u0012\u0004\u0012\u00020\u00050\u00048\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\b&\u0010'\u001a\u0004\b(\u0010)\"\u0004\b*\u0010+R\"\u0010,\u001a\u00020\u00028\u0006@\u0006X\u0087\u000e¢\u0006\u0012\n\u0004\b,\u0010\u0018\u001a\u0004\b-\u0010\u001a\"\u0004\b.\u0010\u001cR\"\u0010/\u001a\u00020\u00028\u0006@\u0006X\u0087\u000e¢\u0006\u0012\n\u0004\b/\u0010\u0018\u001a\u0004\b0\u0010\u001a\"\u0004\b1\u0010\u001cR\"\u00102\u001a\u00020\u00028\u0006@\u0006X\u0087\u000e¢\u0006\u0012\n\u0004\b2\u0010\u0018\u001a\u0004\b3\u0010\u001a\"\u0004\b4\u0010\u001cR\"\u00105\u001a\u00020\u00028\u0006@\u0006X\u0087\u000e¢\u0006\u0012\n\u0004\b5\u0010\u0018\u001a\u0004\b6\u0010\u001a\"\u0004\b7\u0010\u001cR\"\u00108\u001a\u00020\u00028\u0006@\u0006X\u0087\u000e¢\u0006\u0012\n\u0004\b8\u0010\u0018\u001a\u0004\b9\u0010\u001a\"\u0004\b:\u0010\u001cR\"\u0010;\u001a\u00020\u00028\u0006@\u0006X\u0087\u000e¢\u0006\u0012\n\u0004\b;\u0010\u0018\u001a\u0004\b<\u0010\u001a\"\u0004\b=\u0010\u001cR\"\u0010>\u001a\u00020\u00028\u0006@\u0006X\u0087\u000e¢\u0006\u0012\n\u0004\b>\u0010\u0018\u001a\u0004\b?\u0010\u001a\"\u0004\b@\u0010\u001cR\"\u0010A\u001a\u00020\u00028\u0006@\u0006X\u0087\u000e¢\u0006\u0012\n\u0004\bA\u0010\u0018\u001a\u0004\bB\u0010\u001a\"\u0004\bC\u0010\u001cR\"\u0010D\u001a\u00020\u00028\u0006@\u0006X\u0087\u000e¢\u0006\u0012\n\u0004\bD\u0010\u0018\u001a\u0004\bE\u0010\u001a\"\u0004\bF\u0010\u001cR\"\u0010H\u001a\u00020G8\u0006@\u0006X\u0087\u000e¢\u0006\u0012\n\u0004\bH\u0010I\u001a\u0004\bJ\u0010K\"\u0004\bL\u0010MR\"\u0010N\u001a\u00020\u000e8\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\bN\u0010O\u001a\u0004\bP\u0010Q\"\u0004\bR\u0010SR\"\u0010T\u001a\u00020\u000e8\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\bT\u0010O\u001a\u0004\bU\u0010Q\"\u0004\bV\u0010SR\"\u0010W\u001a\u00020\u00028\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\bW\u0010\u0018\u001a\u0004\bX\u0010\u001a\"\u0004\bY\u0010\u001cR\"\u0010Z\u001a\u00020\u00058\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\bZ\u0010[\u001a\u0004\b\\\u0010]\"\u0004\b^\u0010_R\"\u0010`\u001a\u00020\u000e8\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\b`\u0010O\u001a\u0004\ba\u0010Q\"\u0004\bb\u0010SR\"\u0010c\u001a\u00020\u000e8\u0006@\u0006X\u0086\u000e¢\u0006\u0012\n\u0004\bc\u0010O\u001a\u0004\bd\u0010Q\"\u0004\be\u0010S¨\u0006j"}, d2 = {"Lak/im/module/AKCDiscoverNode;", "", "", "toString", "", "", "getServerNodePort", "httpPort", "Lkd/s;", "save", "", "need", "Lfc/z;", "detect", "", "score", "calculateTheDetectScoreByRule", "policys", "searchKey", "Lak/im/module/AKCDiscoverGlobal$DiscoverInstanceResponse;", "queryDiscoverInstance", "t", CtrlMessage.REPORT, "id", "Ljava/lang/String;", "getId", "()Ljava/lang/String;", "setId", "(Ljava/lang/String;)V", "ip", "getIp", "setIp", "location", "getLocation", "setLocation", Constant.LOGIN_ACTIVITY_VENDOR_KEY, "getVendor", "setVendor", Cookie2.PORT, "Ljava/util/Map;", "getPort", "()Ljava/util/Map;", "setPort", "(Ljava/util/Map;)V", "nodeParentId", "getNodeParentId", "setNodeParentId", "nodeType", "getNodeType", "setNodeType", "nodeName", "getNodeName", "setNodeName", "nodeManageIp", "getNodeManageIp", "setNodeManageIp", "nodeManagePort", "getNodeManagePort", "setNodeManagePort", "nodeStatus", "getNodeStatus", "setNodeStatus", "dataValid", "getDataValid", "setDataValid", "creatTime", "getCreatTime", "setCreatTime", "updateTime", "getUpdateTime", "setUpdateTime", "Lak/im/module/AKCDiscoverNode$DiscoverPort;", "discoveryServerNodePort", "Lak/im/module/AKCDiscoverNode$DiscoverPort;", "getDiscoveryServerNodePort", "()Lak/im/module/AKCDiscoverNode$DiscoverPort;", "setDiscoveryServerNodePort", "(Lak/im/module/AKCDiscoverNode$DiscoverPort;)V", "detectScore", "I", "getDetectScore", "()I", "setDetectScore", "(I)V", "detectSuccessCount", "getDetectSuccessCount", "setDetectSuccessCount", "detectSuccessType", "getDetectSuccessType", "setDetectSuccessType", "detectSuccessLastTime", "J", "getDetectSuccessLastTime", "()J", "setDetectSuccessLastTime", "(J)V", "detectCount", "getDetectCount", "setDetectCount", "detectFailedCount", "getDetectFailedCount", "setDetectFailedCount", "<init>", "()V", "Companion", "DiscoverPort", "ak-im_carrotArmV7Release"}, k = 1, mv = {1, 6, 0})
public final class AKCDiscoverNode {
@NotNull
public static final Companion INSTANCE = new Companion(null);
public static final boolean INDEBUG = false;
@NotNull
public static final String TAG = "DISCOVER|AKCDiscoverNode";
@s6.c("creatTime")
@NotNull
private String creatTime;
@s6.c("dataValid")
@NotNull
private String dataValid;
private int detectCount;
private int detectFailedCount;
private int detectScore;
private int detectSuccessCount;
private long detectSuccessLastTime;
@NotNull
private String detectSuccessType;
@s6.c("discoveryServerNodePort")
@NotNull
private DiscoverPort discoveryServerNodePort;
@s6.c("nodeManageIp")
@NotNull
private String nodeManageIp;
@s6.c("nodeManagePort")
@NotNull
private String nodeManagePort;
@s6.c("nodeName")
@NotNull
private String nodeName;
@s6.c("nodeParentId")
@NotNull
private String nodeParentId;
@s6.c("nodeStatus")
@NotNull
private String nodeStatus;
@s6.c("nodeType")
@NotNull
private String nodeType;
@NotNull
private Map<String, Long> port;
@s6.c("updateTime")
@NotNull
private String updateTime;
@s6.c("nodeId")
@NotNull
private String id = "";
@s6.c("nodeIp")
@NotNull
private String ip = "";
@s6.c("nodeLocation")
@NotNull
private String location = "";
@s6.c("nodeVendor")
@NotNull
private String vendor = "";
@kd.g(d1 = {"\u0000\u0014\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\b\u0018\u00002\u00020\u0001B\u0005¢\u0006\u0002\u0010\u0002R\u001a\u0010\u0003\u001a\u00020\u0004X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0005\u0010\u0006\"\u0004\b\u0007\u0010\bR\u001a\u0010\t\u001a\u00020\u0004X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\n\u0010\u0006\"\u0004\b\u000b\u0010\b¨\u0006\f"}, d2 = {"Lak/im/module/AKCDiscoverNode$DiscoverPort;", "", "()V", HttpHost.DEFAULT_SCHEME_NAME, "", "getHttp", "()Ljava/lang/String;", "setHttp", "(Ljava/lang/String;)V", "https", "getHttps", "setHttps", "ak-im_carrotArmV7Release"}, k = 1, mv = {1, 6, 0}, xi = 48)
public static final class DiscoverPort {
@NotNull
private String http = "";
@NotNull
private String https = "";
@NotNull
public final String getHttp() {
return this.http;
}
@NotNull
public final String getHttps() {
return this.https;
}
public final void setHttp(@NotNull String str) {
r.checkNotNullParameter(str, "<set-?>");
this.http = str;
}
public final void setHttps(@NotNull String str) {
r.checkNotNullParameter(str, "<set-?>");
this.https = str;
}
}
public AKCDiscoverNode() {
Map<String, Long> mapOf;
mapOf = x.mapOf(kd.i.to(HttpHost.DEFAULT_SCHEME_NAME, 8336L), kd.i.to("https", 8663L));
this.port = mapOf;
this.nodeParentId = "";
this.nodeType = "";
this.nodeName = "";
this.nodeManageIp = "";
this.nodeManagePort = "";
this.nodeStatus = "";
this.dataValid = "";
this.creatTime = "";
this.updateTime = "";
this.discoveryServerNodePort = new DiscoverPort();
this.detectScore = 300;
this.detectSuccessType = "";
}
public static z detect$default(AKCDiscoverNode aKCDiscoverNode, boolean z10, int i10, Object obj) {
if ((i10 & 1) != 0) {
z10 = true;
}
return aKCDiscoverNode.detect(z10);
}
public static final void m5detect$lambda0(o0.b retrofit, final AKCDiscoverNode this$0, final long j10, final b0 result) {
r.checkNotNullParameter(retrofit, "$retrofit");
r.checkNotNullParameter(this$0, "this$0");
r.checkNotNullParameter(result, "result");
retrofit.getAKAPI(5).speedTest().subscribeOn(gd.b.io()).subscribe(new v0.a<retrofit2.j<ye.n>>() {
@Override
public void onError(@NotNull Throwable e10) {
r.checkNotNullParameter(e10, "e");
Log.d(AKCDiscoverNode.TAG, "lwxdetect onError " + AKCDiscoverNode.this.getIp() + ':' + AKCDiscoverNode.this.httpPort());
if (t.isNetWorkAvailableInPhysical()) {
if (e10 instanceof HttpException) {
AKCDiscoverNode.this.report(AKCDiscoverGlobal.AKCDiscoverError_NodeDetect_Api_Error);
} else if (AkeyChatUtils.IsOrContainCertificateException(e10)) {
AKCDiscoverNode.this.report(AKCDiscoverGlobal.AKCDiscoverError_NodeDetect_PeerInvalid_Error);
} else if (AkeyChatUtils.IsCertificateDateValidException(e10)) {
AKCDiscoverNode.this.report(100007);
} else {
AKCDiscoverNode.this.report(100007);
}
}
AKCDiscoverNode aKCDiscoverNode = AKCDiscoverNode.this;
aKCDiscoverNode.setDetectFailedCount(aKCDiscoverNode.getDetectFailedCount() + 1);
AKCDiscoverNode.this.calculateTheDetectScoreByRule(5000);
AKCDiscoverNode.this.save();
result.onNext(Boolean.FALSE);
}
@Override
public void onNext(@NotNull retrofit2.j<ye.n> response) {
r.checkNotNullParameter(response, "response");
if (204 != response.code() && 200 != response.code()) {
if (response.code() > 0) {
AKCDiscoverNode.this.report(response.code() + AKCDiscoverGlobal.AKCDiscoverError_NodeDetect_Error);
} else {
AKCDiscoverNode.this.report(AKCDiscoverGlobal.AKCDiscoverError_NodeDetect_Api_Error);
}
AKCDiscoverNode aKCDiscoverNode = AKCDiscoverNode.this;
aKCDiscoverNode.setDetectFailedCount(aKCDiscoverNode.getDetectFailedCount() + 1);
AKCDiscoverNode.this.calculateTheDetectScoreByRule(5000);
Log.e(AKCDiscoverNode.TAG, "lwxdetect fail " + AKCDiscoverNode.this.getId());
AKCDiscoverNode.this.save();
result.onNext(Boolean.FALSE);
} else {
AKCDiscoverNode.this.setDetectSuccessLastTime(System.currentTimeMillis());
AKCDiscoverNode aKCDiscoverNode2 = AKCDiscoverNode.this;
aKCDiscoverNode2.calculateTheDetectScoreByRule((int) (aKCDiscoverNode2.getDetectSuccessLastTime() - j10));
AKCDiscoverNode aKCDiscoverNode3 = AKCDiscoverNode.this;
aKCDiscoverNode3.setDetectSuccessCount(aKCDiscoverNode3.getDetectSuccessCount() + 1);
AKCDiscoverNode.this.setDetectFailedCount(0);
Log.d(AKCDiscoverNode.TAG, AKCDiscoverNode.this.getIp() + ':' + AKCDiscoverNode.this.httpPort() + " lwxdetect success,detectScore:" + AKCDiscoverNode.this.getDetectScore() + ",detectSuccessCount:" + AKCDiscoverNode.this.getDetectSuccessCount());
AKCDiscoverNode.this.save();
result.onNext(Boolean.TRUE);
}
AKCDiscoverNode aKCDiscoverNode4 = AKCDiscoverNode.this;
aKCDiscoverNode4.setDetectScore((aKCDiscoverNode4.getDetectScore() * (AKCDiscoverNode.this.getDetectCount() - 1)) / AKCDiscoverNode.this.getDetectCount());
}
});
}
public final void calculateTheDetectScoreByRule(int i10) {
int i11 = this.detectScore;
int i12 = this.detectCount;
this.detectScore = ((i11 * (i12 - 1)) + i10) / i12;
}
@NotNull
public final z<Boolean> detect(boolean need) {
if (!need) {
z<Boolean> just = z.just(Boolean.TRUE);
r.checkNotNullExpressionValue(just, "just(true)");
return just;
}
if (AKApplication.f777d) {
z<Boolean> just2 = z.just(Boolean.TRUE);
r.checkNotNullExpressionValue(just2, "just(true)");
return just2;
}
if (!t.isNetWorkAvailableInPhysical()) {
z<Boolean> just3 = z.just(Boolean.TRUE);
r.checkNotNullExpressionValue(just3, "just(true)");
return just3;
}
this.detectCount++;
final long currentTimeMillis = System.currentTimeMillis();
final o0.b bVar = new o0.b("https://" + this.ip + ':' + httpPort(), false, false);
z<Boolean> create = z.create(new c0() {
@Override
public final void subscribe(b0 b0Var) {
AKCDiscoverNode.m5detect$lambda0(o0.b.this, this, currentTimeMillis, b0Var);
}
});
r.checkNotNullExpressionValue(create, "create { result ->\n … })\n }");
return create;
}
@NotNull
public final String getCreatTime() {
return this.creatTime;
}
@NotNull
public final String getDataValid() {
return this.dataValid;
}
public final int getDetectCount() {
return this.detectCount;
}
public final int getDetectFailedCount() {
return this.detectFailedCount;
}
public final int getDetectScore() {
return this.detectScore;
}
public final int getDetectSuccessCount() {
return this.detectSuccessCount;
}
public final long getDetectSuccessLastTime() {
return this.detectSuccessLastTime;
}
@NotNull
public final String getDetectSuccessType() {
return this.detectSuccessType;
}
@NotNull
public final DiscoverPort getDiscoveryServerNodePort() {
return this.discoveryServerNodePort;
}
@NotNull
public final String getId() {
return this.id;
}
@NotNull
public final String getIp() {
return this.ip;
}
@NotNull
public final String getLocation() {
return this.location;
}
@NotNull
public final String getNodeManageIp() {
return this.nodeManageIp;
}
@NotNull
public final String getNodeManagePort() {
return this.nodeManagePort;
}
@NotNull
public final String getNodeName() {
return this.nodeName;
}
@NotNull
public final String getNodeParentId() {
return this.nodeParentId;
}
@NotNull
public final String getNodeStatus() {
return this.nodeStatus;
}
@NotNull
public final String getNodeType() {
return this.nodeType;
}
@NotNull
public final Map<String, Long> getPort() {
return this.port;
}
@NotNull
public final Map<String, Long> getServerNodePort() {
Map<String, Long> mapOf;
mapOf = x.mapOf(kd.i.to(HttpHost.DEFAULT_SCHEME_NAME, Long.valueOf(Long.parseLong(this.discoveryServerNodePort.getHttp()))), kd.i.to("https", Long.valueOf(Long.parseLong(this.discoveryServerNodePort.getHttps()))));
return mapOf;
}
@NotNull
public final String getUpdateTime() {
return this.updateTime;
}
@NotNull
public final String getVendor() {
return this.vendor;
}
public final long httpPort() {
Map<String, Long> mapOf;
Long l10;
mapOf = x.mapOf(kd.i.to(HttpHost.DEFAULT_SCHEME_NAME, 8336L), kd.i.to("https", 8663L));
try {
mapOf = getServerNodePort();
} catch (Throwable th) {
th.printStackTrace();
}
if (mapOf.containsKey("https")) {
l10 = mapOf.get("https");
if (l10 == null) {
throw new NullPointerException("null cannot be cast to non-null type kotlin.Long");
}
} else {
l10 = mapOf.get(HttpHost.DEFAULT_SCHEME_NAME);
if (l10 == null) {
throw new NullPointerException("null cannot be cast to non-null type kotlin.Long");
}
}
return l10.longValue();
}
@NotNull
public final AKCDiscoverGlobal.DiscoverInstanceResponse queryDiscoverInstance(int policys, @NotNull final String searchKey) {
HashMap hashMapOf;
String str;
int addFlag;
Object obj;
Object obj2;
int i10;
long currentTimeMillis;
r.checkNotNullParameter(searchKey, "searchKey");
Log.i(TAG, "discover server " + searchKey + " in node " + this.ip + ",in" + Thread.currentThread().getName());
if (AKCCheckPoint.isChecking("CHECKPOINT_LOGIN") != null) {
AKCCheckPoint.actionPointStart("CHECKPOINT_LOGIN", "idp");
}
AKCDiscoverGlobal.DiscoverInstanceResponse discoverInstanceResponse = new AKCDiscoverGlobal.DiscoverInstanceResponse(1, null, new AKCDiscoverGlobal.DiscoverError(-1, "", 0, 4, null));
try {
hashMapOf = x.hashMapOf(kd.i.to(IMMessage.CARD_SERVER_KEY, searchKey), kd.i.to("product", BuildConfig.PRODUCT_TYPE), kd.i.to("deviceType", "android"), kd.i.to("deviceId", f1.getInstance().getmLoginCfg().getUuid()), kd.i.to(RosterVer.ELEMENT, f1.getInstance().getVersion()));
AKCDiscoverGlobal.Companion companion = AKCDiscoverGlobal.Companion;
okhttp3.c apiCall$default = AKCDiscoverGlobal.Companion.apiCall$default(companion, "https://" + this.ip + ':' + httpPort(), AKCDiscoverGlobal.DISCOVER_INSTANCE_API, 0, HeaderConstants.GET_METHOD, hashMapOf, false, 5L, null, 128, null);
if (apiCall$default != null) {
Log.d(TAG, "discover instance will execute");
p execute = apiCall$default.execute();
Log.d(TAG, "discover instance executed." + execute.code());
if (AKCCheckPoint.isChecking("CHECKPOINT_LOGIN") != null) {
AKCCheckPoint.actionPointEnd("CHECKPOINT_LOGIN", "idp");
}
if (execute.code() != 200) {
Log.e(TAG, "discover instance err " + execute.code());
calculateTheDetectScoreByRule(5000);
save();
discoverInstanceResponse.getError().setCode(AKCDiscoverGlobal.AKCDiscoverError_IDParse_Response_Error);
AKCDiscoverGlobal.DiscoverError error = discoverInstanceResponse.getError();
String string = j.a.get().getString(y1.login_failed_hint_20, String.valueOf(execute.code()));
r.checkNotNullExpressionValue(string, "get().getString(R.string…sponse.code().toString())");
error.setDescription(string);
discoverInstanceResponse.getError().setHttpStatusCode(execute.code());
} else {
String header = execute.header("x-ak-geo", "CN");
String header2 = execute.header("x-ak-ip", "");
ye.n body = execute.body();
com.google.gson.l asJsonObject = com.google.gson.m.parseString(body != null ? body.string() : null).getAsJsonObject();
Log.e("返回数据", asJsonObject.toString());
if (asJsonObject.has("return_code") && asJsonObject.has("description")) {
int asInt = asJsonObject.get("return_code").getAsInt();
if (asInt == 0 && asJsonObject.has("return_ob")) {
com.google.gson.l return_ob = asJsonObject.get("return_ob").getAsJsonObject();
Log.d(TAG, "discover instance success will load");
okhttp3.k headers = execute.headers();
if (TextUtils.isEmpty(headers != null ? headers.get("X-AK-Loc") : null)) {
str = "CN";
} else {
okhttp3.k headers2 = execute.headers();
str = headers2 != null ? headers2.get("X-AK-Loc") : null;
r.checkNotNull(str);
}
Log.d(TAG, "discover instance loc:" + str);
return_ob.addProperty("location", str);
return_ob.addProperty("geo", header);
AKCDiscoverInstance discoverInstance = companion.getDiscoverInstance(companion.getDISCOVERINSTANCE_CACHE_PERFIX() + searchKey, new vd.a<AKCDiscoverInstance>() {
{
super(0);
}
@Override
@Nullable
public final AKCDiscoverInstance invoke() {
AKCDiscoverInstance aKCDiscoverInstance = new AKCDiscoverInstance();
aKCDiscoverInstance.setSearchKey(searchKey);
return aKCDiscoverInstance;
}
});
r.checkNotNull(discoverInstance);
discoverInstance.scoreServerNetInfo(1);
ServerNetInfo serverNetInfo = discoverInstance.getBestAccessServerNetInfo() != -1 ? discoverInstance.getServer_net_info().get(discoverInstance.getBestAccessServerNetInfo()) : null;
s sVar = s.f40925a;
return_ob.addProperty("nodeId", this.id);
return_ob.addProperty("deviceIp", header2);
r.checkNotNullExpressionValue(return_ob, "return_ob");
discoverInstance.load(return_ob);
Pair<Boolean, AKCDiscoverInstance> isChange = discoverInstance.isChange();
if (isChange.getFirst().booleanValue()) {
StringBuilder sb2 = new StringBuilder();
sb2.append("instance changed,current:");
sb2.append(discoverInstance);
sb2.append(",local:");
sb2.append(isChange.getSecond() == null ? "null" : isChange.getSecond());
Log.e(TAG, sb2.toString());
}
AKCDiscoverInstance second = isChange.getSecond();
if (second != null) {
int i11 = 0;
for (int size = discoverInstance.getServer_net_info().size(); i11 < size; size = i10) {
Iterator<T> it = second.getServer_net_info().iterator();
while (true) {
if (!it.hasNext()) {
obj2 = null;
break;
}
obj2 = it.next();
if (r.areEqual(((ServerNetInfo) obj2).getNode_id(), discoverInstance.getServer_net_info().get(i11).getNode_id())) {
break;
}
}
ServerNetInfo serverNetInfo2 = (ServerNetInfo) obj2;
if (serverNetInfo2 != null) {
discoverInstance.getServer_net_info().get(i11).copyScores(serverNetInfo2);
if (r.areEqual(discoverInstance.getServer_net_info().get(i11).ip(), serverNetInfo2.ip()) && r.areEqual(discoverInstance.getServer_net_info().get(i11).getDiscovery_port(), serverNetInfo2.getDiscovery_port()) && r.areEqual(discoverInstance.getServer_net_info().get(i11).getDetect_port(), serverNetInfo2.getDetect_port())) {
if (Build.VERSION.SDK_INT >= 26) {
currentTimeMillis = Instant.now().getEpochSecond();
i10 = size;
} else {
i10 = size;
currentTimeMillis = System.currentTimeMillis() / 1000;
}
if (discoverInstance.getServer_net_info().get(i11).getReset_duration() > currentTimeMillis) {
discoverInstance.getServer_net_info().get(i11).reSet(searchKey);
}
} else {
i10 = size;
discoverInstance.getServer_net_info().get(i11).reSet(searchKey);
}
if (DiscoverExtKt.hasFlag(policys, 8)) {
discoverInstance.getServer_net_info().get(i11).reSet(searchKey);
}
s sVar2 = s.f40925a;
} else {
i10 = size;
}
i11++;
}
s sVar3 = s.f40925a;
}
ServerNetInfo serverNetInfo3 = serverNetInfo;
if (serverNetInfo3 != null) {
Iterator<T> it2 = discoverInstance.getServer_net_info().iterator();
while (true) {
if (!it2.hasNext()) {
obj = null;
break;
}
Object next = it2.next();
if (r.areEqual(((ServerNetInfo) next).getNode_id(), serverNetInfo3.getNode_id())) {
obj = next;
break;
}
}
ServerNetInfo serverNetInfo4 = (ServerNetInfo) obj;
if (serverNetInfo4 != null) {
if (r.areEqual(serverNetInfo4, serverNetInfo3)) {
discoverInstanceResponse.setStatus(DiscoverExtKt.addFlag(discoverInstanceResponse.getStatus(), 4));
}
s sVar4 = s.f40925a;
}
}
if (isChange.getFirst().booleanValue()) {
discoverInstanceResponse.setStatus(DiscoverExtKt.addFlag(discoverInstanceResponse.getStatus(), 2));
}
if (DiscoverExtKt.hasFlag(policys, 4)) {
addFlag = DiscoverExtKt.addFlag(2, 16);
} else {
addFlag = DiscoverExtKt.addFlag(2, 8);
}
if (AKCCheckPoint.isChecking("CHECKPOINT_LOGIN") != null) {
AKCCheckPoint.actionPointStart("CHECKPOINT_LOGIN", "as");
}
discoverInstance.scoreServerNetInfo(addFlag);
discoverInstance.configBestAccessServerNetInfo();
if (AKCCheckPoint.isChecking("CHECKPOINT_LOGIN") != null) {
AKCCheckPoint.actionPointEnd("CHECKPOINT_LOGIN", "as");
}
discoverInstance.save();
discoverInstanceResponse.setInstance(discoverInstance);
} else {
calculateTheDetectScoreByRule(5000);
save();
AKCDiscoverGlobal.DiscoverError error2 = discoverInstanceResponse.getError();
if (asInt == 0) {
asInt = AKCDiscoverGlobal.AKCDiscoverError_IDParse_Api_Error;
}
error2.setCode(asInt);
AKCDiscoverGlobal.DiscoverError error3 = discoverInstanceResponse.getError();
String asString = asJsonObject.get("description").getAsString();
r.checkNotNullExpressionValue(asString, "res[\"description\"].asString");
error3.setDescription(asString);
}
}
discoverInstanceResponse.getError().setCode(AKCDiscoverGlobal.AKCDiscoverError_IDParse_Parse_Error);
AKCDiscoverGlobal.DiscoverError error4 = discoverInstanceResponse.getError();
String string2 = j.a.get().getString(y1.login_failed_hint_5);
r.checkNotNullExpressionValue(string2, "get().getString(R.string.login_failed_hint_5)");
error4.setDescription(string2);
}
s sVar5 = s.f40925a;
}
} catch (Exception e10) {
e10.printStackTrace();
Log.e(TAG, "discover server err " + e10.getMessage());
discoverInstanceResponse.getError().setCode(AKCDiscoverGlobal.AKCDiscoverError_IDParse_TimeOut_Error);
AKCDiscoverGlobal.DiscoverError error5 = discoverInstanceResponse.getError();
String string3 = j.a.get().getString(y1.Login_failed_hint_23);
r.checkNotNullExpressionValue(string3, "get().getString(R.string.Login_failed_hint_23)");
error5.setDescription(string3);
if (!t.isNetWorkAvailableInPhysical()) {
discoverInstanceResponse.getError().setCode(AKCDiscoverGlobal.AKCDiscoverError_LocalNetErr);
AKCDiscoverGlobal.DiscoverError error6 = discoverInstanceResponse.getError();
String string4 = j.a.get().getString(y1.login_failed_hint_8);
r.checkNotNullExpressionValue(string4, "get().getString(R.string.login_failed_hint_8)");
error6.setDescription(string4);
} else if (AkeyChatUtils.IsOrContainCertificateException(e10)) {
discoverInstanceResponse.getError().setCode(AKCDiscoverGlobal.AKCDiscoverError_IDParse_PeerInvalid_Error);
if (DiscoverExtKt.isID(searchKey)) {
AKCDiscoverGlobal.DiscoverError error7 = discoverInstanceResponse.getError();
String string5 = j.a.get().getString(y1.certificate_failed);
r.checkNotNullExpressionValue(string5, "get().getString(R.string.certificate_failed)");
error7.setDescription(string5);
} else {
AKCDiscoverGlobal.DiscoverError error8 = discoverInstanceResponse.getError();
String string6 = j.a.get().getString(y1.certificate_failed_search);
r.checkNotNullExpressionValue(string6, "get().getString(R.string…ertificate_failed_search)");
error8.setDescription(string6);
}
} else if (AkeyChatUtils.IsCertificateDateValidException(e10) || ((e10 instanceof StreamResetException) && ((StreamResetException) e10).errorCode == ErrorCode.PROTOCOL_ERROR && AKCAppConfiguration.f9925a.mtlsIsExpires())) {
discoverInstanceResponse.getError().setCode(AKCDiscoverGlobal.AKCDiscoverError_IDParse_ClientInvalid_Error);
AKCDiscoverGlobal.DiscoverError error9 = discoverInstanceResponse.getError();
String string7 = j.a.get().getString(y1.local_certificate_failed);
r.checkNotNullExpressionValue(string7, "get().getString(R.string.local_certificate_failed)");
error9.setDescription(string7);
}
}
return discoverInstanceResponse;
}
public final void report(int i10) {
Map mapOf;
try {
mapOf = x.mapOf(kd.i.to("id", this.id), kd.i.to(NotifyType.SOUND, String.valueOf(this.detectScore)), kd.i.to(NotifyType.LIGHTS, String.valueOf(AKCDiscoverInstance.INSTANCE.getCurrentLocation())), kd.i.to("t", String.valueOf(i10)));
AKCCheckPoint.aliyunLog(mapOf, AKCCheckPoint.AKCSLSLogTopic.AKCSLSLogTopic_IDPARSENODE.getValue());
} catch (Throwable th) {
Log.i(TAG, "report " + i10 + " failed,e is " + th.getMessage());
}
}
public final void save() {
HttpURLTools.initIdNodeHosts(this.ip);
ak.db.e.KV().putString(AKCDiscoverGlobal.Companion.getNODE_CACHE_PERFIX() + this.id, new com.google.gson.d().toJson(this));
}
public final void setCreatTime(@NotNull String str) {
r.checkNotNullParameter(str, "<set-?>");
this.creatTime = str;
}
public final void setDataValid(@NotNull String str) {
r.checkNotNullParameter(str, "<set-?>");
this.dataValid = str;
}
public final void setDetectCount(int i10) {
this.detectCount = i10;
}
public final void setDetectFailedCount(int i10) {
this.detectFailedCount = i10;
}
public final void setDetectScore(int i10) {
this.detectScore = i10;
}
public final void setDetectSuccessCount(int i10) {
this.detectSuccessCount = i10;
}
public final void setDetectSuccessLastTime(long j10) {
this.detectSuccessLastTime = j10;
}
public final void setDetectSuccessType(@NotNull String str) {
r.checkNotNullParameter(str, "<set-?>");
this.detectSuccessType = str;
}
public final void setDiscoveryServerNodePort(@NotNull DiscoverPort discoverPort) {
r.checkNotNullParameter(discoverPort, "<set-?>");
this.discoveryServerNodePort = discoverPort;
}
public final void setId(@NotNull String str) {
r.checkNotNullParameter(str, "<set-?>");
this.id = str;
}
public final void setIp(@NotNull String str) {
r.checkNotNullParameter(str, "<set-?>");
this.ip = str;
}
public final void setLocation(@NotNull String str) {
r.checkNotNullParameter(str, "<set-?>");
this.location = str;
}
public final void setNodeManageIp(@NotNull String str) {
r.checkNotNullParameter(str, "<set-?>");
this.nodeManageIp = str;
}
public final void setNodeManagePort(@NotNull String str) {
r.checkNotNullParameter(str, "<set-?>");
this.nodeManagePort = str;
}
public final void setNodeName(@NotNull String str) {
r.checkNotNullParameter(str, "<set-?>");
this.nodeName = str;
}
public final void setNodeParentId(@NotNull String str) {
r.checkNotNullParameter(str, "<set-?>");
this.nodeParentId = str;
}
public final void setNodeStatus(@NotNull String str) {
r.checkNotNullParameter(str, "<set-?>");
this.nodeStatus = str;
}
public final void setNodeType(@NotNull String str) {
r.checkNotNullParameter(str, "<set-?>");
this.nodeType = str;
}
public final void setPort(@NotNull Map<String, Long> map) {
r.checkNotNullParameter(map, "<set-?>");
this.port = map;
}
public final void setUpdateTime(@NotNull String str) {
r.checkNotNullParameter(str, "<set-?>");
this.updateTime = str;
}
public final void setVendor(@NotNull String str) {
r.checkNotNullParameter(str, "<set-?>");
this.vendor = str;
}
@NotNull
public String toString() {
return "AKCDiscoverNode(location=" + this.location + ", id=" + this.id + ", ip=" + this.ip + ", detectScore=" + this.detectScore + ", detectSuccessCount=" + this.detectSuccessCount + ", detectSuccessLastTime=" + this.detectSuccessLastTime + ", detectCount=" + this.detectCount + ", detectFailedCount=" + this.detectFailedCount + ", nodeName=" + this.nodeName + ", nodeType=" + this.nodeType + ')';
}
@Metadata(bv = {}, d1 = {"\u0000@\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0010 \n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0010!\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u000b\b\u0086\u0003\u0018\u00002\u00020\u0001B\t\b\u0002¢\u0006\u0004\b\u001e\u0010\u001fJ\u0010\u0010\u0005\u001a\u00020\u00042\u0006\u0010\u0003\u001a\u00020\u0002H\u0002J\u0006\u0010\u0006\u001a\u00020\u0002J\f\u0010\b\u001a\b\u0012\u0004\u0012\u00020\u00040\u0007J\u0012\u0010\n\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u00040\u00070\tJ\u0006\u0010\f\u001a\u00020\u000bJ\u000e\u0010\u000e\u001a\u00020\u000b2\u0006\u0010\r\u001a\u00020\u0002J\u001c\u0010\u0013\u001a\u00020\u00122\u0006\u0010\u000f\u001a\u00020\u00022\f\u0010\u0011\u001a\b\u0012\u0004\u0012\u00020\u00040\u0010J\u0014\u0010\u0013\u001a\u00020\u00122\f\u0010\u0014\u001a\b\u0012\u0004\u0012\u00020\u00040\u0010J\u001a\u0010\u0018\u001a\u00020\u000b2\u0006\u0010\u0016\u001a\u00020\u00152\b\b\u0002\u0010\u0017\u001a\u00020\u0012H\u0007J\f\u0010\u0019\u001a\b\u0012\u0004\u0012\u00020\u00120\tR\u0014\u0010\u001a\u001a\u00020\u00128\u0006X\u0086T¢\u0006\u0006\n\u0004\b\u001a\u0010\u001bR\u0014\u0010\u001c\u001a\u00020\u00028\u0006X\u0086T¢\u0006\u0006\n\u0004\b\u001c\u0010\u001d¨\u0006 "}, d2 = {"Lak/im/module/AKCDiscoverNode$Companion;", "", "", "json", "Lak/im/module/AKCDiscoverNode;", "init", "defaultNode", "", "loadNodesSync", "Lfc/z;", "loadNodes", "Lkd/s;", "clearNodesCache", "ip", "saveTestDiscoveryNodeIpForBnet", "nodejsons", "", "nodes", "", "saveNodes", "list", "", "interval", "needUpdate", "detectBackground", "updateNodesOnline", "INDEBUG", "Z", "TAG", "Ljava/lang/String;", "<init>", "()V", "ak-im_carrotArmV7Release"}, k = 1, mv = {1, 6, 0})
public static final class Companion {
private Companion() {
}
public Companion(o oVar) {
this();
}
public static void detectBackground$default(Companion companion, int i10, boolean z10, int i11, Object obj) {
if ((i11 & 2) != 0) {
z10 = false;
}
companion.detectBackground(i10, z10);
}
public static final s m6detectBackground$lambda10(int i10, final Ref$BooleanRef update, final List a10, final boolean z10, List it) {
List sortedWith;
final boolean z11;
r.checkNotNullParameter(update, "$update");
r.checkNotNullParameter(a10, "$a");
r.checkNotNullParameter(it, "it");
sortedWith = CollectionsKt___CollectionsKt.sortedWith(it, new Comparator() {
@Override
public final int compare(T t10, T t11) {
int compareValues;
compareValues = nd.b.compareValues(Integer.valueOf(((AKCDiscoverNode) t10).getDetectSuccessCount()), Integer.valueOf(((AKCDiscoverNode) t11).getDetectSuccessCount()));
return compareValues;
}
});
int i11 = 0;
for (Object obj : sortedWith) {
int i12 = i11 + 1;
if (i11 < 0) {
CollectionsKt__CollectionsKt.throwIndexOverflow();
}
final AKCDiscoverNode aKCDiscoverNode = (AKCDiscoverNode) obj;
if (i11 == sortedWith.size() - 1) {
z11 = true;
} else {
z11 = false;
}
z.timer(i11 * i10, TimeUnit.SECONDS, gd.b.io()).subscribe(new mc.g() {
@Override
public final void accept(Object obj2) {
AKCDiscoverNode.Companion.m7detectBackground$lambda10$lambda9$lambda8(AKCDiscoverNode.this, update, a10, z11, z10, (Long) obj2);
}
});
i11 = i12;
}
return s.f40925a;
}
public static final void m7detectBackground$lambda10$lambda9$lambda8(final AKCDiscoverNode value, final Ref$BooleanRef update, final List a10, final boolean z10, final boolean z11, Long l10) {
r.checkNotNullParameter(value, "$value");
r.checkNotNullParameter(update, "$update");
r.checkNotNullParameter(a10, "$a");
Log.d(AKCDiscoverNode.TAG, "detectBackground:" + value.getId() + ",IN THREAD:" + Thread.currentThread().getName());
value.detect(true).subscribe(new mc.g() {
@Override
public final void accept(Object obj) {
AKCDiscoverNode.Companion.m8detectBackground$lambda10$lambda9$lambda8$lambda6(Ref$BooleanRef.this, value, a10, z10, z11, (Boolean) obj);
}
}, new mc.g() {
@Override
public final void accept(Object obj) {
AKCDiscoverNode.Companion.m9detectBackground$lambda10$lambda9$lambda8$lambda7(a10, value, update, z10, z11, (Throwable) obj);
}
});
}
public static final void m8detectBackground$lambda10$lambda9$lambda8$lambda6(Ref$BooleanRef update, AKCDiscoverNode value, List a10, boolean z10, boolean z11, Boolean bool) {
String serverId;
boolean z12;
r.checkNotNullParameter(update, "$update");
r.checkNotNullParameter(value, "$value");
r.checkNotNullParameter(a10, "$a");
if (!bool.booleanValue()) {
if (!update.element) {
if (value.getDetectFailedCount() >= 5) {
z12 = true;
} else {
z12 = false;
}
update.element = z12;
}
a10.add(new u0.s(value.getId(), value.getDetectScore()));
}
if (z10) {
AKCDiscoverManager.Companion companion = AKCDiscoverManager.INSTANCE;
if (f1.getInstance().getServer() != null) {
serverId = f1.getInstance().getServer().getEnterpriseId();
} else {
serverId = f1.getInstance().getServerId();
}
r.checkNotNullExpressionValue(serverId, "if (AppConfigManager.get…er.getInstance().serverId");
companion.upLoadDiscoverError(serverId, "detect", a10);
a10.clear();
if (t.isNetWorkAvailableInPhysical() && z11 && update.element) {
AKCDiscoverNode.INSTANCE.updateNodesOnline().subscribe();
}
}
}
public static final void m9detectBackground$lambda10$lambda9$lambda8$lambda7(List a10, AKCDiscoverNode value, Ref$BooleanRef update, boolean z10, boolean z11, Throwable th) {
String serverId;
boolean z12;
r.checkNotNullParameter(a10, "$a");
r.checkNotNullParameter(value, "$value");
r.checkNotNullParameter(update, "$update");
a10.add(new u0.s(value.getId(), value.getDetectScore()));
if (!update.element) {
if (value.getDetectFailedCount() >= 5) {
z12 = true;
} else {
z12 = false;
}
update.element = z12;
}
if (z10) {
AKCDiscoverManager.Companion companion = AKCDiscoverManager.INSTANCE;
if (f1.getInstance().getServer() != null) {
serverId = f1.getInstance().getServer().getEnterpriseId();
} else {
serverId = f1.getInstance().getServerId();
}
r.checkNotNullExpressionValue(serverId, "if (AppConfigManager.get…er.getInstance().serverId");
companion.upLoadDiscoverError(serverId, "detect", a10);
a10.clear();
if (t.isNetWorkAvailableInPhysical() && z11 && update.element) {
AKCDiscoverNode.INSTANCE.updateNodesOnline().subscribe();
}
}
}
private final AKCDiscoverNode init(String json) {
Object fromJson = new com.google.gson.d().fromJson(json, (Class<Object>) AKCDiscoverNode.class);
r.checkNotNullExpressionValue(fromJson, "Gson().fromJson(json,AKCDiscoverNode::class.java)");
return (AKCDiscoverNode) fromJson;
}
public static final void m10loadNodes$lambda1(b0 ob2) {
r.checkNotNullParameter(ob2, "ob");
Log.d(AKCDiscoverNode.TAG, "loadNotes IN: " + Thread.currentThread().getName());
ob2.onNext(AKCDiscoverNode.INSTANCE.loadNodesSync());
}
public static final void m11updateNodesOnline$lambda11(final b0 result) {
r.checkNotNullParameter(result, "result");
if (f1.getInstance().f2080w1) {
result.onComplete();
return;
}
com.google.gson.l lVar = new com.google.gson.l();
lVar.addProperty("nodeParentId", (Number) 0);
lVar.addProperty("nodeType", "loadBalance");
new o0.b("https://" + f1.getInstance().getOssCenterHost() + '/', false, false).getAKAPI(10).updateNodes(ye.m.create(ye.k.parse("application/json; charset=utf-8"), lVar.toString())).subscribe(new v0.a<u0.t>() {
@Override
public void onError(@NotNull Throwable e10) {
Map mapOf;
Map mapOf2;
Map mapOf3;
Map mapOf4;
r.checkNotNullParameter(e10, "e");
super.onError(e10);
e10.printStackTrace();
Log.i(AKCDiscoverNode.TAG, "updateNodesOnline error is " + e10.getMessage());
String string = j.a.get().getString(y1.login_failed_hint_17);
r.checkNotNullExpressionValue(string, "get().getString(R.string.login_failed_hint_17)");
AKCDiscoverGlobal.DiscoverError discoverError = new AKCDiscoverGlobal.DiscoverError(AKCDiscoverGlobal.AKCDiscoverError_NodeUpdate_TimeOut_Error, string, 0, 4, null);
if (!t.isNetWorkAvailableInPhysical()) {
discoverError.setCode(AKCDiscoverGlobal.AKCDiscoverError_LocalNetErr);
String string2 = j.a.get().getString(y1.login_failed_hint_8);
r.checkNotNullExpressionValue(string2, "get().getString(R.string.login_failed_hint_8)");
discoverError.setDescription(string2);
} else if (e10 instanceof HttpException) {
discoverError.setCode(AKCDiscoverGlobal.AKCDiscoverError_NodeUpdate_Error);
String string3 = j.a.get().getString(y1.login_failed_hint_20, String.valueOf(((HttpException) e10).code()));
r.checkNotNullExpressionValue(string3, "get().getString(R.string…t_20,e.code().toString())");
discoverError.setDescription(string3);
mapOf4 = x.mapOf(kd.i.to(NotifyType.LIGHTS, String.valueOf(AKCDiscoverInstance.INSTANCE.getCurrentLocation())), kd.i.to("t", "200002"));
AKCCheckPoint.aliyunLog(mapOf4, AKCCheckPoint.AKCSLSLogTopic.AKCSLSLogTopic_IDPARSENODE.getValue());
} else if (AkeyChatUtils.IsOrContainCertificateException(e10)) {
discoverError.setCode(AKCDiscoverGlobal.AKCDiscoverError_NodeUpdate_PeerInvalid_Error);
String string4 = j.a.get().getString(y1.certificate_failed_node);
r.checkNotNullExpressionValue(string4, "get().getString(R.string.certificate_failed_node)");
discoverError.setDescription(string4);
mapOf3 = x.mapOf(kd.i.to(NotifyType.LIGHTS, String.valueOf(AKCDiscoverInstance.INSTANCE.getCurrentLocation())), kd.i.to("t", "200005"));
AKCCheckPoint.aliyunLog(mapOf3, AKCCheckPoint.AKCSLSLogTopic.AKCSLSLogTopic_IDPARSENODE.getValue());
} else if (AkeyChatUtils.IsCertificateDateValidException(e10)) {
discoverError.setCode(AKCDiscoverGlobal.AKCDiscoverError_NodeUpdate_ClientInvalid_Error);
String string5 = j.a.get().getString(y1.local_certificate_failed);
r.checkNotNullExpressionValue(string5, "get().getString(R.string.local_certificate_failed)");
discoverError.setDescription(string5);
mapOf2 = x.mapOf(kd.i.to(NotifyType.LIGHTS, String.valueOf(AKCDiscoverInstance.INSTANCE.getCurrentLocation())), kd.i.to("t", "200006"));
AKCCheckPoint.aliyunLog(mapOf2, AKCCheckPoint.AKCSLSLogTopic.AKCSLSLogTopic_IDPARSENODE.getValue());
} else {
mapOf = x.mapOf(kd.i.to(NotifyType.LIGHTS, String.valueOf(AKCDiscoverInstance.INSTANCE.getCurrentLocation())), kd.i.to("t", "200007"));
AKCCheckPoint.aliyunLog(mapOf, AKCCheckPoint.AKCSLSLogTopic.AKCSLSLogTopic_IDPARSENODE.getValue());
}
result.onError(new AKCDiscoverGlobal.DiscoverGlobalException(discoverError));
}
@Override
public void onNext(@NotNull u0.t t10) {
Map mapOf;
Map mapOf2;
r.checkNotNullParameter(t10, "t");
int code = t10.getCode();
if (code == 200 && t10.getData().size() > 0) {
AKCDiscoverNode.Companion companion = AKCDiscoverNode.INSTANCE;
List<AKCDiscoverNode> data = t10.getData();
r.checkNotNullExpressionValue(data, "t.data");
boolean z10 = !companion.saveNodes(data);
Log.i(AKCDiscoverNode.TAG, "updateNodesOnline need retry is " + z10);
result.onNext(Boolean.valueOf(z10));
return;
}
int i10 = AKCDiscoverGlobal.AKCDiscoverError_NodeUpdate_Api_Error;
String message = t10.getMessage();
r.checkNotNullExpressionValue(message, "t.message");
AKCDiscoverGlobal.DiscoverError discoverError = new AKCDiscoverGlobal.DiscoverError(i10, message, 0, 4, null);
if (code == 500) {
String string = j.a.get().getString(y1.login_failed_hint_18);
r.checkNotNullExpressionValue(string, "get().getString(R.string.login_failed_hint_18)");
discoverError.setDescription(string);
} else {
String message2 = t10.getMessage();
if ((message2 == null || message2.length() == 0) || code == 200) {
discoverError.setCode(AKCDiscoverGlobal.AKCDiscoverError_NodeUpdate_Empty_Error);
String string2 = j.a.get().getString(y1.login_failed_hint_4);
r.checkNotNullExpressionValue(string2, "get().getString(R.string.login_failed_hint_4)");
discoverError.setDescription(string2);
}
}
if (code > 0) {
mapOf2 = x.mapOf(kd.i.to(NotifyType.LIGHTS, String.valueOf(AKCDiscoverInstance.INSTANCE.getCurrentLocation())), kd.i.to("t", String.valueOf(code + AKCDiscoverGlobal.AKCDiscoverError_NodeUpdate_Error)));
AKCCheckPoint.aliyunLog(mapOf2, AKCCheckPoint.AKCSLSLogTopic.AKCSLSLogTopic_IDPARSENODE.getValue());
} else {
mapOf = x.mapOf(kd.i.to(NotifyType.LIGHTS, String.valueOf(AKCDiscoverInstance.INSTANCE.getCurrentLocation())), kd.i.to("t", "200002"));
AKCCheckPoint.aliyunLog(mapOf, AKCCheckPoint.AKCSLSLogTopic.AKCSLSLogTopic_IDPARSENODE.getValue());
}
result.onError(new AKCDiscoverGlobal.DiscoverGlobalException(discoverError));
}
});
}
public final void clearNodesCache() {
List<String> emptyList;
ak.db.e KV = ak.db.e.KV();
AKCDiscoverGlobal.Companion companion = AKCDiscoverGlobal.Companion;
String string = KV.getString(companion.getNODES_IDS_CACHE_KEY(), "");
if (!TextUtils.isEmpty(string)) {
Object fromJson = new com.google.gson.d().fromJson(string, (Class<Object>) List.class);
if (fromJson != null) {
emptyList = (List) fromJson;
} else {
throw new NullPointerException("null cannot be cast to non-null type kotlin.collections.List<kotlin.String>");
}
} else {
emptyList = CollectionsKt__CollectionsKt.emptyList();
}
ak.db.e.KV().remove(companion.getNODES_IDS_CACHE_KEY());
for (String str : emptyList) {
ak.db.e.KV().remove(AKCDiscoverGlobal.Companion.getNODE_CACHE_PERFIX() + str);
}
}
@NotNull
public final String defaultNode() {
return "[{\n\t\"nodeId\": \"1466332767924150273\",\n\t\"nodeParentId\": \"0\",\n\t\"nodeType\": \"loadBalance\",\n\t\"nodeName\": \"香港CLB\",\n\t\"nodeIp\": \"8.217.99.212\",\n\t\"nodePort\": \"8336/8663\",\n\t\"nodeManageIp\": \"\",\n\t\"nodeManagePort\": \"\",\n\t\"nodeLocation\": \"APAC\",\n\t\"nodeVendor\": \"aliyun\",\n\t\"nodeStatus\": \"\",\n\t\"dataValid\": 1,\n\t\"createTime\": \"2021-12-02 17:05:49\",\n\t\"updateTime\": \"2021-12-02 17:05:49\",\n\t\"discoveryServerNodePort\": {\n\t\t\"http\": \"8336\",\n\t\t\"https\": \"8663\"\n\t},\n\t\"nodeParentName\": null\n},{\n\t\"nodeId\": \"1466333754919378946\",\n\t\"nodeParentId\": \"0\",\n\t\"nodeType\": \"loadBalance\",\n\t\"nodeName\": \"华东CLB\",\n\t\"nodeIp\": \"106.15.10.119\",\n\t\"nodePort\": \"8336/8663\",\n\t\"nodeManageIp\": \"\",\n\t\"nodeManagePort\": \"\",\n\t\"nodeLocation\": \"CN\",\n\t\"nodeVendor\": \"aliyun\",\n\t\"nodeStatus\": \"\",\n\t\"dataValid\": 1,\n\t\"createTime\": \"2021-12-02 17:09:44\",\n\t\"updateTime\": \"2021-12-02 17:09:44\",\n\t\"discoveryServerNodePort\": {\n\t\t\"http\": \"8336\",\n\t\t\"https\": \"8663\"\n\t},\n\t\"nodeParentName\": null\n},{\n\t\"nodeId\": \"1466333852801851394\",\n\t\"nodeParentId\": \"0\",\n\t\"nodeType\": \"loadBalance\",\n\t\"nodeName\": \"华北CLB\",\n\t\"nodeIp\": \"39.105.151.223\",\n\t\"nodePort\": \"8336/8663\",\n\t\"nodeManageIp\": \"\",\n\t\"nodeManagePort\": \"\",\n\t\"nodeLocation\": \"CN\",\n\t\"nodeVendor\": \"aliyun\",\n\t\"nodeStatus\": \"\",\n\t\"dataValid\": 1,\n\t\"createTime\": \"2021-12-02 17:10:08\",\n\t\"updateTime\": \"2021-12-02 17:10:08\",\n\t\"discoveryServerNodePort\": {\n\t\t\"http\": \"8336\",\n\t\t\"https\": \"8663\"\n\t},\n\t\"nodeParentName\": null\n},{\n\t\"nodeId\": \"1466334005306744834\",\n\t\"nodeParentId\": \"0\",\n\t\"nodeType\": \"loadBalance\",\n\t\"nodeName\": \"华南CLB\",\n\t\"nodeIp\": \"120.77.13.17\",\n\t\"nodePort\": \"8336/8663\",\n\t\"nodeManageIp\": \"\",\n\t\"nodeManagePort\": \"\",\n\t\"nodeLocation\": \"CN\",\n\t\"nodeVendor\": \"aliyun\",\n\t\"nodeStatus\": \"\",\n\t\"dataValid\": 1,\n\t\"createTime\": \"2021-12-02 17:10:44\",\n\t\"updateTime\": \"2021-12-02 17:10:44\",\n\t\"discoveryServerNodePort\": {\n\t\t\"http\": \"8336\",\n\t\t\"https\": \"8663\"\n\t},\n\t\"nodeParentName\": null\n},{\n\t\"nodeId\": \"1466334065750859778\",\n\t\"nodeParentId\": \"0\",\n\t\"nodeType\": \"loadBalance\",\n\t\"nodeName\": \"新加坡CLB\",\n\t\"nodeIp\": \"47.241.166.121\",\n\t\"nodePort\": \"8336/8663\",\n\t\"nodeManageIp\": \"\",\n\t\"nodeManagePort\": \"\",\n\t\"nodeLocation\": \"APAC\",\n\t\"nodeVendor\": \"aliyun\",\n\t\"nodeStatus\": \"\",\n\t\"dataValid\": 1,\n\t\"createTime\": \"2021-12-02 17:10:59\",\n\t\"updateTime\": \"2021-12-02 17:10:59\",\n\t\"discoveryServerNodePort\": {\n\t\t\"http\": \"8336\",\n\t\t\"https\": \"8663\"\n\t},\n\t\"nodeParentName\": null\n},{\n\t\"nodeId\": \"1466334378952122370\",\n\t\"nodeParentId\": \"0\",\n\t\"nodeType\": \"loadBalance\",\n\t\"nodeName\": \"迪拜CLB\",\n\t\"nodeIp\": \"47.91.124.176\",\n\t\"nodePort\": \"8336/8663\",\n\t\"nodeManageIp\": \"\",\n\t\"nodeManagePort\": \"\",\n\t\"nodeLocation\": \"MENA\",\n\t\"nodeVendor\": \"aliyun\",\n\t\"nodeStatus\": \"\",\n\t\"dataValid\": 1,\n\t\"createTime\": \"2021-12-02 17:12:13\",\n\t\"updateTime\": \"2021-12-02 17:12:13\",\n\t\"discoveryServerNodePort\": {\n\t\t\"http\": \"8336\",\n\t\t\"https\": \"8663\"\n\t},\n\t\"nodeParentName\": null\n}]";
}
@SuppressLint({"CheckResult"})
public final void detectBackground(final int i10, final boolean z10) {
final Ref$BooleanRef ref$BooleanRef = new Ref$BooleanRef();
final ArrayList arrayList = new ArrayList();
loadNodes().subscribeOn(gd.b.io()).map(new mc.o() {
@Override
public final Object apply(Object obj) {
s m6detectBackground$lambda10;
m6detectBackground$lambda10 = AKCDiscoverNode.Companion.m6detectBackground$lambda10(i10, ref$BooleanRef, arrayList, z10, (List) obj);
return m6detectBackground$lambda10;
}
}).subscribe();
}
@NotNull
public final z<List<AKCDiscoverNode>> loadNodes() {
z<List<AKCDiscoverNode>> create = z.create(new c0() {
@Override
public final void subscribe(b0 b0Var) {
AKCDiscoverNode.Companion.m10loadNodes$lambda1(b0Var);
}
});
r.checkNotNullExpressionValue(create, "create { ob ->\n …esSync());\n\n }");
return create;
}
@NotNull
public final List<AKCDiscoverNode> loadNodesSync() {
List<String> emptyList;
String string = ak.db.e.KV().getString(AKCDiscoverGlobal.Companion.getNODES_IDS_CACHE_KEY(), "");
r.checkNotNullExpressionValue(string, "KV().getString(NODES_IDS_CACHE_KEY, \"\")");
if (!TextUtils.isEmpty(string)) {
Object fromJson = new com.google.gson.d().fromJson(string, (Class<Object>) List.class);
if (fromJson != null) {
emptyList = (List) fromJson;
} else {
throw new NullPointerException("null cannot be cast to non-null type kotlin.collections.List<kotlin.String>");
}
} else {
emptyList = CollectionsKt__CollectionsKt.emptyList();
}
ArrayList arrayList = new ArrayList();
if (emptyList.isEmpty()) {
Log.d(AKCDiscoverNode.TAG, "init nodes use def config");
saveNodes(defaultNode(), arrayList);
} else {
Log.d(AKCDiscoverNode.TAG, "init nodes use cache");
for (String str : emptyList) {
String string2 = ak.db.e.KV().getString(AKCDiscoverGlobal.Companion.getNODE_CACHE_PERFIX() + str, "");
r.checkNotNullExpressionValue(string2, "KV().getString(NODE_CACHE_PERFIX+id, \"\")");
if (!TextUtils.isEmpty(string2)) {
Object fromJson2 = new com.google.gson.d().fromJson(string2, (Class<Object>) AKCDiscoverNode.class);
r.checkNotNullExpressionValue(fromJson2, "Gson().fromJson(nodejson…DiscoverNode::class.java)");
AKCDiscoverNode aKCDiscoverNode = (AKCDiscoverNode) fromJson2;
if (aKCDiscoverNode != null) {
arrayList.add(aKCDiscoverNode);
}
}
}
if (arrayList.isEmpty()) {
saveNodes(defaultNode(), arrayList);
}
}
Log.d(AKCDiscoverNode.TAG, "nodes size is " + arrayList.size() + ",nodes:" + arrayList);
return arrayList;
}
public final boolean saveNodes(@NotNull String nodejsons, @NotNull List<AKCDiscoverNode> nodes) {
int collectionSizeOrDefault;
r.checkNotNullParameter(nodejsons, "nodejsons");
r.checkNotNullParameter(nodes, "nodes");
Object fromJson = new com.google.gson.d().fromJson(nodejsons, new com.google.gson.reflect.a<List<AKCDiscoverNode>>() {
}.getType());
r.checkNotNullExpressionValue(fromJson, "Gson().fromJson<MutableL…CDiscoverNode>>(){}.type)");
nodes.addAll((Collection) fromJson);
String string = ak.db.e.KV().getString(AKCDiscoverGlobal.Companion.getNODES_IDS_CACHE_KEY(), "");
com.google.gson.d dVar = new com.google.gson.d();
collectionSizeOrDefault = kotlin.collections.l.collectionSizeOrDefault(nodes, 10);
ArrayList arrayList = new ArrayList(collectionSizeOrDefault);
Iterator<T> it = nodes.iterator();
while (it.hasNext()) {
arrayList.add(((AKCDiscoverNode) it.next()).getId());
}
String json = dVar.toJson(arrayList);
ak.db.e.KV().putString(AKCDiscoverGlobal.Companion.getNODES_IDS_CACHE_KEY(), json);
return string.equals(json);
}
public final void saveTestDiscoveryNodeIpForBnet(@NotNull String ip) {
boolean contains$default;
List split$default;
r.checkNotNullParameter(ip, "ip");
List<AKCDiscoverNode> nodes = (List) new com.google.gson.d().fromJson(defaultNode(), new com.google.gson.reflect.a<List<AKCDiscoverNode>>() {
}.getType());
Log.i(AKCDiscoverNode.TAG, "nodes ip is " + nodes.get(0).getIp());
contains$default = StringsKt__StringsKt.contains$default((CharSequence) ip, (CharSequence) ":", false, 2, (Object) null);
if (contains$default) {
split$default = StringsKt__StringsKt.split$default((CharSequence) ip, new String[]{":"}, false, 0, 6, (Object) null);
nodes.get(0).setIp((String) split$default.get(0));
nodes.get(0).getDiscoveryServerNodePort().setHttp((String) split$default.get(1));
nodes.get(0).getDiscoveryServerNodePort().setHttps((String) split$default.get(1));
} else {
nodes.get(0).setIp(ip);
}
r.checkNotNullExpressionValue(nodes, "nodes");
saveNodes(nodes);
}
@NotNull
public final z<Boolean> updateNodesOnline() {
z<Boolean> create = z.create(new c0() {
@Override
public final void subscribe(b0 b0Var) {
AKCDiscoverNode.Companion.m11updateNodesOnline$lambda11(b0Var);
}
});
r.checkNotNullExpressionValue(create, "create { result ->\n … })\n }");
return create;
}
public final boolean saveNodes(@NotNull List<AKCDiscoverNode> list) {
int collectionSizeOrDefault;
r.checkNotNullParameter(list, "list");
String string = ak.db.e.KV().getString(AKCDiscoverGlobal.Companion.getNODES_IDS_CACHE_KEY(), "");
com.google.gson.d dVar = new com.google.gson.d();
collectionSizeOrDefault = kotlin.collections.l.collectionSizeOrDefault(list, 10);
ArrayList arrayList = new ArrayList(collectionSizeOrDefault);
Iterator<T> it = list.iterator();
while (it.hasNext()) {
arrayList.add(((AKCDiscoverNode) it.next()).getId());
}
String json = dVar.toJson(arrayList);
Log.i("nodesdate", "odl is :" + string);
Log.i("nodesdate", "new is :" + json);
Iterator<AKCDiscoverNode> it2 = list.iterator();
while (it2.hasNext()) {
it2.next().save();
}
ak.db.e.KV().putString(AKCDiscoverGlobal.Companion.getNODES_IDS_CACHE_KEY(), json);
return string.equals(json);
}
}
}