mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2025-01-19 08:36:27 +01:00
now works properly for hotels that disable encryption
This commit is contained in:
parent
1b71b97501
commit
1e704ccf3c
@ -43,7 +43,7 @@ public abstract class ProxyProvider {
|
|||||||
Rc4Obtainer rc4Obtainer = new Rc4Obtainer(hConnection);
|
Rc4Obtainer rc4Obtainer = new Rc4Obtainer(hConnection);
|
||||||
|
|
||||||
OutgoingPacketHandler outgoingHandler = new OutgoingPacketHandler(server.getOutputStream(), hConnection.getTrafficObservables());
|
OutgoingPacketHandler outgoingHandler = new OutgoingPacketHandler(server.getOutputStream(), hConnection.getTrafficObservables());
|
||||||
IncomingPacketHandler incomingHandler = new IncomingPacketHandler(client.getOutputStream(), hConnection.getTrafficObservables());
|
IncomingPacketHandler incomingHandler = new IncomingPacketHandler(client.getOutputStream(), hConnection.getTrafficObservables(), outgoingHandler);
|
||||||
rc4Obtainer.setPacketHandlers(outgoingHandler, incomingHandler);
|
rc4Obtainer.setPacketHandlers(outgoingHandler, incomingHandler);
|
||||||
|
|
||||||
Semaphore abort = new Semaphore(0);
|
Semaphore abort = new Semaphore(0);
|
||||||
|
@ -11,17 +11,18 @@ import java.util.List;
|
|||||||
|
|
||||||
public class IncomingPacketHandler extends PacketHandler {
|
public class IncomingPacketHandler extends PacketHandler {
|
||||||
|
|
||||||
public IncomingPacketHandler(OutputStream outputStream, Object[] trafficObservables) {
|
public IncomingPacketHandler(OutputStream outputStream, Object[] trafficObservables, OutgoingPacketHandler outgoingHandler) {
|
||||||
super(outputStream, trafficObservables);
|
super(outputStream, trafficObservables);
|
||||||
|
|
||||||
TrafficListener listener = new TrafficListener() {
|
TrafficListener listener = new TrafficListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onCapture(HMessage message) {
|
public void onCapture(HMessage message) {
|
||||||
if (isDataStream && message.getPacket().structureEquals("s,b")) {
|
if (isDataStream && message.getPacket().structureEquals("s,b") && message.getPacket().length() > 500) {
|
||||||
((Observable<TrafficListener>)trafficObservables[0]).removeListener(this);
|
((Observable<TrafficListener>)trafficObservables[0]).removeListener(this);
|
||||||
HPacket packet = message.getPacket();
|
HPacket packet = message.getPacket();
|
||||||
packet.readString();
|
packet.readString();
|
||||||
isEncryptedStream = packet.readBoolean();
|
isEncryptedStream = packet.readBoolean();
|
||||||
|
outgoingHandler.isEncryptedStream = true;
|
||||||
}
|
}
|
||||||
else if (message.getIndex() > 3) {
|
else if (message.getIndex() > 3) {
|
||||||
((Observable<TrafficListener>)trafficObservables[0]).removeListener(this);
|
((Observable<TrafficListener>)trafficObservables[0]).removeListener(this);
|
||||||
@ -32,16 +33,6 @@ public class IncomingPacketHandler extends PacketHandler {
|
|||||||
((Observable<TrafficListener>)trafficObservables[0]).addListener(listener);
|
((Observable<TrafficListener>)trafficObservables[0]).addListener(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void act(byte[] buffer) throws IOException {
|
|
||||||
if (isDataStream) {
|
|
||||||
continuedAct(buffer);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
out.write(buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HMessage.Direction getMessageSide() {
|
public HMessage.Direction getMessageSide() {
|
||||||
return HMessage.Direction.TOCLIENT;
|
return HMessage.Direction.TOCLIENT;
|
||||||
|
@ -38,17 +38,7 @@ public class OutgoingPacketHandler extends PacketHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void act(byte[] buffer) throws IOException {
|
public void act(byte[] buffer) throws IOException {
|
||||||
dataStreamCheck(buffer);
|
dataStreamCheck(buffer);
|
||||||
|
super.act(buffer);
|
||||||
if (isDataStream) {
|
|
||||||
if (!isEncryptedStream && (new HPacket(buffer).length() < 2 || new HPacket(buffer).length() > 1000)) {
|
|
||||||
isEncryptedStream = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
continuedAct(buffer);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
out.write(buffer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -16,23 +16,23 @@ public abstract class PacketHandler {
|
|||||||
|
|
||||||
protected static final boolean DEBUG = false;
|
protected static final boolean DEBUG = false;
|
||||||
|
|
||||||
volatile PayloadBuffer payloadBuffer = new PayloadBuffer();
|
private volatile PayloadBuffer payloadBuffer = new PayloadBuffer();
|
||||||
volatile OutputStream out;
|
private volatile OutputStream out;
|
||||||
volatile Object[] trafficObservables; //get notified on packet send
|
private volatile Object[] trafficObservables; //get notified on packet send
|
||||||
volatile boolean isTempBlocked = false;
|
private volatile boolean isTempBlocked = false;
|
||||||
volatile boolean isDataStream = false;
|
volatile boolean isDataStream = false;
|
||||||
volatile int currentIndex = 0;
|
private volatile int currentIndex = 0;
|
||||||
|
|
||||||
protected final Object lock = new Object();
|
private final Object lock = new Object();
|
||||||
|
|
||||||
protected RC4 decryptcipher = null;
|
private RC4 decryptcipher = null;
|
||||||
protected RC4 encryptcipher = null;
|
private RC4 encryptcipher = null;
|
||||||
|
|
||||||
protected volatile List<Byte> tempEncryptedBuffer = new ArrayList<>();
|
private volatile List<Byte> tempEncryptedBuffer = new ArrayList<>();
|
||||||
protected volatile boolean isEncryptedStream = false;
|
volatile boolean isEncryptedStream = false;
|
||||||
|
|
||||||
|
|
||||||
public PacketHandler(OutputStream outputStream, Object[] trafficObservables) {
|
PacketHandler(OutputStream outputStream, Object[] trafficObservables) {
|
||||||
this.trafficObservables = trafficObservables;
|
this.trafficObservables = trafficObservables;
|
||||||
out = outputStream;
|
out = outputStream;
|
||||||
}
|
}
|
||||||
@ -46,8 +46,12 @@ public abstract class PacketHandler {
|
|||||||
return isEncryptedStream;
|
return isEncryptedStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void act(byte[] buffer) throws IOException;
|
public void act(byte[] buffer) throws IOException {
|
||||||
protected void continuedAct(byte[] buffer) throws IOException {
|
if (!isDataStream) {
|
||||||
|
out.write(buffer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bufferChangeObservable.fireEvent();
|
bufferChangeObservable.fireEvent();
|
||||||
|
|
||||||
if (!isEncryptedStream) {
|
if (!isEncryptedStream) {
|
||||||
|
Loading…
Reference in New Issue
Block a user