4399游戏盒 v7.2.1.31版本的 MD5 值为:951717f45e3fda95c8a358caf4ca93e1
以下内容为反编译后的 HttpDnsLoader.java 源代码,内容仅作参考
package com.download.okhttp.dns;
import android.text.TextUtils;
import com.download.DownloadConfigKey;
import com.download.httpdns.CdnModel;
import com.download.okhttp.kidnaps.OkHttpKidnapHttpsHandler;
import com.download.utils.DownloadUtils;
import com.framework.config.Config;
import com.framework.utils.JSONUtils;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import javax.net.ssl.HttpsURLConnection;
import org.json.JSONObject;
import timber.log.Timber;
public class HttpDnsLoader {
public static CdnModel loadTXDns(String str, AccountType accountType) {
Closeable closeable;
CdnModel cdnModel;
String str2;
HttpURLConnection httpURLConnection;
HttpURLConnection httpURLConnection2 = null;
InputStream inputStream = null;
httpURLConnection2 = null;
try {
TXAccount a2 = a(accountType);
a2.getId();
if (((Boolean) Config.getValue(DownloadConfigKey.DOWNLOAD_ENABLE_HTTP_DNS)).booleanValue()) {
str2 = "https://119.29.29.99/d?dn=" + str + "&token=" + a2.getToken();
} else {
str2 = "https://1.1.1.1/d?dn=" + str + "&id=" + a2.getToken();
}
httpURLConnection = (HttpURLConnection) new URL(str2).openConnection();
} catch (Exception e) {
e = e;
closeable = null;
} catch (Throwable th) {
th = th;
closeable = null;
}
try {
httpURLConnection.setConnectTimeout(((Integer) Config.getValue(DownloadConfigKey.DOWNLOAD_HTTPDNS_TIMEOUT)).intValue());
httpURLConnection.setRequestMethod("GET");
if (httpURLConnection.getResponseCode() == 200) {
inputStream = httpURLConnection.getInputStream();
String str3 = new String(c(inputStream), "UTF-8");
if (!TextUtils.isEmpty(str3)) {
cdnModel = new CdnModel(str, str3);
} else {
cdnModel = new CdnModel(str, "");
}
} else {
cdnModel = new CdnModel((Throwable) null, httpURLConnection.getResponseCode());
}
if (httpURLConnection != null) {
httpURLConnection.disconnect();
}
DownloadUtils.closeSilent(inputStream);
} catch (Exception e2) {
e = e2;
httpURLConnection2 = httpURLConnection;
closeable = null;
try {
cdnModel = new CdnModel(e, -1);
Timber.d(e, "loadALDns error", new Object[0]);
if (httpURLConnection2 != null) {
httpURLConnection2.disconnect();
}
DownloadUtils.closeSilent(closeable);
cdnModel.setDnsType(DnsType.TXDns);
return cdnModel;
} catch (Throwable th2) {
th = th2;
if (httpURLConnection2 != null) {
httpURLConnection2.disconnect();
}
DownloadUtils.closeSilent(closeable);
throw th;
}
} catch (Throwable th3) {
th = th3;
httpURLConnection2 = httpURLConnection;
closeable = null;
if (httpURLConnection2 != null) {
}
DownloadUtils.closeSilent(closeable);
throw th;
}
cdnModel.setDnsType(DnsType.TXDns);
return cdnModel;
}
private static TXAccount a(AccountType accountType) {
if (accountType == AccountType.XM) {
return new TXAccount("47246", "sZzukUmy", "jvFjULFqsqtKFFGI", "");
}
return new TXAccount("9671", "TOF24SjB", "0123456789ABCDEF", "705259213");
}
public static class AnonymousClass1 {
static final int[] xC = new int[AccountType.values().length];
static {
try {
xC[AccountType.XM.ordinal()] = 1;
} catch (NoSuchFieldError unused) {
}
}
}
private static ALAccount b(AccountType accountType) {
if (AnonymousClass1.xC[accountType.ordinal()] == 1) {
return new ALAccount("135683", "5554fbaf8377aefc7b96391dcd750160");
}
return new ALAccount("123465", "7aed3411a316a629f33887cc2ccf858d");
}
public static CdnModel loadALDns(String str, AccountType accountType) {
Closeable closeable;
CdnModel cdnModel;
String str2;
if (str.endsWith(OkHttpKidnapHttpsHandler.MYSITERES)) {
str = "sj.mysiteres.com";
}
HttpsURLConnection httpsURLConnection = null;
InputStream inputStream = null;
httpsURLConnection = null;
try {
ALAccount b = b(accountType);
long currentTimeMillis = System.currentTimeMillis() / 1000;
if (((Boolean) Config.getValue(DownloadConfigKey.DOWNLOAD_ENABLE_HTTP_DNS)).booleanValue()) {
str2 = "https://203.107.1.1/" + b.getId() + "/d?host=" + str;
} else {
str2 = "https://1.1.1.1/" + b.getId() + "/sign_d?host=" + str;
}
HttpsURLConnection httpsURLConnection2 = (HttpsURLConnection) new URL(str2).openConnection();
try {
httpsURLConnection2.setConnectTimeout(((Integer) Config.getValue(DownloadConfigKey.DOWNLOAD_HTTPDNS_TIMEOUT)).intValue());
httpsURLConnection2.setRequestMethod("GET");
if (httpsURLConnection2.getResponseCode() == 200) {
inputStream = httpsURLConnection2.getInputStream();
JSONObject parseJSONObjectFromString = JSONUtils.parseJSONObjectFromString(new String(c(inputStream), "UTF-8"));
if (parseJSONObjectFromString != null) {
cdnModel = new CdnModel(str, parseJSONObjectFromString);
} else {
cdnModel = new CdnModel(str, "");
}
} else {
cdnModel = new CdnModel((Throwable) null, httpsURLConnection2.getResponseCode());
}
if (httpsURLConnection2 != null) {
httpsURLConnection2.disconnect();
}
DownloadUtils.closeSilent(inputStream);
} catch (Exception e) {
e = e;
httpsURLConnection = httpsURLConnection2;
closeable = null;
try {
cdnModel = new CdnModel(e, -1);
Timber.e(e, "loadALDns error", new Object[0]);
if (httpsURLConnection != null) {
httpsURLConnection.disconnect();
}
DownloadUtils.closeSilent(closeable);
cdnModel.setDnsType(DnsType.ALDns);
return cdnModel;
} catch (Throwable th) {
th = th;
if (httpsURLConnection != null) {
httpsURLConnection.disconnect();
}
DownloadUtils.closeSilent(closeable);
throw th;
}
} catch (Throwable th2) {
th = th2;
httpsURLConnection = httpsURLConnection2;
closeable = null;
if (httpsURLConnection != null) {
}
DownloadUtils.closeSilent(closeable);
throw th;
}
} catch (Exception e2) {
e = e2;
closeable = null;
} catch (Throwable th3) {
th = th3;
closeable = null;
}
cdnModel.setDnsType(DnsType.ALDns);
return cdnModel;
}
private static byte[] c(InputStream inputStream) throws Exception {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] bArr = new byte[1024];
while (true) {
int read = inputStream.read(bArr);
if (read != -1) {
byteArrayOutputStream.write(bArr, 0, read);
} else {
inputStream.close();
return byteArrayOutputStream.toByteArray();
}
}
}
}