CarrotChat v2.8.60.240131版本的 MD5 值为:2baf8b9f31830b86b5c5a85ae6b47e05
以下内容为反编译后的 AKCDiscoverNode.java 源代码,内容仅作参考
package ak.im.module;
import ak.application.AKApplication;
import ak.i.s;
import ak.i.t;
import ak.im.BuildConfig;
import ak.im.b2;
import ak.im.module.AKCDiscoverGlobal;
import ak.im.module.AKCDiscoverNode;
import ak.im.o1;
import ak.im.sdk.manager.AKCDiscoverManager;
import ak.im.sdk.manager.ye;
import ak.im.uitls.AKCAppConfiguration;
import ak.im.uitls.AKCCheckPoint;
import ak.im.uitls.a0;
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 io.reactivex.b0;
import io.reactivex.c0;
import io.reactivex.z;
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.Objects;
import java.util.concurrent.TimeUnit;
import kotlin.Pair;
import kotlin.collections.CollectionsKt__CollectionsKt;
import kotlin.collections.CollectionsKt___CollectionsKt;
import kotlin.collections.p0;
import kotlin.jvm.internal.Ref$BooleanRef;
import kotlin.jvm.internal.o;
import kotlin.jvm.internal.r;
import kotlin.text.StringsKt__StringsKt;
import kotlin.v;
import okhttp3.d0;
import okhttp3.internal.http2.ErrorCode;
import okhttp3.internal.http2.StreamResetException;
import okhttp3.u;
import okhttp3.w;
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;
@kotlin.j(d1 = {"\u0000P\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000e\n\u0002\b\b\n\u0002\u0010\b\n\u0002\b\u000e\n\u0002\u0010\t\n\u0002\b\b\n\u0002\u0018\u0002\n\u0002\b \n\u0002\u0010$\n\u0002\b\u000b\n\u0002\u0010\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0010\u000b\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\t\u0018\u0000 b2\u00020\u0001:\u0002bcB\u0005¢\u0006\u0002\u0010\u0002J\u000e\u0010Q\u001a\u00020R2\u0006\u0010S\u001a\u00020\rJ\u0016\u0010T\u001a\b\u0012\u0004\u0012\u00020V0U2\b\b\u0002\u0010W\u001a\u00020VJ\u0012\u0010X\u001a\u000e\u0012\u0004\u0012\u00020\u0004\u0012\u0004\u0012\u00020\u001c0FJ\u0006\u0010Y\u001a\u00020\u001cJ\u0016\u0010Z\u001a\u00020[2\u0006\u0010\\\u001a\u00020\r2\u0006\u0010]\u001a\u00020\u0004J\u000e\u0010^\u001a\u00020R2\u0006\u0010_\u001a\u00020\rJ\u0006\u0010`\u001a\u00020RJ\b\u0010a\u001a\u00020\u0004H\u0016R\u001e\u0010\u0003\u001a\u00020\u00048\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0005\u0010\u0006\"\u0004\b\u0007\u0010\bR\u001e\u0010\t\u001a\u00020\u00048\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\n\u0010\u0006\"\u0004\b\u000b\u0010\bR\u001a\u0010\f\u001a\u00020\rX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u000e\u0010\u000f\"\u0004\b\u0010\u0010\u0011R\u001a\u0010\u0012\u001a\u00020\rX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0013\u0010\u000f\"\u0004\b\u0014\u0010\u0011R\u001a\u0010\u0015\u001a\u00020\rX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0016\u0010\u000f\"\u0004\b\u0017\u0010\u0011R\u001a\u0010\u0018\u001a\u00020\rX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u0019\u0010\u000f\"\u0004\b\u001a\u0010\u0011R\u001a\u0010\u001b\u001a\u00020\u001cX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\u001d\u0010\u001e\"\u0004\b\u001f\u0010 R\u001a\u0010!\u001a\u00020\u0004X\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b\"\u0010\u0006\"\u0004\b#\u0010\bR\u001e\u0010$\u001a\u00020%8\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b&\u0010'\"\u0004\b(\u0010)R\u001e\u0010*\u001a\u00020\u00048\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b+\u0010\u0006\"\u0004\b,\u0010\bR\u001e\u0010-\u001a\u00020\u00048\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b.\u0010\u0006\"\u0004\b/\u0010\bR\u001e\u00100\u001a\u00020\u00048\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b1\u0010\u0006\"\u0004\b2\u0010\bR\u001e\u00103\u001a\u00020\u00048\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b4\u0010\u0006\"\u0004\b5\u0010\bR\u001e\u00106\u001a\u00020\u00048\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b7\u0010\u0006\"\u0004\b8\u0010\bR\u001e\u00109\u001a\u00020\u00048\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b:\u0010\u0006\"\u0004\b;\u0010\bR\u001e\u0010<\u001a\u00020\u00048\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b=\u0010\u0006\"\u0004\b>\u0010\bR\u001e\u0010?\u001a\u00020\u00048\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\b@\u0010\u0006\"\u0004\bA\u0010\bR\u001e\u0010B\u001a\u00020\u00048\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\bC\u0010\u0006\"\u0004\bD\u0010\bR&\u0010E\u001a\u000e\u0012\u0004\u0012\u00020\u0004\u0012\u0004\u0012\u00020\u001c0FX\u0086\u000e¢\u0006\u000e\n\u0000\u001a\u0004\bG\u0010H\"\u0004\bI\u0010JR\u001e\u0010K\u001a\u00020\u00048\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\bL\u0010\u0006\"\u0004\bM\u0010\bR\u001e\u0010N\u001a\u00020\u00048\u0006@\u0006X\u0087\u000e¢\u0006\u000e\n\u0000\u001a\u0004\bO\u0010\u0006\"\u0004\bP\u0010\b¨\u0006d"}, d2 = {"Lak/im/module/AKCDiscoverNode;", "", "()V", "creatTime", "", "getCreatTime", "()Ljava/lang/String;", "setCreatTime", "(Ljava/lang/String;)V", "dataValid", "getDataValid", "setDataValid", "detectCount", "", "getDetectCount", "()I", "setDetectCount", "(I)V", "detectFailedCount", "getDetectFailedCount", "setDetectFailedCount", "detectScore", "getDetectScore", "setDetectScore", "detectSuccessCount", "getDetectSuccessCount", "setDetectSuccessCount", "detectSuccessLastTime", "", "getDetectSuccessLastTime", "()J", "setDetectSuccessLastTime", "(J)V", "detectSuccessType", "getDetectSuccessType", "setDetectSuccessType", "discoveryServerNodePort", "Lak/im/module/AKCDiscoverNode$DiscoverPort;", "getDiscoveryServerNodePort", "()Lak/im/module/AKCDiscoverNode$DiscoverPort;", "setDiscoveryServerNodePort", "(Lak/im/module/AKCDiscoverNode$DiscoverPort;)V", "id", "getId", "setId", "ip", "getIp", "setIp", "location", "getLocation", "setLocation", "nodeManageIp", "getNodeManageIp", "setNodeManageIp", "nodeManagePort", "getNodeManagePort", "setNodeManagePort", "nodeName", "getNodeName", "setNodeName", "nodeParentId", "getNodeParentId", "setNodeParentId", "nodeStatus", "getNodeStatus", "setNodeStatus", "nodeType", "getNodeType", "setNodeType", Cookie2.PORT, "", "getPort", "()Ljava/util/Map;", "setPort", "(Ljava/util/Map;)V", "updateTime", "getUpdateTime", "setUpdateTime", Constant.LOGIN_ACTIVITY_VENDOR_KEY, "getVendor", "setVendor", "calculateTheDetectScoreByRule", "", "score", "detect", "Lio/reactivex/Observable;", "", "need", "getServerNodePort", "httpPort", "queryDiscoverInstance", "Lak/im/module/AKCDiscoverGlobal$DiscoverInstanceResponse;", "policys", "searchKey", CtrlMessage.REPORT, "t", "save", "toString", "Companion", "DiscoverPort", "ak-im_carrotArmV7Release"}, k = 1, mv = {1, 6, 0}, xi = 48)
public final class AKCDiscoverNode {
@NotNull
public static final Companion Companion = new Companion(null);
public static final boolean INDEBUG = false;
@NotNull
public static final String TAG = "DISCOVER|AKCDiscoverNode";
@com.google.gson.t.c("creatTime")
@NotNull
private String creatTime;
@com.google.gson.t.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;
@com.google.gson.t.c("discoveryServerNodePort")
@NotNull
private DiscoverPort discoveryServerNodePort;
@com.google.gson.t.c("nodeManageIp")
@NotNull
private String nodeManageIp;
@com.google.gson.t.c("nodeManagePort")
@NotNull
private String nodeManagePort;
@com.google.gson.t.c("nodeName")
@NotNull
private String nodeName;
@com.google.gson.t.c("nodeParentId")
@NotNull
private String nodeParentId;
@com.google.gson.t.c("nodeStatus")
@NotNull
private String nodeStatus;
@com.google.gson.t.c("nodeType")
@NotNull
private String nodeType;
@NotNull
private Map<String, Long> port;
@com.google.gson.t.c("updateTime")
@NotNull
private String updateTime;
@com.google.gson.t.c("nodeId")
@NotNull
private String id = "";
@com.google.gson.t.c("nodeIp")
@NotNull
private String ip = "";
@com.google.gson.t.c("nodeLocation")
@NotNull
private String location = "";
@com.google.gson.t.c("nodeVendor")
@NotNull
private String vendor = "";
@kotlin.j(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 = p0.mapOf(kotlin.l.to(HttpHost.DEFAULT_SCHEME_NAME, 8336L), kotlin.l.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 z, int i, Object obj) {
if ((i & 1) != 0) {
z = true;
}
return aKCDiscoverNode.detect(z);
}
public static final void m3detect$lambda0(ak.f.b retrofit, final AKCDiscoverNode this$0, final long j, final b0 result) {
r.checkNotNullParameter(retrofit, "$retrofit");
r.checkNotNullParameter(this$0, "this$0");
r.checkNotNullParameter(result, "result");
retrofit.getAKAPI(5).speedTest().subscribeOn(io.reactivex.w0.a.io()).subscribe(new ak.j.a<retrofit2.l<d0>>() {
@Override
public void onError(@NotNull Throwable e2) {
r.checkNotNullParameter(e2, "e");
Log.d(AKCDiscoverNode.TAG, "lwxdetect onError " + AKCDiscoverNode.this.getIp() + ':' + AKCDiscoverNode.this.httpPort());
if (a0.isNetWorkAvailableInPhysical()) {
if (e2 instanceof HttpException) {
AKCDiscoverNode.this.report(AKCDiscoverGlobal.AKCDiscoverError_NodeDetect_Api_Error);
} else if (AkeyChatUtils.IsOrContainCertificateException(e2)) {
AKCDiscoverNode.this.report(AKCDiscoverGlobal.AKCDiscoverError_NodeDetect_PeerInvalid_Error);
} else if (AkeyChatUtils.IsCertificateDateValidException(e2)) {
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.l<d0> 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, r.stringPlus("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() - j));
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 i) {
int i2 = this.detectScore;
int i3 = this.detectCount;
this.detectScore = ((i2 * (i3 - 1)) + i) / i3;
}
@NotNull
public final z<Boolean> detect(boolean z) {
if (!z) {
z<Boolean> just = z.just(Boolean.TRUE);
r.checkNotNullExpressionValue(just, "just(true)");
return just;
} else if (AKApplication.f139b) {
z<Boolean> just2 = z.just(Boolean.TRUE);
r.checkNotNullExpressionValue(just2, "just(true)");
return just2;
} else if (!a0.isNetWorkAvailableInPhysical()) {
z<Boolean> just3 = z.just(Boolean.TRUE);
r.checkNotNullExpressionValue(just3, "just(true)");
return just3;
} else {
this.detectCount++;
final long currentTimeMillis = System.currentTimeMillis();
final ak.f.b bVar = new ak.f.b("https://" + this.ip + ':' + httpPort(), false, false);
z<Boolean> create = z.create(new c0() {
@Override
public final void subscribe(b0 b0Var) {
AKCDiscoverNode.m3detect$lambda0(ak.f.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 = p0.mapOf(kotlin.l.to(HttpHost.DEFAULT_SCHEME_NAME, Long.valueOf(Long.parseLong(this.discoveryServerNodePort.getHttp()))), kotlin.l.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;
mapOf = p0.mapOf(kotlin.l.to(HttpHost.DEFAULT_SCHEME_NAME, 8336L), kotlin.l.to("https", 8663L));
try {
mapOf = getServerNodePort();
} catch (Throwable th) {
th.printStackTrace();
}
Long l = mapOf.containsKey("https") ? mapOf.get("https") : mapOf.get(HttpHost.DEFAULT_SCHEME_NAME);
Objects.requireNonNull(l, "null cannot be cast to non-null type kotlin.Long");
return l.longValue();
}
@NotNull
public final AKCDiscoverGlobal.DiscoverInstanceResponse queryDiscoverInstance(int i, @NotNull final String searchKey) {
HashMap hashMapOf;
String str;
AKCDiscoverInstance aKCDiscoverInstance;
Object obj;
int i2;
long currentTimeMillis;
Object obj2;
int addFlag;
r.checkNotNullParameter(searchKey, "searchKey");
Log.i(TAG, "discover server " + searchKey + " in node " + this.ip + ",in" + ((Object) 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 = p0.hashMapOf(kotlin.l.to(IMMessage.CARD_SERVER_KEY, searchKey), kotlin.l.to("product", BuildConfig.PRODUCT_TYPE), kotlin.l.to("deviceType", "android"), kotlin.l.to("deviceId", ye.getInstance().getmLoginCfg().getUuid()), kotlin.l.to(RosterVer.ELEMENT, ye.getInstance().getVersion()));
AKCDiscoverGlobal.Companion companion = AKCDiscoverGlobal.Companion;
okhttp3.e 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");
okhttp3.c0 execute = apiCall$default.execute();
Log.d(TAG, r.stringPlus("discover instance executed.", Integer.valueOf(execute.code())));
if (AKCCheckPoint.isChecking("CHECKPOINT_LOGIN") != null) {
AKCCheckPoint.actionPointEnd("CHECKPOINT_LOGIN", "idp");
}
if (execute.code() != 200) {
Log.e(TAG, r.stringPlus("discover instance err ", Integer.valueOf(execute.code())));
calculateTheDetectScoreByRule(5000);
save();
discoverInstanceResponse.getError().setCode(AKCDiscoverGlobal.AKCDiscoverError_IDParse_Response_Error);
AKCDiscoverGlobal.DiscoverError error = discoverInstanceResponse.getError();
String string = o1.get().getString(b2.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", "");
d0 body = execute.body();
com.google.gson.l asJsonObject = com.google.gson.m.parseString(body == null ? null : body.string()).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");
u headers = execute.headers();
if (TextUtils.isEmpty(headers == null ? null : headers.get("X-AK-Loc"))) {
str = "CN";
} else {
u headers2 = execute.headers();
str = headers2 == null ? null : headers2.get("X-AK-Loc");
r.checkNotNull(str);
r.checkNotNullExpressionValue(str, "response?.headers()?.get(\"X-AK-Loc\")!!");
}
Log.d(TAG, r.stringPlus("discover instance loc:", str));
return_ob.addProperty("location", str);
return_ob.addProperty("geo", header);
AKCDiscoverInstance discoverInstance = companion.getDiscoverInstance(r.stringPlus(companion.getDISCOVERINSTANCE_CACHE_PERFIX(), searchKey), new kotlin.jvm.b.a<AKCDiscoverInstance>() {
{
super(0);
}
@Override
@Nullable
public final AKCDiscoverInstance invoke() {
AKCDiscoverInstance aKCDiscoverInstance2 = new AKCDiscoverInstance();
aKCDiscoverInstance2.setSearchKey(searchKey);
return aKCDiscoverInstance2;
}
});
r.checkNotNull(discoverInstance);
discoverInstance.scoreServerNetInfo(1);
ServerNetInfo serverNetInfo = discoverInstance.getBestAccessServerNetInfo() != -1 ? discoverInstance.getServer_net_info().get(discoverInstance.getBestAccessServerNetInfo()) : null;
v vVar = v.a;
return_ob.addProperty("nodeId", getId());
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 sb = new StringBuilder();
sb.append("instance changed,current:");
sb.append(discoverInstance);
sb.append(",local:");
sb.append(isChange.getSecond() == null ? "null" : isChange.getSecond());
Log.e(TAG, sb.toString());
}
AKCDiscoverInstance second = isChange.getSecond();
if (second != null) {
int i3 = 0;
for (int size = discoverInstance.getServer_net_info().size(); i3 < size; size = i2) {
int i4 = i3 + 1;
Iterator<T> it = second.getServer_net_info().iterator();
while (true) {
if (!it.hasNext()) {
aKCDiscoverInstance = second;
obj = null;
break;
}
obj = it.next();
aKCDiscoverInstance = second;
if (r.areEqual(((ServerNetInfo) obj).getNode_id(), discoverInstance.getServer_net_info().get(i3).getNode_id())) {
break;
}
second = aKCDiscoverInstance;
}
ServerNetInfo serverNetInfo2 = (ServerNetInfo) obj;
if (serverNetInfo2 == null) {
i2 = size;
} else {
discoverInstance.getServer_net_info().get(i3).copyScores(serverNetInfo2);
if (r.areEqual(discoverInstance.getServer_net_info().get(i3).ip(), serverNetInfo2.ip()) && r.areEqual(discoverInstance.getServer_net_info().get(i3).getDiscovery_port(), serverNetInfo2.getDiscovery_port()) && r.areEqual(discoverInstance.getServer_net_info().get(i3).getDetect_port(), serverNetInfo2.getDetect_port())) {
if (Build.VERSION.SDK_INT >= 26) {
currentTimeMillis = Instant.now().getEpochSecond();
i2 = size;
} else {
i2 = size;
currentTimeMillis = System.currentTimeMillis() / 1000;
}
if (discoverInstance.getServer_net_info().get(i3).getReset_duration() > currentTimeMillis) {
discoverInstance.getServer_net_info().get(i3).reSet(searchKey);
}
} else {
i2 = size;
discoverInstance.getServer_net_info().get(i3).reSet(searchKey);
}
if (DiscoverExtKt.hasFlag(i, 8)) {
discoverInstance.getServer_net_info().get(i3).reSet(searchKey);
}
v vVar2 = v.a;
}
i3 = i4;
second = aKCDiscoverInstance;
}
v vVar3 = v.a;
}
ServerNetInfo serverNetInfo3 = serverNetInfo;
if (serverNetInfo3 != null) {
Iterator<T> it2 = discoverInstance.getServer_net_info().iterator();
while (true) {
if (!it2.hasNext()) {
obj2 = null;
break;
}
Object next = it2.next();
if (r.areEqual(((ServerNetInfo) next).getNode_id(), serverNetInfo3.getNode_id())) {
obj2 = next;
break;
}
}
ServerNetInfo serverNetInfo4 = (ServerNetInfo) obj2;
if (serverNetInfo4 != null) {
if (r.areEqual(serverNetInfo4, serverNetInfo3)) {
discoverInstanceResponse.setStatus(DiscoverExtKt.addFlag(discoverInstanceResponse.getStatus(), 4));
}
v vVar4 = v.a;
}
}
if (isChange.getFirst().booleanValue()) {
discoverInstanceResponse.setStatus(DiscoverExtKt.addFlag(discoverInstanceResponse.getStatus(), 2));
}
if (DiscoverExtKt.hasFlag(i, 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 = o1.get().getString(b2.login_failed_hint_5);
r.checkNotNullExpressionValue(string2, "get().getString(R.string.login_failed_hint_5)");
error4.setDescription(string2);
}
v vVar5 = v.a;
}
} catch (Exception e2) {
e2.printStackTrace();
Log.e(TAG, r.stringPlus("discover server err ", e2.getMessage()));
discoverInstanceResponse.getError().setCode(AKCDiscoverGlobal.AKCDiscoverError_IDParse_TimeOut_Error);
AKCDiscoverGlobal.DiscoverError error5 = discoverInstanceResponse.getError();
String string3 = o1.get().getString(b2.Login_failed_hint_23);
r.checkNotNullExpressionValue(string3, "get().getString(R.string.Login_failed_hint_23)");
error5.setDescription(string3);
if (!a0.isNetWorkAvailableInPhysical()) {
discoverInstanceResponse.getError().setCode(AKCDiscoverGlobal.AKCDiscoverError_LocalNetErr);
AKCDiscoverGlobal.DiscoverError error6 = discoverInstanceResponse.getError();
String string4 = o1.get().getString(b2.login_failed_hint_8);
r.checkNotNullExpressionValue(string4, "get().getString(R.string.login_failed_hint_8)");
error6.setDescription(string4);
} else if (AkeyChatUtils.IsOrContainCertificateException(e2)) {
discoverInstanceResponse.getError().setCode(AKCDiscoverGlobal.AKCDiscoverError_IDParse_PeerInvalid_Error);
if (DiscoverExtKt.isID(searchKey)) {
AKCDiscoverGlobal.DiscoverError error7 = discoverInstanceResponse.getError();
String string5 = o1.get().getString(b2.certificate_failed);
r.checkNotNullExpressionValue(string5, "get().getString(R.string.certificate_failed)");
error7.setDescription(string5);
} else {
AKCDiscoverGlobal.DiscoverError error8 = discoverInstanceResponse.getError();
String string6 = o1.get().getString(b2.certificate_failed_search);
r.checkNotNullExpressionValue(string6, "get().getString(R.string…ertificate_failed_search)");
error8.setDescription(string6);
}
} else if (AkeyChatUtils.IsCertificateDateValidException(e2) || ((e2 instanceof StreamResetException) && ((StreamResetException) e2).errorCode == ErrorCode.PROTOCOL_ERROR && AKCAppConfiguration.a.mtlsIsExpires())) {
discoverInstanceResponse.getError().setCode(AKCDiscoverGlobal.AKCDiscoverError_IDParse_ClientInvalid_Error);
AKCDiscoverGlobal.DiscoverError error9 = discoverInstanceResponse.getError();
String string7 = o1.get().getString(b2.local_certificate_failed);
r.checkNotNullExpressionValue(string7, "get().getString(R.string.local_certificate_failed)");
error9.setDescription(string7);
}
}
return discoverInstanceResponse;
}
public final void report(int i) {
Map mapOf;
try {
mapOf = p0.mapOf(kotlin.l.to("id", this.id), kotlin.l.to(NotifyType.SOUND, String.valueOf(this.detectScore)), kotlin.l.to(NotifyType.LIGHTS, String.valueOf(AKCDiscoverInstance.Companion.getCurrentLocation())), kotlin.l.to("t", String.valueOf(i)));
AKCCheckPoint.aliyunLog(mapOf, AKCCheckPoint.AKCSLSLogTopic.AKCSLSLogTopic_IDPARSENODE.getValue());
} catch (Throwable th) {
Log.i(TAG, "report " + i + " failed,e is " + ((Object) th.getMessage()));
}
}
public final void save() {
HttpURLTools.initIdNodeHosts(this.ip);
ak.db.e.KV().putString(r.stringPlus(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 i) {
this.detectCount = i;
}
public final void setDetectFailedCount(int i) {
this.detectFailedCount = i;
}
public final void setDetectScore(int i) {
this.detectScore = i;
}
public final void setDetectSuccessCount(int i) {
this.detectSuccessCount = i;
}
public final void setDetectSuccessLastTime(long j) {
this.detectSuccessLastTime = j;
}
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 + ')';
}
@kotlin.j(d1 = {"\u0000D\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0002\b\u0002\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0003\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0010 \n\u0002\b\u0004\n\u0002\u0010!\n\u0002\b\u0005\b\u0086\u0003\u0018\u00002\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0002J\u0006\u0010\u0007\u001a\u00020\bJ\u0006\u0010\t\u001a\u00020\u0006J\u001a\u0010\n\u001a\u00020\b2\u0006\u0010\u000b\u001a\u00020\f2\b\b\u0002\u0010\r\u001a\u00020\u0004H\u0007J\u0010\u0010\u000e\u001a\u00020\u000f2\u0006\u0010\u0010\u001a\u00020\u0006H\u0002J\u0012\u0010\u0011\u001a\u000e\u0012\n\u0012\b\u0012\u0004\u0012\u00020\u000f0\u00130\u0012J\f\u0010\u0014\u001a\b\u0012\u0004\u0012\u00020\u000f0\u0013J\u001c\u0010\u0015\u001a\u00020\u00042\u0006\u0010\u0016\u001a\u00020\u00062\f\u0010\u0017\u001a\b\u0012\u0004\u0012\u00020\u000f0\u0018J\u0014\u0010\u0015\u001a\u00020\u00042\f\u0010\u0019\u001a\b\u0012\u0004\u0012\u00020\u000f0\u0018J\u000e\u0010\u001a\u001a\u00020\b2\u0006\u0010\u001b\u001a\u00020\u0006J\f\u0010\u001c\u001a\b\u0012\u0004\u0012\u00020\u00040\u0012R\u000e\u0010\u0003\u001a\u00020\u0004X\u0086T¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0006X\u0086T¢\u0006\u0002\n\u0000¨\u0006\u001d"}, d2 = {"Lak/im/module/AKCDiscoverNode$Companion;", "", "()V", "INDEBUG", "", "TAG", "", "clearNodesCache", "", "defaultNode", "detectBackground", "interval", "", "needUpdate", "init", "Lak/im/module/AKCDiscoverNode;", "json", "loadNodes", "Lio/reactivex/Observable;", "", "loadNodesSync", "saveNodes", "nodejsons", "nodes", "", "list", "saveTestDiscoveryNodeIpForBnet", "ip", "updateNodesOnline", "ak-im_carrotArmV7Release"}, k = 1, mv = {1, 6, 0}, xi = 48)
public static final class Companion {
private Companion() {
}
public Companion(o oVar) {
this();
}
public static void detectBackground$default(Companion companion, int i, boolean z, int i2, Object obj) {
if ((i2 & 2) != 0) {
z = false;
}
companion.detectBackground(i, z);
}
public static final v m4detectBackground$lambda10(int i, final Ref$BooleanRef update, final List a, final boolean z, List it) {
List sortedWith;
r.checkNotNullParameter(update, "$update");
r.checkNotNullParameter(a, "$a");
r.checkNotNullParameter(it, "it");
sortedWith = CollectionsKt___CollectionsKt.sortedWith(it, new Comparator() {
@Override
public final int compare(T t, T t2) {
int compareValues;
compareValues = kotlin.x.b.compareValues(Integer.valueOf(((AKCDiscoverNode) t).getDetectSuccessCount()), Integer.valueOf(((AKCDiscoverNode) t2).getDetectSuccessCount()));
return compareValues;
}
});
int i2 = 0;
for (Object obj : sortedWith) {
int i3 = i2 + 1;
if (i2 < 0) {
CollectionsKt__CollectionsKt.throwIndexOverflow();
}
final AKCDiscoverNode aKCDiscoverNode = (AKCDiscoverNode) obj;
final boolean z2 = i2 == sortedWith.size() - 1;
z.timer(i2 * i, TimeUnit.SECONDS, io.reactivex.w0.a.io()).subscribe(new io.reactivex.s0.g() {
@Override
public final void accept(Object obj2) {
AKCDiscoverNode.Companion.m5detectBackground$lambda10$lambda9$lambda8(AKCDiscoverNode.this, update, a, z2, z, (Long) obj2);
}
});
i2 = i3;
}
return v.a;
}
public static final void m5detectBackground$lambda10$lambda9$lambda8(final AKCDiscoverNode value, final Ref$BooleanRef update, final List a, final boolean z, final boolean z2, Long l) {
r.checkNotNullParameter(value, "$value");
r.checkNotNullParameter(update, "$update");
r.checkNotNullParameter(a, "$a");
Log.d(AKCDiscoverNode.TAG, "detectBackground:" + value.getId() + ",IN THREAD:" + ((Object) Thread.currentThread().getName()));
value.detect(true).subscribe(new io.reactivex.s0.g() {
@Override
public final void accept(Object obj) {
AKCDiscoverNode.Companion.m6detectBackground$lambda10$lambda9$lambda8$lambda6(Ref$BooleanRef.this, value, a, z, z2, (Boolean) obj);
}
}, new io.reactivex.s0.g() {
@Override
public final void accept(Object obj) {
AKCDiscoverNode.Companion.m7detectBackground$lambda10$lambda9$lambda8$lambda7(a, value, update, z, z2, (Throwable) obj);
}
});
}
public static final void m6detectBackground$lambda10$lambda9$lambda8$lambda6(Ref$BooleanRef update, AKCDiscoverNode value, List a, boolean z, boolean z2, Boolean bool) {
r.checkNotNullParameter(update, "$update");
r.checkNotNullParameter(value, "$value");
r.checkNotNullParameter(a, "$a");
if (!bool.booleanValue()) {
if (!update.element) {
update.element = value.getDetectFailedCount() >= 5;
}
a.add(new s(value.getId(), value.getDetectScore()));
}
if (z) {
AKCDiscoverManager.a aVar = AKCDiscoverManager.a;
String enterpriseId = ye.getInstance().getServer() != null ? ye.getInstance().getServer().getEnterpriseId() : ye.getInstance().getServerId();
r.checkNotNullExpressionValue(enterpriseId, "if (AppConfigManager.get…er.getInstance().serverId");
aVar.upLoadDiscoverError(enterpriseId, "detect", a);
a.clear();
if (a0.isNetWorkAvailableInPhysical() && z2 && update.element) {
AKCDiscoverNode.Companion.updateNodesOnline().subscribe();
}
}
}
public static final void m7detectBackground$lambda10$lambda9$lambda8$lambda7(List a, AKCDiscoverNode value, Ref$BooleanRef update, boolean z, boolean z2, Throwable th) {
r.checkNotNullParameter(a, "$a");
r.checkNotNullParameter(value, "$value");
r.checkNotNullParameter(update, "$update");
a.add(new s(value.getId(), value.getDetectScore()));
if (!update.element) {
update.element = value.getDetectFailedCount() >= 5;
}
if (z) {
AKCDiscoverManager.a aVar = AKCDiscoverManager.a;
String enterpriseId = ye.getInstance().getServer() != null ? ye.getInstance().getServer().getEnterpriseId() : ye.getInstance().getServerId();
r.checkNotNullExpressionValue(enterpriseId, "if (AppConfigManager.get…er.getInstance().serverId");
aVar.upLoadDiscoverError(enterpriseId, "detect", a);
a.clear();
if (a0.isNetWorkAvailableInPhysical() && z2 && update.element) {
AKCDiscoverNode.Companion.updateNodesOnline().subscribe();
}
}
}
private final AKCDiscoverNode init(String str) {
Object fromJson = new com.google.gson.d().fromJson(str, (Class<Object>) AKCDiscoverNode.class);
r.checkNotNullExpressionValue(fromJson, "Gson().fromJson(json,AKCDiscoverNode::class.java)");
return (AKCDiscoverNode) fromJson;
}
public static final void m8loadNodes$lambda1(b0 ob) {
r.checkNotNullParameter(ob, "ob");
Log.d(AKCDiscoverNode.TAG, r.stringPlus("loadNotes IN: ", Thread.currentThread().getName()));
ob.onNext(AKCDiscoverNode.Companion.loadNodesSync());
}
public static final void m9updateNodesOnline$lambda11(final b0 result) {
r.checkNotNullParameter(result, "result");
if (ye.getInstance().x1) {
result.onComplete();
return;
}
com.google.gson.l lVar = new com.google.gson.l();
lVar.addProperty("nodeParentId", (Number) 0);
lVar.addProperty("nodeType", "loadBalance");
okhttp3.b0 create = okhttp3.b0.create(w.parse("application/json; charset=utf-8"), lVar.toString());
new ak.f.b("https://" + ((Object) ye.getInstance().getOssCenterHost()) + '/', false, false).getAKAPI(10).updateNodes(create).subscribe(new ak.j.a<t>() {
@Override
public void onError(@NotNull Throwable e2) {
Map mapOf;
Map mapOf2;
Map mapOf3;
Map mapOf4;
r.checkNotNullParameter(e2, "e");
super.onError(e2);
e2.printStackTrace();
Log.i(AKCDiscoverNode.TAG, r.stringPlus("updateNodesOnline error is ", e2.getMessage()));
String string = o1.get().getString(b2.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 (!a0.isNetWorkAvailableInPhysical()) {
discoverError.setCode(AKCDiscoverGlobal.AKCDiscoverError_LocalNetErr);
String string2 = o1.get().getString(b2.login_failed_hint_8);
r.checkNotNullExpressionValue(string2, "get().getString(R.string.login_failed_hint_8)");
discoverError.setDescription(string2);
} else if (e2 instanceof HttpException) {
discoverError.setCode(AKCDiscoverGlobal.AKCDiscoverError_NodeUpdate_Error);
String string3 = o1.get().getString(b2.login_failed_hint_20, String.valueOf(((HttpException) e2).code()));
r.checkNotNullExpressionValue(string3, "get().getString(R.string…t_20,e.code().toString())");
discoverError.setDescription(string3);
mapOf4 = p0.mapOf(kotlin.l.to(NotifyType.LIGHTS, String.valueOf(AKCDiscoverInstance.Companion.getCurrentLocation())), kotlin.l.to("t", "200002"));
AKCCheckPoint.aliyunLog(mapOf4, AKCCheckPoint.AKCSLSLogTopic.AKCSLSLogTopic_IDPARSENODE.getValue());
} else if (AkeyChatUtils.IsOrContainCertificateException(e2)) {
discoverError.setCode(AKCDiscoverGlobal.AKCDiscoverError_NodeUpdate_PeerInvalid_Error);
String string4 = o1.get().getString(b2.certificate_failed_node);
r.checkNotNullExpressionValue(string4, "get().getString(R.string.certificate_failed_node)");
discoverError.setDescription(string4);
mapOf3 = p0.mapOf(kotlin.l.to(NotifyType.LIGHTS, String.valueOf(AKCDiscoverInstance.Companion.getCurrentLocation())), kotlin.l.to("t", "200005"));
AKCCheckPoint.aliyunLog(mapOf3, AKCCheckPoint.AKCSLSLogTopic.AKCSLSLogTopic_IDPARSENODE.getValue());
} else if (AkeyChatUtils.IsCertificateDateValidException(e2)) {
discoverError.setCode(AKCDiscoverGlobal.AKCDiscoverError_NodeUpdate_ClientInvalid_Error);
String string5 = o1.get().getString(b2.local_certificate_failed);
r.checkNotNullExpressionValue(string5, "get().getString(R.string.local_certificate_failed)");
discoverError.setDescription(string5);
mapOf2 = p0.mapOf(kotlin.l.to(NotifyType.LIGHTS, String.valueOf(AKCDiscoverInstance.Companion.getCurrentLocation())), kotlin.l.to("t", "200006"));
AKCCheckPoint.aliyunLog(mapOf2, AKCCheckPoint.AKCSLSLogTopic.AKCSLSLogTopic_IDPARSENODE.getValue());
} else {
mapOf = p0.mapOf(kotlin.l.to(NotifyType.LIGHTS, String.valueOf(AKCDiscoverInstance.Companion.getCurrentLocation())), kotlin.l.to("t", "200007"));
AKCCheckPoint.aliyunLog(mapOf, AKCCheckPoint.AKCSLSLogTopic.AKCSLSLogTopic_IDPARSENODE.getValue());
}
result.onError(new AKCDiscoverGlobal.DiscoverGlobalException(discoverError));
}
@Override
public void onNext(@NotNull t t) {
Map mapOf;
Map mapOf2;
r.checkNotNullParameter(t, "t");
int code = t.getCode();
if (code == 200 && t.getData().size() > 0) {
AKCDiscoverNode.Companion companion = AKCDiscoverNode.Companion;
List<AKCDiscoverNode> data = t.getData();
r.checkNotNullExpressionValue(data, "t.data");
boolean z = !companion.saveNodes(data);
Log.i(AKCDiscoverNode.TAG, r.stringPlus("updateNodesOnline need retry is ", Boolean.valueOf(z)));
result.onNext(Boolean.valueOf(z));
return;
}
String message = t.getMessage();
r.checkNotNullExpressionValue(message, "t.message");
AKCDiscoverGlobal.DiscoverError discoverError = new AKCDiscoverGlobal.DiscoverError(AKCDiscoverGlobal.AKCDiscoverError_NodeUpdate_Api_Error, message, 0, 4, null);
if (code == 500) {
String string = o1.get().getString(b2.login_failed_hint_18);
r.checkNotNullExpressionValue(string, "get().getString(R.string.login_failed_hint_18)");
discoverError.setDescription(string);
} else {
String message2 = t.getMessage();
if ((message2 == null || message2.length() == 0) || code == 200) {
discoverError.setCode(AKCDiscoverGlobal.AKCDiscoverError_NodeUpdate_Empty_Error);
String string2 = o1.get().getString(b2.login_failed_hint_4);
r.checkNotNullExpressionValue(string2, "get().getString(R.string.login_failed_hint_4)");
discoverError.setDescription(string2);
}
}
if (code > 0) {
mapOf2 = p0.mapOf(kotlin.l.to(NotifyType.LIGHTS, String.valueOf(AKCDiscoverInstance.Companion.getCurrentLocation())), kotlin.l.to("t", String.valueOf(code + AKCDiscoverGlobal.AKCDiscoverError_NodeUpdate_Error)));
AKCCheckPoint.aliyunLog(mapOf2, AKCCheckPoint.AKCSLSLogTopic.AKCSLSLogTopic_IDPARSENODE.getValue());
} else {
mapOf = p0.mapOf(kotlin.l.to(NotifyType.LIGHTS, String.valueOf(AKCDiscoverInstance.Companion.getCurrentLocation())), kotlin.l.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);
Objects.requireNonNull(fromJson, "null cannot be cast to non-null type kotlin.collections.List<kotlin.String>");
emptyList = (List) fromJson;
} else {
emptyList = CollectionsKt__CollectionsKt.emptyList();
}
ak.db.e.KV().remove(companion.getNODES_IDS_CACHE_KEY());
for (String str : emptyList) {
ak.db.e.KV().remove(r.stringPlus(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 i, final boolean z) {
final Ref$BooleanRef ref$BooleanRef = new Ref$BooleanRef();
final ArrayList arrayList = new ArrayList();
loadNodes().subscribeOn(io.reactivex.w0.a.io()).map(new io.reactivex.s0.o() {
@Override
public final Object apply(Object obj) {
v m4detectBackground$lambda10;
m4detectBackground$lambda10 = AKCDiscoverNode.Companion.m4detectBackground$lambda10(i, ref$BooleanRef, arrayList, z, (List) obj);
return m4detectBackground$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.m8loadNodes$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);
Objects.requireNonNull(fromJson, "null cannot be cast to non-null type kotlin.collections.List<kotlin.String>");
emptyList = (List) fromJson;
} 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(r.stringPlus(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)");
arrayList.add((AKCDiscoverNode) fromJson2);
}
}
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.u.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.u.collectionSizeOrDefault(nodes, 10);
ArrayList arrayList = new ArrayList(collectionSizeOrDefault);
for (AKCDiscoverNode aKCDiscoverNode : nodes) {
arrayList.add(aKCDiscoverNode.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.u.a<List<AKCDiscoverNode>>() {
}.getType());
Log.i(AKCDiscoverNode.TAG, r.stringPlus("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.m9updateNodesOnline$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.u.collectionSizeOrDefault(list, 10);
ArrayList arrayList = new ArrayList(collectionSizeOrDefault);
for (AKCDiscoverNode aKCDiscoverNode : list) {
arrayList.add(aKCDiscoverNode.getId());
}
String json = dVar.toJson(arrayList);
Log.i("nodesdate", r.stringPlus("odl is :", string));
Log.i("nodesdate", r.stringPlus("new is :", json));
for (AKCDiscoverNode aKCDiscoverNode2 : list) {
aKCDiscoverNode2.save();
}
ak.db.e.KV().putString(AKCDiscoverGlobal.Companion.getNODES_IDS_CACHE_KEY(), json);
return string.equals(json);
}
}
}