流利说-英语 v8.47.26版本的 MD5 值为:0079dce5ff96e6cdbc95c261b3f51387
以下内容为反编译后的 c.java 源代码,内容仅作参考
package com.liulishuo.thanossdk.network.dns.provider;
import com.liulishuo.thanossdk.utils.Hex;
import com.liulishuo.thanossdk.utils.ThanosSelfLog;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.util.List;
import java.util.ListIterator;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import kotlin.TypeCastException;
import kotlin.collections.k;
import kotlin.i;
import kotlin.jvm.internal.o;
import kotlin.jvm.internal.t;
import kotlin.text.Regex;
import kotlin.text.d;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
@i
public final class c implements com.liulishuo.thanossdk.network.dns.b {
private final OkHttpClient bUd;
private final String iTD;
private final SecretKeySpec iTF;
private final String id;
public c(OkHttpClient.Builder okHttpBuilder, String id, String key, String apiUrl) {
t.f(okHttpBuilder, "okHttpBuilder");
t.f(id, "id");
t.f(key, "key");
t.f(apiUrl, "apiUrl");
this.id = id;
this.iTD = apiUrl;
this.bUd = okHttpBuilder.build();
try {
Charset forName = Charset.forName("utf-8");
t.d(forName, "Charset.forName(charsetName)");
byte[] bytes = key.getBytes(forName);
t.d(bytes, "(this as java.lang.String).getBytes(charset)");
this.iTF = new SecretKeySpec(bytes, "DES");
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
public c(OkHttpClient.Builder builder, String str, String str2, String str3, int i, o oVar) {
this(builder, str, str2, (i & 8) != 0 ? "119.29.29.29" : str3);
}
@Override
public com.liulishuo.thanossdk.network.dns.a te(String domain) {
Response response;
List emptyList;
List emptyList2;
t.f(domain, "domain");
com.liulishuo.thanossdk.network.dns.a aVar = new com.liulishuo.thanossdk.network.dns.a();
try {
response = this.bUd.newCall(new Request.Builder().url("http://" + this.iTD + "/d?ttl=1&dn=" + encrypt(domain) + "&id=" + this.id).build()).execute();
t.d(response, "response");
} catch (Exception e) {
aVar.lJ(false);
aVar.td("Dnspod query error, message = " + e.getMessage());
ThanosSelfLog.a(ThanosSelfLog.iUo, null, new kotlin.jvm.a.a<String>() {
{
super(0);
}
@Override
public final String invoke() {
return "Dnspod query error, message = " + e.getMessage();
}
}, 1, null);
}
if (response.isSuccessful()) {
ResponseBody body = response.body();
String string = body != null ? body.string() : null;
if (string != null) {
if (string.length() > 0) {
List<String> split = new Regex(",").split(decrypt(string), 0);
if (!split.isEmpty()) {
ListIterator<String> listIterator = split.listIterator(split.size());
while (listIterator.hasPrevious()) {
if (!(listIterator.previous().length() == 0)) {
emptyList = kotlin.collections.t.d(split, listIterator.nextIndex() + 1);
break;
}
}
}
emptyList = kotlin.collections.t.emptyList();
List list = emptyList;
if (list == null) {
throw new TypeCastException("null cannot be cast to non-null type java.util.Collection<T>");
}
Object[] array = list.toArray(new String[0]);
if (array != null) {
String[] strArr = (String[]) array;
if (strArr.length != 2) {
throw new RuntimeException("Dnspod response body format is illegal");
}
List<String> split2 = new Regex(";").split(strArr[0], 0);
if (!split2.isEmpty()) {
ListIterator<String> listIterator2 = split2.listIterator(split2.size());
while (listIterator2.hasPrevious()) {
if (!(listIterator2.previous().length() == 0)) {
emptyList2 = kotlin.collections.t.d(split2, listIterator2.nextIndex() + 1);
break;
}
}
}
emptyList2 = kotlin.collections.t.emptyList();
List list2 = emptyList2;
if (list2 == null) {
throw new TypeCastException("null cannot be cast to non-null type java.util.Collection<T>");
}
Object[] array2 = list2.toArray(new String[0]);
if (array2 != null) {
String[] strArr2 = (String[]) array2;
if (strArr2.length == 0) {
throw new RuntimeException("Dnspod response ips is empty");
}
aVar.lJ(true);
aVar.ez(k.v(strArr2));
return aVar;
}
throw new TypeCastException("null cannot be cast to non-null type kotlin.Array<T>");
}
throw new TypeCastException("null cannot be cast to non-null type kotlin.Array<T>");
}
}
throw new RuntimeException("Dnspod response body is empty");
}
throw new RuntimeException("Dnspod response is not Successful");
}
private final String encrypt(String str) {
try {
Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
cipher.init(1, this.iTF);
Charset forName = Charset.forName("utf-8");
t.d(forName, "Charset.forName(charsetName)");
if (str == null) {
throw new TypeCastException("null cannot be cast to non-null type java.lang.String");
}
byte[] bytes = str.getBytes(forName);
t.d(bytes, "(this as java.lang.String).getBytes(charset)");
return Hex.encodeHexString(cipher.doFinal(bytes)) + "&id=" + this.id;
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
private final String decrypt(String str) {
try {
Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
cipher.init(2, this.iTF);
if (str != null) {
char[] charArray = str.toCharArray();
t.d(charArray, "(this as java.lang.String).toCharArray()");
byte[] decrypted = cipher.doFinal(Hex.decodeHex(charArray));
t.d(decrypted, "decrypted");
return new String(decrypted, d.UTF_8);
}
throw new TypeCastException("null cannot be cast to non-null type java.lang.String");
} catch (Exception e) {
e.printStackTrace();
return "";
}
}
@Override
public String dky() {
return this.iTD;
}
}