♬♬ v1.0.0版本的 MD5 值为:04cc17073568ba22bfb83ea139fbe521
以下内容为反编译后的 NetworkConfig.java 源代码,内容仅作参考
package im.wgogsutsuz.tgnet;
import android.os.Process;
import android.text.TextUtils;
import com.alibaba.fastjson.JSONObject;
import com.aliyun.security.yunceng.android.sdk.YunCeng;
import com.csm.shield.GameShield;
import com.google.android.exoplayer2.util.Log;
import com.google.gson.Gson;
import com.king.zxing.util.LogUtils;
import com.qiniu.android.dns.DnsManager;
import com.qiniu.android.dns.IResolver;
import com.qiniu.android.dns.NetworkInfo;
import com.qiniu.android.dns.Record;
import com.qiniu.android.dns.dns.DohResolver;
import im.wgogsutsuz.messenger.AndroidUtilities;
import im.wgogsutsuz.messenger.BuildVars;
import im.wgogsutsuz.messenger.FileLog;
import im.wgogsutsuz.messenger.NotificationCenter;
import im.wgogsutsuz.messenger.UserConfig;
import im.wgogsutsuz.ui.hui.friendscircle_v1.view.expandTextView.model.UUIDUtils;
import im.wgogsutsuz.ui.utils.AesUtils;
import java.io.ByteArrayOutputStream;
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;
import obfuse.NPStringFog;
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 DnsManager dnsManager;
private boolean inited;
private boolean inited_doh;
private boolean initing;
private boolean initing_doh;
public static final String[] IP_DEFALUT_ONLINE = {NPStringFog.decode("0003061F011F011F00"), "0000"};
public static final String[] HOST = {NPStringFog.decode("59454541420B1E1E091F0300031F00081F0006071E555F421C4044544348"), "https://8.212.57.169/dns-query"};
private static volatile NetworkConfig sInstance = new NetworkConfig();
public static String gameAppId = NPStringFog.decode("72787C6274707468431E585B01567C5E497A5F67425668464B5652074B56555273677F7E625A78777963686077597457746309677959647D73646B696702597E60466455736363767901637477647C62725973746364747A7449786074465E5477016775725963756374746977597B7277647C667746647D7367637465017B7554776762620178777969495273677F5467017877796067445502595B535F67586B797C7772466763635A4562605664555770646274465A5477605A677749707B77636855794964577760647D7363607B7949097B776360637263686679630967794964777246646474465A677773787B7759645472636865796309677949647772466464726309627263646977605A60744901577763096773604277775970657263686779565A6574605A6777597C5579496457776067076656455273677F54670178777960675B5076415C535C5D0555697B436856647D7367777662007B72736301776700677860017F76695952667256635B73705E74556368697373496164007F6979605678737649585756607B60016B7E620004786777636267017C6977565D57695D017873764958575660776656455273677F5467017877796067445502595B535F67586B797C7772466763635A456260566455577064667749747B74597C7B77590554726364637963096779496477724664667473787B77637C7B775974607263646577490157776309677360427777595263726378657263685474705A6677737855794964577760647D7363686977565A6577705A6074465A67794901577763096773604277775964677263686277605A677749057B775970677963096779496477545D5E7D69706765695D557273630177680359406B5C0441547967485003787772466763635A456260566455736463656901417A655D7F657256635B73705E74556368697373496164007F6979605678737649585756607B63777F57625A417E64007C7B6374607873764958575660776656455273677F5467017877796067445502595B535F67586B797C7772466763635A456260566455577064647263527B77595266726368647773015777630967736042777759607B776364547263646974605A6677737C55794964577760647D736368577263686577605A6274605A6677637455794964577760647D736368647263646779565A667749647B77597C577963096779496477724664667763647B77637C577263646779565A697963096779496477545D5E7D69706765695D557273630177680359406B5C0441547967485003787772466763635A4562605664557367556762747F6162777B677749687A73760974725663007756605265007F656749017872706342685F057472640878645D677D695A596467777B6960495266726708546960567453767B1A737067507200467764000469605664557366040254767F4455667B5A5246647D7367777662007B7273630009736309677263686274605A6274565A6777736855794964577760647D73637C547263646477605A5774565A6777737855794964577760647D736309677263686274605A677773647B7459015777630967736042777949647B775978637263786472636469794901577763096773604277775905677263686574465A667773097B7459605579496457776067076656455273677F54670178777960675B5076415C535C5D0555697B436856647D7367777662007B727363017763777F577256634773705E745563687479740865640052557270567453767B1A73705D746400087A650159626764455463776772635A5E7B6374597A72706342685F05747367410766560C0C");
private String dohDomain = NPStringFog.decode("525F1F0208081F525E5C");
private ArrayList<NetBean> connInfos = new ArrayList<>();
private int sCurrentConnection = -1;
protected int currentAccount = UserConfig.selectedAccount;
private boolean start = true;
private int gamePort = 26652;
private int gameStart = 0;
@Retention(RetentionPolicy.SOURCE)
private @interface EnvNode {
}
public static NetworkConfig getInstance() {
NetworkConfig localInstance = sInstance;
if (localInstance == null) {
synchronized (NetworkConfig.class) {
localInstance = sInstance;
if (localInstance == null) {
NetworkConfig networkConfig = new NetworkConfig();
localInstance = networkConfig;
sInstance = networkConfig;
}
}
}
return localInstance;
}
public static void setIpPortDefaultAddress() {
String[] cfg;
if (BuildVars.RELEASE_VERSION) {
cfg = IP_DEFALUT_ONLINE;
} else {
cfg = getInstance().initNetconfig(1001);
}
if (BuildVars.DEBUG_VERSION) {
StringBuilder sb = new StringBuilder();
sb.append(NPStringFog.decode("5B504750117F5445665E435A725E5F575856114254457841615E434575545750445D4570555543544242110C0C0C0F1150555543544242110C11"));
sb.append(cfg != null ? Arrays.toString(cfg) : NPStringFog.decode("5F445D5D"));
Log.i(NPStringFog.decode("525E5F5F545245585E5F"), sb.toString());
}
if (cfg != null && cfg[0] != null && cfg[1] != null) {
for (int a = 0; a < 3; a++) {
ConnectionsManager.native_setIpPortDefaultAddress(a, cfg[0], Integer.parseInt(cfg[1]));
}
}
}
private NetworkConfig() {
}
public void applyNetconfig(int instance) {
String[] cfg;
if (BuildVars.RELEASE_VERSION) {
cfg = initNetconfig(1002);
} else {
cfg = initNetconfig(1002);
}
if (BuildVars.DEBUG_VERSION) {
StringBuilder sb = new StringBuilder();
sb.append(NPStringFog.decode("5B504750117F5445665E435A725E5F575856115041415D487F5445525E5F575856110C0C0C0F1150555543544242110C11"));
sb.append(cfg != null ? Arrays.toString(cfg) : NPStringFog.decode("5F445D5D"));
Log.i(NPStringFog.decode("525E5F5F545245585E5F"), sb.toString());
}
if (cfg != null && cfg[0] != null && cfg[1] != null) {
ConnectionsManager.getInstance(instance).applyDatacenterAddress(2, cfg[0], Integer.parseInt(cfg[1]));
ConnectionsManager.getInstance(instance).resumeNetworkMaybe();
}
}
public void initUrlDOH() {
this.initing_doh = true;
try {
try {
IResolver[] resolvers = {new DohResolver(HOST[0]), new DohResolver(HOST[1])};
DnsManager dnsManager = new DnsManager(NetworkInfo.normal, resolvers);
this.dnsManager = dnsManager;
Record[] records = dnsManager.queryRecords(this.dohDomain);
String recordsStr = JSONObject.toJSONString(records);
LogUtils.e(NPStringFog.decode("555E59D9BF86D4BEA7D7B9A1D4BBAE0C0C0C0C") + recordsStr);
if (records != null && records.length > 0) {
for (Record record : records) {
String ipAddress = record.value;
NetBean netBean = new NetBean(null, ipAddress, IP_DEFALUT_ONLINE[1]);
this.connInfos.add(netBean);
}
}
this.inited_doh = true;
this.sCurrentConnection = -1;
setServer2();
} catch (Exception e) {
e.printStackTrace();
}
} finally {
this.initing_doh = false;
}
}
private void setServer2() {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NetworkConfig.this.lambda$setServer2$0$NetworkConfig();
}
});
}
public void lambda$setServer2$0$NetworkConfig() {
String server2 = NPStringFog.decode("4254434754431103");
if (this.inited) {
server2 = NPStringFog.decode("5E42421A") + server2;
}
if (this.inited_doh) {
server2 = NPStringFog.decode("555E591A") + server2;
}
NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.getBackupIpStatus, server2);
}
private String[] initNetconfig(int node) {
if (this.start) {
this.start = false;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
NetworkConfig.this.lambda$initNetconfig$1$NetworkConfig();
}
});
}
String decode = NPStringFog.decode("0200050502");
switch (node) {
case 1000:
return new String[]{NPStringFog.decode("05061F0001051F0305021F0607"), "31537"};
case 1001:
return new String[]{NPStringFog.decode("0008031F0007091F001F000905"), decode};
case 1002:
String[] address = getGameShieldConfig();
if (address == null || address.length != 2 || TextUtils.isEmpty(address[0]) || TextUtils.isEmpty(address[1])) {
return null;
}
return address;
case 1003:
return new String[]{NPStringFog.decode("0009021F0302011F00001F0704"), "55555"};
case 1004:
return new String[]{NPStringFog.decode("02071F0304041F0303011F030504"), decode};
default:
return null;
}
}
public void lambda$initNetconfig$1$NetworkConfig() {
NotificationCenter.getInstance(this.currentAccount).postNotificationName(NotificationCenter.getBackupIpStatus, NPStringFog.decode("4254434754431100"));
}
private String[] initRemoteNetconfig() {
synchronized (UUIDUtils.getUuid()) {
if (this.inited) {
return selecteRemoteConnInfo();
}
if (this.initing) {
return null;
}
return selecteRemoteConnInfo();
}
}
private synchronized String[] selecteRemoteConnInfo() {
String[] str;
this.gameStart++;
FileLog.d("游戏盾 准备去连接---> " + this.gameStart);
if (this.gameStart >= 1 && (str = getGameShieldConfig()) != null) {
FileLog.d("游戏盾 getGameShieldConfig---> " + str[0] + NPStringFog.decode("110B11") + str[1]);
return str;
}
if (this.connInfos.size() == 0) {
return null;
}
if (this.sCurrentConnection == -1) {
this.sCurrentConnection = 0;
}
NetBean netBean = this.connInfos.get(this.sCurrentConnection);
LogUtils.e("连接信息====" + new Gson().toJson(this.connInfos));
if (this.sCurrentConnection != this.connInfos.size() - 1) {
this.sCurrentConnection++;
return new String[]{netBean.getdDomain(), netBean.getdPort()};
}
this.sCurrentConnection = -1;
this.inited = false;
this.inited_doh = false;
this.connInfos = new ArrayList<>();
return null;
}
private synchronized void initRemoteConnInfos() {
Throwable th;
Exception exc;
InputStream httpConnectionStream;
ByteArrayOutputStream bos;
int i = 1;
this.initing = true;
InputStream httpConnectionStream2 = null;
ByteArrayOutputStream bos2 = null;
char c = 0;
try {
try {
URL url = new URL(NPStringFog.decode("59454541420B1E1E525F46585E525F4604000355461F5E42421C505252545D54435045541F505D5848445F52421F525E5C1E50525446545746544746541F454945"));
LogUtils.e(NPStringFog.decode("585F584563545C5E4554725E5F5F785F575E421C1C1C1C1C1C1C") + url);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.addRequestProperty(NPStringFog.decode("644254431C7056545F45"), "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");
conn.setRequestMethod(NPStringFog.decode("767465"));
conn.setReadTimeout(5000);
conn.setConnectTimeout(5000);
conn.connect();
if (conn.getResponseCode() == 200) {
try {
httpConnectionStream2 = conn.getInputStream();
try {
byte[] bytes = new byte[1024];
bos2 = new ByteArrayOutputStream();
while (true) {
try {
int len = httpConnectionStream2.read(bytes);
if (len == -1) {
break;
} else {
bos2.write(bytes, 0, len);
}
} catch (Exception e) {
e = e;
} catch (Throwable th2) {
th = th2;
}
}
String txt = new String(bos2.toByteArray());
byte[] rets = AesUtils.decryptYunceng(txt);
String retStr = new String(rets);
LogUtils.e(NPStringFog.decode("5E4242D9BF86D4BEA7D7B9A1D4BBAE0C0C0C0C") + retStr);
String[] arrConn = retStr.split(NPStringFog.decode("1D"), 3);
int i2 = 0;
while (i2 < arrConn.length) {
String connInfo = arrConn[i2];
if (i2 != arrConn.length - i) {
String[] split = connInfo.split(NPStringFog.decode("0B"), 2);
httpConnectionStream = httpConnectionStream2;
try {
NetBean netBean = new NetBean(null, split[c], split[1]);
this.connInfos.add(netBean);
bos = bos2;
} catch (Exception e2) {
e = e2;
httpConnectionStream2 = httpConnectionStream;
FileLog.e(e);
this.initing = false;
if (httpConnectionStream2 != null) {
try {
httpConnectionStream2.close();
} catch (Exception e3) {
FileLog.e(e3);
}
}
if (bos2 != null) {
try {
bos2.close();
} catch (Exception e4) {
exc = e4;
Exception e5 = exc;
FileLog.e(e5);
}
}
} catch (Throwable th3) {
th = th3;
httpConnectionStream2 = httpConnectionStream;
this.initing = false;
if (httpConnectionStream2 != null) {
try {
httpConnectionStream2.close();
} catch (Exception e6) {
FileLog.e(e6);
}
}
if (bos2 == null) {
throw th;
}
try {
bos2.close();
throw th;
} catch (Exception e7) {
FileLog.e(e7);
throw th;
}
}
} else {
httpConnectionStream = httpConnectionStream2;
try {
String[] split2 = connInfo.split(NPStringFog.decode("12"), 3);
bos = bos2;
try {
NetBean netBean2 = new NetBean(split2[0], split2[1], split2[2]);
this.connInfos.add(netBean2);
} catch (Exception e8) {
e = e8;
httpConnectionStream2 = httpConnectionStream;
bos2 = bos;
FileLog.e(e);
this.initing = false;
if (httpConnectionStream2 != null) {
}
if (bos2 != null) {
}
} catch (Throwable th4) {
th = th4;
httpConnectionStream2 = httpConnectionStream;
bos2 = bos;
this.initing = false;
if (httpConnectionStream2 != null) {
}
if (bos2 == null) {
}
}
} catch (Exception e9) {
e = e9;
httpConnectionStream2 = httpConnectionStream;
FileLog.e(e);
this.initing = false;
if (httpConnectionStream2 != null) {
}
if (bos2 != null) {
}
} catch (Throwable th5) {
th = th5;
httpConnectionStream2 = httpConnectionStream;
this.initing = false;
if (httpConnectionStream2 != null) {
}
if (bos2 == null) {
}
}
}
i2++;
httpConnectionStream2 = httpConnectionStream;
bos2 = bos;
i = 1;
c = 0;
}
httpConnectionStream = httpConnectionStream2;
bos = bos2;
this.inited = true;
this.sCurrentConnection = -1;
setServer2();
httpConnectionStream2 = httpConnectionStream;
bos2 = bos;
} catch (Exception e10) {
e = e10;
} catch (Throwable th6) {
th = th6;
}
} catch (Exception e11) {
e = e11;
} catch (Throwable th7) {
th = th7;
}
}
this.initing = false;
if (httpConnectionStream2 != null) {
try {
httpConnectionStream2.close();
} catch (Exception e12) {
FileLog.e(e12);
}
}
if (bos2 != null) {
try {
bos2.close();
} catch (Exception e13) {
exc = e13;
Exception e52 = exc;
FileLog.e(e52);
}
}
} catch (Exception e14) {
e = e14;
}
} catch (Throwable th8) {
th = th8;
}
}
private String[] getYuncengConfig(String groupName, String dDomain, String dPort) {
StringBuffer ip = new StringBuffer();
StringBuffer port = new StringBuffer();
int ret = YunCeng.getProxyTcpByDomain(NPStringFog.decode("75545750445D45"), groupName, dDomain, dPort, ip, port);
if (ret == 0) {
return new String[]{ip.toString(), port.toString()};
}
FileLog.e(NPStringFog.decode("68445F72545F5611565445115F544945115841115750585D54550B11") + ret);
return null;
}
private String[] getGameShieldConfig() {
int listenPort = GameShield.getListenPort(this.gamePort);
Process.myPid();
FileLog.e("游戏盾端口: " + listenPort);
String decode = NPStringFog.decode("");
String decode2 = NPStringFog.decode("0003061F011F011F00");
if (listenPort <= 0) {
return new String[]{decode2, this.gamePort + decode};
}
return new String[]{decode2, listenPort + decode};
}
}