Sunflower v2.7.0版本的 MD5 值为:0696e8ce118febedd4bd019622cb23b1
以下内容为反编译后的 NetworkConfig.java 源代码,内容仅作参考
package im.grnuohmoqd.tgnet;
import android.text.TextUtils;
import com.aliyun.security.yunceng.android.sdk.YunCeng;
import com.google.android.exoplayer2.util.Log;
import com.king.zxing.util.LogUtils;
import im.grnuohmoqd.messenger.BuildVars;
import im.grnuohmoqd.messenger.FileLog;
import im.grnuohmoqd.ui.utils.AesUtils;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
public class NetworkConfig {
private static final int ENV_LOCAL = 1000;
private static final int ENV_LOCAL_TEST = 1001;
private static final int ENV_NONE = 0;
private static final int ENV_ONLINE = 1002;
private static final int ENV_ONLINE_GREY = 1004;
private static final int ENV_ONLINE_TEST = 1003;
private static final String[] IP_DEFALUT_ONLINE = {"Que.gz.que57dsfd.com", "11057"};
private static volatile NetworkConfig sInstance = new NetworkConfig();
private boolean inited;
private boolean initing;
private ArrayList<NetBean> connInfos = new ArrayList<>();
private int sCurrentConnection = -1;
@Retention(RetentionPolicy.SOURCE)
private @interface EnvNode {
}
public static NetworkConfig getInstance() {
NetworkConfig networkConfig = sInstance;
if (networkConfig == null) {
synchronized (NetworkConfig.class) {
networkConfig = sInstance;
if (networkConfig == null) {
networkConfig = new NetworkConfig();
sInstance = networkConfig;
}
}
}
return networkConfig;
}
public static void setIpPortDefaultAddress() {
String[] initNetconfig;
if (BuildVars.RELEASE_VERSION) {
initNetconfig = IP_DEFALUT_ONLINE;
} else {
initNetconfig = getInstance().initNetconfig(1001);
}
if (BuildVars.DEBUG_VERSION) {
StringBuilder sb = new StringBuilder();
sb.append("java NetWorkConfig setIpPortDefaultAddress ===> address = ");
sb.append(initNetconfig != null ? Arrays.toString(initNetconfig) : "null");
Log.i("connection", sb.toString());
}
if (initNetconfig == null || initNetconfig[0] == null || initNetconfig[1] == null) {
return;
}
for (int i = 0; i < 3; i++) {
ConnectionsManager.native_setIpPortDefaultAddress(i, initNetconfig[0], Integer.parseInt(initNetconfig[1]));
}
}
private NetworkConfig() {
}
public void applyNetconfig(int i) {
String[] initNetconfig;
if (BuildVars.RELEASE_VERSION) {
initNetconfig = initNetconfig(1002);
} else {
initNetconfig = initNetconfig(1002);
}
if (BuildVars.DEBUG_VERSION) {
StringBuilder sb = new StringBuilder();
sb.append("java NetWorkConfig applyNetconfig ===> address = ");
sb.append(initNetconfig != null ? Arrays.toString(initNetconfig) : "null");
Log.i("connection", sb.toString());
}
if (initNetconfig == null || initNetconfig[0] == null || initNetconfig[1] == null) {
return;
}
ConnectionsManager.getInstance(i).applyDatacenterAddress(2, initNetconfig[0], Integer.parseInt(initNetconfig[1]));
ConnectionsManager.getInstance(i).resumeNetworkMaybe();
}
private String[] initNetconfig(int i) {
switch (i) {
case 1000:
return new String[]{"192.200.1.117 ", "4445"};
case 1001:
return new String[]{"192.168.1.184", "31443"};
case 1002:
String[] initRemoteNetconfig = initRemoteNetconfig();
return (initRemoteNetconfig == null || initRemoteNetconfig.length != 2 || TextUtils.isEmpty(initRemoteNetconfig[0]) || TextUtils.isEmpty(initRemoteNetconfig[1])) ? IP_DEFALUT_ONLINE : initRemoteNetconfig;
case 1003:
return new String[]{"192.168.0.0", "55555"};
case 1004:
return new String[]{"36.255.220.245", "31443"};
default:
return null;
}
}
private String[] initRemoteNetconfig() {
if (this.inited) {
return selecteRemoteConnInfo();
}
if (this.initing) {
return null;
}
initRemoteConnInfos();
return selecteRemoteConnInfo();
}
private synchronized String[] selecteRemoteConnInfo() {
if (this.connInfos.size() == 0) {
return null;
}
if (this.sCurrentConnection == -1) {
this.sCurrentConnection = 0;
}
NetBean netBean = this.connInfos.get(this.sCurrentConnection);
if (this.sCurrentConnection != this.connInfos.size() - 1) {
this.sCurrentConnection++;
return new String[]{netBean.getdDomain(), netBean.getdPort()};
}
this.sCurrentConnection = -1;
this.inited = false;
return getYuncengConfig(netBean.getdName(), netBean.getdDomain(), netBean.getdPort());
}
private synchronized void initRemoteConnInfos() {
ByteArrayOutputStream byteArrayOutputStream;
this.initing = true;
InputStream inputStream = null;
try {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL("https://ufk15pew754g3i.oss-accelerate.aliyuncs.com/8sisjhlujrc.txt").openConnection();
httpURLConnection.addRequestProperty("User-Agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 10_0 like Mac OS X) AppleWebKit/602.1.38 (KHTML, like Gecko) Version/10.0 Mobile/14A5297c Safari/602.1");
httpURLConnection.setRequestMethod("GET");
httpURLConnection.setReadTimeout(5000);
httpURLConnection.setConnectTimeout(5000);
httpURLConnection.connect();
if (httpURLConnection.getResponseCode() == 200) {
InputStream inputStream2 = httpURLConnection.getInputStream();
try {
byte[] bArr = new byte[1024];
byteArrayOutputStream = new ByteArrayOutputStream();
while (true) {
try {
int read = inputStream2.read(bArr);
if (read == -1) {
break;
} else {
byteArrayOutputStream.write(bArr, 0, read);
}
} catch (Throwable th) {
th = th;
inputStream = inputStream2;
try {
FileLog.e(th);
this.initing = false;
this.sCurrentConnection = -1;
if (inputStream != null) {
try {
inputStream.close();
} catch (Throwable th2) {
FileLog.e(th2);
}
}
if (byteArrayOutputStream != null) {
try {
byteArrayOutputStream.close();
} catch (IOException e) {
e = e;
FileLog.e(e);
}
}
} finally {
}
}
}
String[] split = new String(AesUtils.decryptYunceng(new String(byteArrayOutputStream.toByteArray()))).split(",", 3);
for (int i = 0; i < split.length; i++) {
String str = split[i];
if (i != split.length - 1) {
String[] split2 = str.split(LogUtils.COLON, 2);
this.connInfos.add(new NetBean(null, split2[0], split2[1]));
} else {
String[] split3 = str.split("#", 3);
this.connInfos.add(new NetBean(split3[0], split3[1], split3[2]));
}
}
this.inited = true;
inputStream = inputStream2;
} catch (Throwable th3) {
th = th3;
byteArrayOutputStream = null;
}
} else {
byteArrayOutputStream = null;
}
this.initing = false;
this.sCurrentConnection = -1;
if (inputStream != null) {
try {
inputStream.close();
} catch (Throwable th4) {
FileLog.e(th4);
}
}
if (byteArrayOutputStream != null) {
try {
byteArrayOutputStream.close();
} catch (IOException e2) {
e = e2;
FileLog.e(e);
}
}
} catch (Throwable th5) {
th = th5;
byteArrayOutputStream = null;
}
}
private String[] getYuncengConfig(String str, String str2, String str3) {
StringBuffer stringBuffer = new StringBuffer();
StringBuffer stringBuffer2 = new StringBuffer();
int proxyTcpByDomain = YunCeng.getProxyTcpByDomain("Default", str, str2, str3, stringBuffer, stringBuffer2);
if (proxyTcpByDomain == 0) {
return new String[]{stringBuffer.toString(), stringBuffer2.toString()};
}
FileLog.e("YunCeng get next ip failed: " + proxyTcpByDomain);
return null;
}
}