some renaming

This commit is contained in:
sirjonasxx 2021-04-27 22:08:08 +02:00
parent 1c4c7b03c0
commit 1c3193ec57
6 changed files with 30 additions and 37 deletions

View File

@ -137,7 +137,7 @@ public class HConnection {
}
public boolean sendToClientAsync(HPacket message) {
public boolean sendToClient(HPacket message) {
if (proxy == null) return false;
if (!message.isPacketComplete()) {
@ -147,10 +147,10 @@ public class HConnection {
if (!message.isPacketComplete()) return false;
}
proxy.getAsyncPacketSender().sendToClientAsync(message);
proxy.getPacketSenderQueue().queueToClient(message);
return true;
}
public boolean sendToServerAsync(HPacket message) {
public boolean sendToServer(HPacket message) {
if (proxy == null) return false;
if (!message.isPacketComplete()) {
@ -160,7 +160,7 @@ public class HConnection {
if (!message.isPacketComplete()) return false;
}
proxy.getAsyncPacketSender().sendToServerAsync(message);
proxy.getPacketSenderQueue().queueToServer(message);
return true;
}

View File

@ -25,7 +25,7 @@ public class HProxy {
private volatile String clientIdentifier = "";
private volatile PacketInfoManager packetInfoManager = null;
private volatile AsyncPacketSender asyncPacketSender = null;
private volatile PacketSenderQueue packetSenderQueue = null;
public HProxy(HClient hClient, String input_domain, String actual_domain, int actual_port, int intercept_port, String intercept_host) {
this.hClient = hClient;
@ -46,7 +46,7 @@ public class HProxy {
this.hotelVersion = hotelVersion;
this.clientIdentifier = clientIdentifier;
this.packetInfoManager = PacketInfoManager.fromHotelVersion(hotelVersion, hClient);
this.asyncPacketSender = new AsyncPacketSender(this);
this.packetSenderQueue = new PacketSenderQueue(this);
}
public String getClientIdentifier() {
@ -89,8 +89,8 @@ public class HProxy {
return hotelVersion;
}
public AsyncPacketSender getAsyncPacketSender() {
return asyncPacketSender;
public PacketSenderQueue getPacketSenderQueue() {
return packetSenderQueue;
}
public HClient gethClient() {

View File

@ -5,19 +5,19 @@ import gearth.protocol.HPacket;
import java.util.LinkedList;
import java.util.Queue;
public class AsyncPacketSender {
public class PacketSenderQueue {
private final HProxy proxy;
private final Queue<HPacket> sendToClientAsyncQueue = new LinkedList<>();
private final Queue<HPacket> sendToServerAsyncQueue = new LinkedList<>();
private final Queue<HPacket> sendToClientQueue = new LinkedList<>();
private final Queue<HPacket> sendToServerQueue = new LinkedList<>();
AsyncPacketSender(HProxy proxy) {
PacketSenderQueue(HProxy proxy) {
this.proxy = proxy;
new Thread(() -> {
while (true) {
HPacket packet;
synchronized (sendToClientAsyncQueue) {
while ((packet = sendToClientAsyncQueue.poll()) != null) {
synchronized (sendToClientQueue) {
while ((packet = sendToClientQueue.poll()) != null) {
sendToClient(packet);
}
}
@ -32,8 +32,8 @@ public class AsyncPacketSender {
new Thread(() -> {
while (true) {
HPacket packet;
synchronized (sendToServerAsyncQueue) {
while ((packet = sendToServerAsyncQueue.poll()) != null) {
synchronized (sendToServerQueue) {
while ((packet = sendToServerQueue.poll()) != null) {
sendToServer(packet);
}
}
@ -55,24 +55,24 @@ public class AsyncPacketSender {
proxy.getOutHandler().sendToStream(message.toBytes());
}
public void sendToClientAsync(HPacket message) {
synchronized (sendToClientAsyncQueue) {
sendToClientAsyncQueue.add(message);
public void queueToClient(HPacket message) {
synchronized (sendToClientQueue) {
sendToClientQueue.add(message);
}
}
public void sendToServerAsync(HPacket message) {
synchronized (sendToServerAsyncQueue) {
sendToServerAsyncQueue.add(message);
public void queueToServer(HPacket message) {
synchronized (sendToServerQueue) {
sendToServerQueue.add(message);
}
}
public void clear() {
synchronized (sendToClientAsyncQueue) {
sendToClientAsyncQueue.clear();
synchronized (sendToClientQueue) {
sendToClientQueue.clear();
}
synchronized (sendToServerAsyncQueue) {
sendToServerAsyncQueue.clear();
synchronized (sendToServerQueue) {
sendToServerQueue.clear();
}
}
}

View File

@ -191,10 +191,10 @@ public class ExtensionHandler {
@Override
public void sendMessage(HMessage.Direction direction, HPacket packet) {
if (direction == HMessage.Direction.TOCLIENT) {
hConnection.sendToClientAsync(packet);
hConnection.sendToClient(packet);
}
else {
hConnection.sendToServerAsync(packet);
hConnection.sendToServer(packet);
}
}

View File

@ -6,23 +6,18 @@ import gearth.protocol.HMessage;
import gearth.protocol.connection.HState;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.*;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.text.Text;
import gearth.protocol.HPacket;
import gearth.ui.SubForm;
import sun.misc.Cache;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
public class InjectionController extends SubForm {
@ -190,7 +185,7 @@ public class InjectionController extends SubForm {
public void sendToServer_clicked(ActionEvent actionEvent) {
HPacket[] packets = parsePackets(inputPacket.getText());
for (HPacket packet : packets) {
getHConnection().sendToServerAsync(packet);
getHConnection().sendToServer(packet);
writeToLog(Color.BLUE, "SS -> packet with id: " + packet.headerId());
}
@ -200,7 +195,7 @@ public class InjectionController extends SubForm {
public void sendToClient_clicked(ActionEvent actionEvent) {
HPacket[] packets = parsePackets(inputPacket.getText());
for (HPacket packet : packets) {
getHConnection().sendToClientAsync(packet);
getHConnection().sendToClient(packet);
writeToLog(Color.RED, "CS -> packet with id: " + packet.headerId());
}

View File

@ -115,7 +115,6 @@ public class SchedulerController extends SubForm {
scheduler.size(),
false,
new Interval(txt_delay.getText()),
new HPacket(txt_packet.getText()),
txt_packet.getText(),
rb_incoming.isSelected() ? HMessage.Direction.TOCLIENT : HMessage.Direction.TOSERVER);
@ -123,7 +122,6 @@ public class SchedulerController extends SubForm {
}
else {
isBeingEdited.getPacketProperty().set(new HPacket(txt_packet.getText()));
isBeingEdited.getPacketAsStringProperty().set(txt_packet.getText());
isBeingEdited.getDelayProperty().set(new Interval(txt_delay.getText()));
isBeingEdited.getDestinationProperty().set(rb_incoming.isSelected() ? HMessage.Direction.TOCLIENT : HMessage.Direction.TOSERVER);