Solved bug with text encoding and changed default host to 0.0.0.0

This commit is contained in:
Carlos 2020-05-30 13:49:13 +02:00
parent 2643999e8d
commit d1b158a0fe
18 changed files with 240 additions and 214 deletions

View File

@ -248,7 +248,7 @@
<!-- Webpage footer --> <!-- Webpage footer -->
<footer class="footer mt-auto py-3"> <footer class="footer mt-auto py-3">
<div class="container"> <div class="container">
<span class="text-muted">WebConsole v1.5 (rev. 4) - <a href="https://github.com/mesacarlos/WebConsole">GitHub</a></span> <span class="text-muted">WebConsole v1.6 - <a href="https://github.com/mesacarlos/WebConsole">GitHub</a></span>
</div> </div>
</footer> </footer>
@ -258,15 +258,15 @@
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<!-- WebConsole JS Objects --> <!-- WebConsole JS Objects -->
<script src="scripts/object/Setting.js?v=1.5.4"></script> <script src="scripts/object/Setting.js?v=1.6"></script>
<script src="scripts/object/WSServer.js?v=1.5.4"></script> <script src="scripts/object/WSServer.js?v=1.6"></script>
<!-- WebConsole JS Scripts --> <!-- WebConsole JS Scripts -->
<script src="scripts/WebConsoleLanguage.js?v=1.5.4"></script> <script src="scripts/WebConsoleLanguage.js?v=1.6"></script>
<script src="scripts/WebConsoleConnector.js?v=1.5.4"></script> <script src="scripts/WebConsoleConnector.js?v=1.6"></script>
<script src="scripts/WebConsoleManager.js?v=1.5.4"></script> <script src="scripts/WebConsoleManager.js?v=1.6"></script>
<script src="scripts/WebConsolePersistenceManager.js?v=1.5.4"></script> <script src="scripts/WebConsolePersistenceManager.js?v=1.6"></script>
<script src="scripts/WebConsole.js?v=1.5.4"></script> <script src="scripts/WebConsole.js?v=1.6"></script>
<script src="scripts/WebConsoleJqueryHandler.js?v=1.5.4"></script> <script src="scripts/WebConsoleJqueryHandler.js?v=1.6"></script>
</body> </body>
</html> </html>

View File

@ -13,6 +13,7 @@ forbidden-console = [WebConsole] {0} tried to run "{1}" while not logged in!
closed-connection = [WebConsole] Closed connection and logged out from {0} closed-connection = [WebConsole] Closed connection and logged out from {0}
error-on-connection = [WebConsole] Error occurred on connection {0}: {1} error-on-connection = [WebConsole] Error occurred on connection {0}: {1}
started-websocket = [WebConsole] WebSocket Server started successfully. started-websocket = [WebConsole] WebSocket Server started successfully.
error-disconnected-client = [WebConsole] Attempted to send a message to a disconnected client.
# CpuUsageCommand.java # CpuUsageCommand.java
cpu-usage-message = Usage is {0}% cpu-usage-message = Usage is {0}%

View File

@ -13,6 +13,7 @@ forbidden-console = [WebConsole] {0} se pokusil spustit "{1}" nepřihlášený!
closed-connection = [WebConsole] Ukončeno připojení a odhlášeno z {0}! closed-connection = [WebConsole] Ukončeno připojení a odhlášeno z {0}!
error-on-connection = [WebConsole] Nastala chyba u připojení {0}: {1} error-on-connection = [WebConsole] Nastala chyba u připojení {0}: {1}
started-websocket = [WebConsole] Websocketový server se úspěšně spustil. started-websocket = [WebConsole] Websocketový server se úspěšně spustil.
error-disconnected-client = [WebConsole] Pokus o odeslání zprávy odpojenému klientovi.
# CpuUsageCommand.java # CpuUsageCommand.java
cpu-usage-message = Využití je {0}% cpu-usage-message = Využití je {0}%

View File

@ -13,6 +13,7 @@ forbidden-console = [WebConsole] {0} hat versucht "{1}" auszuführen, ohne einge
closed-connection = [WebConsole] {0} hat seine Verbindung geschlossen und hat sich ausgeloggt. closed-connection = [WebConsole] {0} hat seine Verbindung geschlossen und hat sich ausgeloggt.
error-on-connection = [WebConsole] Fehler beim verbinden von {0}: {1}. error-on-connection = [WebConsole] Fehler beim verbinden von {0}: {1}.
started-websocket = [WebConsole] WebSocket Server wurde erfolgreich gestartet. started-websocket = [WebConsole] WebSocket Server wurde erfolgreich gestartet.
error-disconnected-client = [WebConsole] Es wurde versucht, eine Nachricht an einen nicht verbundenen Client zu senden.
# CpuUsageCommand.java # CpuUsageCommand.java
cpu-usage-message = Die CPU Auslastung liegt bei {0}%. cpu-usage-message = Die CPU Auslastung liegt bei {0}%.

