小马软件库 v4.3版本的 MD5 值为:5bdc4b93cc4814bc786c18efbaeb25d1
以下内容为反编译后的 C0062.java 源代码,内容仅作参考
package i.app;
import android.content.Context;
import i.runlibrary.a.o;
import i.runlibrary.a.s;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class C0062 {
private List a;
private Context b;
private java.net.ServerSocket c;
private int d;
private int e;
private int f;
private String g;
private socketServer h;
private OnMessagesListener f257i;
private int j;
public boolean f114;
public String f115;
public interface OnMessagesListener {
void Accept(C0062 c0062, socketServer socketserver);
void Message(socketServer socketserver, int i2, String str, byte[] bArr);
}
public class socketServer {
private Socket b;
public Object f116 = null;
public Object[] f117 = null;
public socketServer(Socket socket) {
this.b = socket;
a();
}
private void a() {
new j(this).start();
}
public static void a(socketServer socketserver, InputStream inputStream, int i2, byte[] bArr) {
int i3;
int i4 = i2;
while (true) {
if (i4 < 32 || !i.runlibrary.a.f.c(bArr)) {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byteArrayOutputStream.write(bArr, 0, i4);
boolean z = false;
while (true) {
if (socketserver.b.isClosed() || inputStream.available() <= 0) {
break;
}
i4 = inputStream.read(bArr);
if (i4 > 0) {
if (i4 >= 32 && i.runlibrary.a.f.c(bArr)) {
z = true;
break;
}
byteArrayOutputStream.write(bArr, 0, i4);
}
}
C0062.this.f257i.Message(socketserver, 0, null, byteArrayOutputStream.toByteArray());
byteArrayOutputStream.close();
if (!z) {
return;
}
} else {
byte b = bArr[6];
int a = i.runlibrary.a.f.a(bArr);
String b2 = b == 2 ? i.runlibrary.a.f.b(bArr) : null;
if (a <= 0) {
return;
}
ByteArrayOutputStream byteArrayOutputStream2 = new ByteArrayOutputStream();
if (i4 > 32) {
i3 = i4 - 32;
if (i3 <= a) {
byteArrayOutputStream2.write(bArr, 32, i3);
if (a > i3) {
a -= i3;
}
} else {
byteArrayOutputStream2.write(bArr, 32, a);
}
if (a <= i3) {
byte[] byteArray = byteArrayOutputStream2.toByteArray();
OnMessagesListener onMessagesListener = C0062.this.f257i;
if (b == 1) {
b2 = new String(byteArray, C0062.this.f115);
}
onMessagesListener.Message(socketserver, b, b2, byteArray);
byteArrayOutputStream2.close();
if (i3 <= a) {
return;
}
byte[] bArr2 = new byte[i3 - a];
int i5 = 0;
for (int i6 = a + 32; i6 < i4; i6++) {
bArr2[i5] = bArr[i6];
i5++;
}
i4 = bArr2.length;
bArr = bArr2;
}
} else {
i3 = i4;
}
while (true) {
if (socketserver.b.isClosed()) {
break;
}
i3 = inputStream.read(bArr);
if (i3 > 0) {
if (i3 > a) {
byteArrayOutputStream2.write(bArr, 0, a);
break;
}
byteArrayOutputStream2.write(bArr, 0, i3);
if (a == i3) {
break;
} else {
a -= i3;
}
}
}
if (a > i3) {
return;
}
byte[] byteArray2 = byteArrayOutputStream2.toByteArray();
OnMessagesListener onMessagesListener2 = C0062.this.f257i;
if (b == 1) {
b2 = new String(byteArray2, C0062.this.f115);
}
onMessagesListener2.Message(socketserver, b, b2, byteArray2);
byteArrayOutputStream2.close();
if (i3 <= a) {
return;
}
byte[] bArr3 = new byte[i3 - a];
int i7 = 0;
while (a < i3) {
bArr3[i7] = bArr[a];
i7++;
a++;
}
bArr = bArr3;
i4 = bArr3.length;
}
}
}
public String ip() {
return this.b.getInetAddress().getHostAddress();
}
public void m97() {
if (this.b.isClosed()) {
return;
}
C0062.this.a.remove(this);
try {
this.b.close();
} catch (IOException e) {
e.printStackTrace();
}
}
public Object m98() {
return this.f116;
}
public void m99(Object obj) {
this.f116 = obj;
}
public void m100(Object obj) {
this.f117 = s.c(obj);
}
public Object[] m101() {
return this.f117;
}
public boolean m102() {
return this.b.isClosed();
}
public String m103ip() {
return this.b.getLocalAddress().getHostAddress();
}
public int m104() {
return this.b.getLocalPort();
}
public int m105() {
return this.b.getPort();
}
public boolean m106(Object obj) {
return C0062.this.a(this, obj);
}
public boolean m107(Object obj, Object obj2) {
return C0062.this.a(this, obj, obj2);
}
public Socket m108() {
return this.b;
}
public boolean m109() {
try {
if (this.b.isClosed()) {
if (C0062.this.e > 0) {
this.b.connect(this.b.getRemoteSocketAddress(), C0062.this.e);
} else {
this.b.connect(this.b.getRemoteSocketAddress());
}
if (!this.b.isClosed()) {
if (!C0062.this.a.contains(this)) {
C0062.this.a.add(this);
}
a();
}
return true;
}
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
}
public C0062(Context context, int i2, int i3, int i4, boolean z, OnMessagesListener onMessagesListener) {
this.a = new ArrayList();
this.c = null;
this.f114 = true;
this.d = 0;
this.e = 0;
this.f115 = "utf-8";
this.h = null;
this.f257i = null;
this.j = 0;
this.j = 1;
this.b = context;
try {
this.c = new java.net.ServerSocket(i2);
} catch (IOException e) {
e.printStackTrace();
}
if (i3 > 0) {
try {
this.c.setSoTimeout(i3);
} catch (SocketException e2) {
e2.printStackTrace();
}
}
this.f = i2;
this.d = i3;
this.e = i4;
this.f114 = z;
this.f257i = onMessagesListener;
}
public C0062(Context context, String str, int i2, int i3, OnMessagesListener onMessagesListener) {
this.a = new ArrayList();
this.c = null;
this.f114 = true;
this.d = 0;
this.e = 0;
this.f115 = "utf-8";
this.h = null;
this.f257i = null;
this.j = 0;
this.j = 2;
this.b = context;
this.g = str;
this.f = i2;
this.e = i3;
this.f257i = onMessagesListener;
}
public boolean a(socketServer socketserver, Object obj) {
byte[] bytes = o.toBytes(obj, this.f115, null);
if (bytes != null) {
return a(socketserver.b, bytes);
}
return false;
}
public boolean a(socketServer socketserver, Object obj, Object obj2) {
Object obj3;
File file;
int d = s.d(obj);
if (d == 2) {
file = obj2 instanceof File ? (File) obj2 : new File(i.runlibrary.a.d.a(this.b, obj2.toString()));
if (!file.exists() || !file.isFile()) {
return false;
}
obj3 = file;
} else {
obj3 = obj2;
file = null;
}
byte[] bytes = o.toBytes(obj3, this.f115, null);
if (bytes != null) {
return a(socketserver.b, i.runlibrary.a.f.a(bytes, d, file)) && a(socketserver.b, bytes);
}
return false;
}
private static boolean a(Socket socket, byte[] bArr) {
try {
socket.getOutputStream().write(bArr);
socket.getOutputStream().flush();
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
public void m84() {
this.f114 = false;
Iterator it = this.a.iterator();
while (it.hasNext()) {
try {
((socketServer) it.next()).m97();
} catch (Exception e) {
e.printStackTrace();
}
}
this.a.clear();
if (this.c == null || this.c.isClosed()) {
return;
}
try {
this.c.close();
} catch (IOException e2) {
e2.printStackTrace();
}
}
public void m85() {
if (this.j != 1) {
if (this.j == 2) {
try {
Socket socket = new Socket();
socket.connect(new InetSocketAddress(this.g, this.f), 10000);
if (this.e != 0) {
socket.setSoTimeout(this.e);
}
this.h = new socketServer(socket);
this.a.add(this.h);
return;
} catch (IOException e) {
e.printStackTrace();
return;
}
}
return;
}
while (!this.c.isClosed()) {
try {
Socket accept = this.c.accept();
if (this.f114) {
if (this.e > 0) {
accept.setSoTimeout(this.e);
}
socketServer socketserver = new socketServer(accept);
this.a.add(socketserver);
this.f257i.Accept(this, socketserver);
} else {
accept.close();
}
} catch (SocketTimeoutException e2) {
e2.printStackTrace();
} catch (IOException e3) {
e3.printStackTrace();
}
}
try {
this.c.close();
} catch (IOException e4) {
e4.printStackTrace();
}
}
public boolean m86() {
if (this.c != null) {
return this.c.isClosed();
}
if (this.h != null) {
return this.h.m102();
}
return true;
}
public java.net.ServerSocket m87() {
return this.c;
}
public String m88ip() {
if (this.c != null) {
return "127.0.0.1";
}
if (this.h != null) {
return this.h.b.getLocalAddress().getHostAddress();
}
return null;
}
public int m89() {
if (this.c != null) {
return this.c.getLocalPort();
}
if (this.h != null) {
return this.h.b.getLocalPort();
}
return -1;
}
public int m90(Object obj) {
int i2 = 0;
Iterator it = this.a.iterator();
while (true) {
int i3 = i2;
if (!it.hasNext()) {
return i3;
}
socketServer socketserver = (socketServer) it.next();
if (!socketserver.m102() && a(socketserver, obj)) {
i3++;
}
i2 = i3;
}
}
public int m91(Object obj, Object obj2) {
int i2 = 0;
Iterator it = this.a.iterator();
while (true) {
int i3 = i2;
if (!it.hasNext()) {
return i3;
}
socketServer socketserver = (socketServer) it.next();
if (!socketserver.m102() && a(socketserver, obj, obj2)) {
i3++;
}
i2 = i3;
}
}
public socketServer m92(Object obj) {
int d = s.d(obj);
if (d < 0 || this.a.size() <= d) {
return null;
}
return (socketServer) this.a.get(d);
}
public List m93() {
return this.a;
}
public int m94() {
return this.a.size();
}
public void m95() {
if (this.c != null) {
Iterator it = this.a.iterator();
while (it.hasNext()) {
try {
((socketServer) it.next()).m97();
} catch (Exception e) {
e.printStackTrace();
}
}
this.a.clear();
}
}
public void m96() {
if (this.j != 1) {
if (this.j == 2 && this.h.m102()) {
m85();
return;
}
return;
}
if (this.c.isClosed()) {
try {
this.c = new java.net.ServerSocket(this.f);
} catch (IOException e) {
e.printStackTrace();
}
if (this.d > 0) {
try {
this.c.setSoTimeout(this.d);
} catch (SocketException e2) {
e2.printStackTrace();
}
}
m85();
}
}
}