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

View File

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

View File

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

View File

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

View File

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

View File

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