View File

@ -13,6 +13,7 @@ forbidden-console = [WebConsole] {0} tried to run "{1}" while not logged in!
closed-connection = [WebConsole] Closed connection and logged out from {0} closed-connection = [WebConsole] Closed connection and logged out from {0}
error-on-connection = [WebConsole] Error occurred on connection {0}: {1} error-on-connection = [WebConsole] Error occurred on connection {0}: {1}
started-websocket = [WebConsole] WebSocket Server started successfully. started-websocket = [WebConsole] WebSocket Server started successfully.
error-disconnected-client = [WebConsole] Attempted to send a message to a disconnected WebSocket client.
# CpuUsageCommand.java # CpuUsageCommand.java
cpu-usage-message = Usage is {0}% cpu-usage-message = Usage is {0}%

View File

@ -13,6 +13,7 @@ forbidden-console = [WebConsole] {0} intento ejecutar "{1}" sin tener una sesió
closed-connection = [WebConsole] Sesión cerrada y desconectado desde {0} closed-connection = [WebConsole] Sesión cerrada y desconectado desde {0}
error-on-connection = [WebConsole] Ocurrió un error en la conexión con {0}: {1} error-on-connection = [WebConsole] Ocurrió un error en la conexión con {0}: {1}
started-websocket = [WebConsole] Servidor WebSocket iniciado con éxito. started-websocket = [WebConsole] Servidor WebSocket iniciado con éxito.
error-disconnected-client = [WebConsole] Se intentó enviar un mensaje a un cliente WebSocket que estaba desconectado.
# CpuUsageCommand.java # CpuUsageCommand.java
cpu-usage-message = En uso {0}% cpu-usage-message = En uso {0}%

View File

@ -13,6 +13,7 @@ forbidden-console = [WebConsole] {0} a tenté d'exécuter "{1}" alors qu'il n'é
closed-connection = [WebConsole] Connexion fermée et déconnecté de {0} closed-connection = [WebConsole] Connexion fermée et déconnecté de {0}
error-on-connection = [WebConsole] Une erreur s'est produite lors de la connexion {0}: {1} error-on-connection = [WebConsole] Une erreur s'est produite lors de la connexion {0}: {1}
started-websocket = [WebConsole] WebSocket Server a démarré avec succès. started-websocket = [WebConsole] WebSocket Server a démarré avec succès.
error-disconnected-client = [WebConsole] Vous avez tenté d'envoyer un message à un client WebSocket déconnecté.
# CpuUsageCommand.java # CpuUsageCommand.java
cpu-usage-message = L'utilisation est {0}% cpu-usage-message = L'utilisation est {0}%

View File

@ -13,6 +13,7 @@ forbidden-console = [WebConsole] {0} ha tentato di avviare "{1}" mentre non avev
closed-connection = [WebConsole] Connessione chiusa e disconnessione da {0} closed-connection = [WebConsole] Connessione chiusa e disconnessione da {0}
error-on-connection = [WebConsole] Si è verificato un errore sulla connessione {0}: {1} error-on-connection = [WebConsole] Si è verificato un errore sulla connessione {0}: {1}
started-websocket = [WebConsole] WebSocket Server avviato correttamente. started-websocket = [WebConsole] WebSocket Server avviato correttamente.
error-disconnected-client = [WebConsole] Tentativo di inviare un messaggio a un client WebSocket disconnesso.
# CpuUsageCommand.java # CpuUsageCommand.java
cpu-usage-message = L''uso è {0}% cpu-usage-message = L''uso è {0}%

View File

@ -13,6 +13,7 @@ forbidden-console = [WebConsole] {0} probeerde "{1}" uit te voeren zonder ingelo
closed-connection = [WebConsole] Verbinding verbroken en uitgelogd van {0} closed-connection = [WebConsole] Verbinding verbroken en uitgelogd van {0}
error-on-connection = [WebConsole] Er is een fout opgetreden bij het verbinden van {0}: {1} error-on-connection = [WebConsole] Er is een fout opgetreden bij het verbinden van {0}: {1}
started-websocket = [WebConsole] De WebSocket Server is succesvol gestart. started-websocket = [WebConsole] De WebSocket Server is succesvol gestart.
error-disconnected-client = [WebConsole] Poging om een bericht te sturen naar een niet-verbonden WebSocket-client.
# CpuUsageCommand.java # CpuUsageCommand.java
cpu-usage-message = Verbruik is {0}% cpu-usage-message = Verbruik is {0}%

View File

@ -13,6 +13,7 @@ forbidden-console = [WebConsole] {0} tentou executar "{1}" mas não está autên
closed-connection = [WebConsole] {0} foi desconectado. closed-connection = [WebConsole] {0} foi desconectado.
error-on-connection = [WebConsole] Houve um erro na conexão de {0}: {1} error-on-connection = [WebConsole] Houve um erro na conexão de {0}: {1}
started-websocket = [WebConsole] WebSocket Server foi iniciado com sucesso. started-websocket = [WebConsole] WebSocket Server foi iniciado com sucesso.
error-disconnected-client = [WebConsole] Tentativa de enviar uma mensagem para um cliente WebSocket desconectado..
# CpuUsageCommand.java # CpuUsageCommand.java
cpu-usage-message = Consumindo {0}% cpu-usage-message = Consumindo {0}%

