正在查看: 95爱播免登录版 v3.1.9 应用的 LDNetSocket.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 95爱播免登录版 v3.1.9 应用的 LDNetSocket.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.netease.LDNetDiagnoService;
import java.io.IOException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketTimeoutException;
import java.util.List;
public class LDNetSocket {
private static final int CONN_TIMES = 4;
private static final String HOSTERR = "DNS解析失败,主机地址不可达";
private static final String IOERR = "DNS解析正常,IO异常,TCP建立失败";
private static final int PORT = 80;
private static final String TIMEOUT = "DNS解析正常,连接超时,TCP建立失败";
private static LDNetSocket instance;
static boolean loaded;
public InetAddress[] _remoteInet;
public List<String> _remoteIpList;
private boolean[] isConnnected;
private LDNetSocketListener listener;
private int timeOut = 6000;
private final long[] RttTimes = new long[4];
public boolean isCConn = true;
public interface LDNetSocketListener {
void OnNetSocketFinished(String str);
void OnNetSocketUpdated(String str);
}
static {
try {
System.loadLibrary("tracepath");
loaded = true;
} catch (Exception e2) {
e2.printStackTrace();
} catch (UnsatisfiedLinkError e3) {
e3.printStackTrace();
}
}
private LDNetSocket() {
}
private boolean execIP(InetAddress inetAddress, String str) {
char c;
StringBuilder sb = new StringBuilder();
boolean z = false;
z = false;
z = false;
z = false;
if (inetAddress != null && str != null) {
InetSocketAddress inetSocketAddress = new InetSocketAddress(inetAddress, 80);
this.listener.OnNetSocketUpdated("Connect to host: " + str + "...\n");
int i2 = 0;
while (true) {
if (i2 >= 4) {
c = 0;
break;
}
execSocket(inetSocketAddress, this.timeOut, i2);
long[] jArr = this.RttTimes;
if (jArr[i2] == -1) {
this.listener.OnNetSocketUpdated((i2 + 1) + "'s time=TimeOut, ");
this.timeOut = this.timeOut + 4000;
if (i2 > 0 && this.RttTimes[i2 - 1] == -1) {
c = 65535;
break;
}
i2++;
} else {
if (jArr[i2] == -2) {
this.listener.OnNetSocketUpdated((i2 + 1) + "'s time=IOException");
if (i2 > 0 && this.RttTimes[i2 - 1] == -2) {
c = 65534;
break;
}
} else {
this.listener.OnNetSocketUpdated((i2 + 1) + "'s time=" + this.RttTimes[i2] + "ms, ");
}
i2++;
}
}
if (c != 65535 && c != 65534) {
long j2 = 0;
int i3 = 0;
for (int i4 = 0; i4 < 4; i4++) {
long[] jArr2 = this.RttTimes;
if (jArr2[i4] > 0) {
j2 += jArr2[i4];
i3++;
}
}
if (i3 > 0) {
sb.append("average=" + (j2 / i3) + "ms");
}
z = true;
}
}
this.listener.OnNetSocketUpdated(sb.toString());
return z;
}
private void execSocket(InetSocketAddress inetSocketAddress, int i2, int i3) {
Socket socket;
Socket socket2 = null;
Socket socket3 = null;
Socket socket4 = null;
socket2 = null;
try {
try {
try {
socket = new Socket();
} catch (Throwable th) {
th = th;
}
} catch (SocketTimeoutException e2) {
e = e2;
} catch (IOException e3) {
e = e3;
}
} catch (IOException e4) {
e4.printStackTrace();
socket2 = socket2;
}
try {
long currentTimeMillis = System.currentTimeMillis();
socket.connect(inetSocketAddress, i2);
long currentTimeMillis2 = System.currentTimeMillis();
long[] jArr = this.RttTimes;
jArr[i3] = currentTimeMillis2 - currentTimeMillis;
socket.close();
socket2 = jArr;
} catch (SocketTimeoutException e5) {
e = e5;
socket3 = socket;
this.RttTimes[i3] = -1;
e.printStackTrace();
socket2 = socket3;
if (socket3 != null) {
socket3.close();
socket2 = socket3;
}
} catch (IOException e6) {
e = e6;
socket4 = socket;
this.RttTimes[i3] = -2;
e.printStackTrace();
socket2 = socket4;
if (socket4 != null) {
socket4.close();
socket2 = socket4;
}
} catch (Throwable th2) {
th = th2;
socket2 = socket;
if (socket2 != null) {
try {
socket2.close();
} catch (IOException e7) {
e7.printStackTrace();
}
}
throw th;
}
}
private boolean execUseJava(String str) {
InetAddress[] inetAddressArr = this._remoteInet;
if (inetAddressArr == null || this._remoteIpList == null) {
this.listener.OnNetSocketFinished(HOSTERR);
} else {
int length = inetAddressArr.length;
this.isConnnected = new boolean[length];
for (int i2 = 0; i2 < length; i2++) {
if (i2 != 0) {
this.listener.OnNetSocketUpdated("\n");
}
this.isConnnected[i2] = execIP(this._remoteInet[i2], this._remoteIpList.get(i2));
}
for (boolean z : this.isConnnected) {
if (Boolean.valueOf(z).booleanValue()) {
this.listener.OnNetSocketFinished("\n");
return true;
}
}
}
this.listener.OnNetSocketFinished("\n");
return false;
}
public static LDNetSocket getInstance() {
if (instance == null) {
instance = new LDNetSocket();
}
return instance;
}
public boolean exec(String str) {
if (!this.isCConn || !loaded) {
return execUseJava(str);
}
try {
startJNITelnet(str, "80");
return true;
} catch (UnsatisfiedLinkError e2) {
e2.printStackTrace();
return execUseJava(str);
}
}
public void initListener(LDNetSocketListener lDNetSocketListener) {
this.listener = lDNetSocketListener;
}
public void printSocketInfo(String str) {
this.listener.OnNetSocketUpdated(str);
}
public void resetInstance() {
if (instance != null) {
instance = null;
}
}
public native void startJNITelnet(String str, String str2);
}