View File

@ -13,6 +13,7 @@ forbidden-console = [WebConsole] {0} попытался запустить "{1}"
closed-connection = [WebConsole] Соединение закрытое и выход из {0} closed-connection = [WebConsole] Соединение закрытое и выход из {0}
error-on-connection = [WebConsole] Произошла ошибка при подключении к {0}: {1} error-on-connection = [WebConsole] Произошла ошибка при подключении к {0}: {1}
started-websocket = [WebConsole] WebSocket Server успешно запущен. started-websocket = [WebConsole] WebSocket Server успешно запущен.
error-disconnected-client = [WebConsole] Попытка отправить сообщение отключенному клиенту WebSocket.
# CpuUsageCommand.java # CpuUsageCommand.java
cpu-usage-message = Использование {0}% cpu-usage-message = Использование {0}%

View File

@ -13,6 +13,7 @@ forbidden-console = [網站控制台] {0} 嘗試在未登錄的情況下運行 '
closed-connection = [網站控制台] 關閉連接並註銷 {0} closed-connection = [網站控制台] 關閉連接並註銷 {0}
error-on-connection = [網站控制台] 連接時出錯 {0}: {1} error-on-connection = [網站控制台] 連接時出錯 {0}: {1}
started-websocket = [網站控制台] 網站控制台 伺服器成功啟動。 started-websocket = [網站控制台] 網站控制台 伺服器成功啟動。
error-disconnected-client = [WebConsole] 尝试向断开连接的WebSocket客户端发送消息。
# CpuUsageCommand.java # CpuUsageCommand.java
cpu-usage-message = 已使用 {0}% cpu-usage-message = 已使用 {0}%

View File

@ -1,7 +1,7 @@
name: WebConsole name: WebConsole
main: es.mesacarlos.webconsole.WebConsole main: es.mesacarlos.webconsole.WebConsole
api-version: 1.13 api-version: 1.13
version: 1.5 version: 1.6
description: WebSockets-based web console description: WebSockets-based web console
author: Carlos Mesa author: Carlos Mesa
commands: commands:

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>WebConsole</groupId> <groupId>WebConsole</groupId>
<artifactId>WebConsole</artifactId> <artifactId>WebConsole</artifactId>
<version>1.5</version> <version>1.6</version>
<build> <build>
<sourceDirectory>src</sourceDirectory> <sourceDirectory>src</sourceDirectory>
<plugins> <plugins>

View File

@ -74,7 +74,7 @@ public class WebConsole extends JavaPlugin {
config.addDefault("KeyPassword", "keypassword"); config.addDefault("KeyPassword", "keypassword");
// Connection config variables // Connection config variables
config.addDefault("host", "localhost"); config.addDefault("host", "0.0.0.0");
config.addDefault("port", 8080); config.addDefault("port", 8080);
config.addDefault("password", 1234); config.addDefault("password", 1234);

View File

@ -49,4 +49,19 @@ public class Internationalization {
return msg; return msg;
} }
/**
* getPhrase() method expects all params to be ISO-8859-1.
* This method will be used when a UTF-8 String is given and you need to use it as a parameter for the above mentioned function.
*
* @return The same String encoded ISO-8859-1
*/
public static String utf8ToIso(String msg) {
try {
msg = new String(msg.getBytes("UTF-8"), "ISO-8859-1");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return msg;
}
} }

View File

@ -111,7 +111,7 @@ public class WSServer extends WebSocketServer {
try { try {
conn.send(content.toJSON()); conn.send(content.toJSON());
}catch(WebsocketNotConnectedException e) { }catch(WebsocketNotConnectedException e) {
Bukkit.getLogger().warning("Tried to send message to a disconnected client."); Bukkit.getLogger().warning(Internationalization.getPhrase("error-disconnected-client"));
} }
} }

View File

@ -14,7 +14,7 @@ public class ExecCommand implements WSCommand {
@Override @Override
public void execute(WSServer wsServer, WebSocket conn, String command) { public void execute(WSServer wsServer, WebSocket conn, String command) {
Bukkit.getLogger().info(Internationalization.getPhrase("cmd-executed-console", conn.getRemoteSocketAddress(), command)); Bukkit.getLogger().info(Internationalization.getPhrase("cmd-executed-console", conn.getRemoteSocketAddress(), Internationalization.utf8ToIso(command)));
ConsoleCommandSender sender = Bukkit.getServer().getConsoleSender(); ConsoleCommandSender sender = Bukkit.getServer().getConsoleSender();
try { try {