diff --git a/pom.xml b/pom.xml index 9e17fdf..76fc8e8 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.ryanmichela sshd - 1.3.6 + 1.3.6.1 https://github.com/Justasic/Bukkit-SSHD/ @@ -171,4 +171,4 @@ jar - \ No newline at end of file + diff --git a/src/main/java/com/ryanmichela/sshd/ConsoleLogFormatter.java b/src/main/java/com/ryanmichela/sshd/ConsoleLogFormatter.java index 3c29559..629afce 100644 --- a/src/main/java/com/ryanmichela/sshd/ConsoleLogFormatter.java +++ b/src/main/java/com/ryanmichela/sshd/ConsoleLogFormatter.java @@ -67,8 +67,7 @@ public class ConsoleLogFormatter extends Formatter { return result; } - public - String format(LogRecord logrecord) + public String format(LogRecord logrecord) { try { diff --git a/src/main/java/com/ryanmichela/sshd/ConsoleShellFactory.java b/src/main/java/com/ryanmichela/sshd/ConsoleShellFactory.java index df7b9fa..d967e39 100644 --- a/src/main/java/com/ryanmichela/sshd/ConsoleShellFactory.java +++ b/src/main/java/com/ryanmichela/sshd/ConsoleShellFactory.java @@ -138,7 +138,7 @@ public class ConsoleShellFactory implements ShellFactory { this.ConsoleReader.clearScreen(); continue; } - // Hide the mkpasswd command input. + // Hide the mkpasswd command input from other users. Boolean mkpasswd = command.split(" ")[0].equals("mkpasswd"); Bukkit.getScheduler().runTask( @@ -153,17 +153,12 @@ public class ConsoleShellFactory implements ShellFactory { else { if (!mkpasswd) - { - SshdPlugin.instance.getLogger().info("<" + this.Username + "> <" + (mkpasswd ? "True": "False") + "> " + command); + SshdPlugin.instance.getLogger().info("<" + this.Username + "> " + command); - } Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command); } }); } - // This should help stop one of the bugs where bytes are waiting to be written - // but the client fucked off already so the plugin throws an exception. - ((Logger)LogManager.getRootLogger()).removeAppender(this.streamHandlerAppender); } catch (IOException e) { diff --git a/src/main/java/com/ryanmichela/sshd/FlushyOutputStream.java b/src/main/java/com/ryanmichela/sshd/FlushyOutputStream.java index 34027cb..2442a4a 100644 --- a/src/main/java/com/ryanmichela/sshd/FlushyOutputStream.java +++ b/src/main/java/com/ryanmichela/sshd/FlushyOutputStream.java @@ -1,49 +1,59 @@ package com.ryanmichela.sshd; import org.apache.sshd.common.SshException; +import org.apache.sshd.common.channel.exception.SshChannelClosedException; import java.io.IOException; import java.io.OutputStream; +import java.math.BigInteger; /** * Copyright 2013 Ryan Michela */ -public class FlushyOutputStream extends OutputStream { +public class FlushyOutputStream extends OutputStream +{ private OutputStream base; private boolean isClosed = false; - public FlushyOutputStream(OutputStream base) { + public FlushyOutputStream(OutputStream base) + { this.base = base; } @Override - public void write(int b) throws IOException { - if (isClosed) return; - base.write(b); - base.flush(); + public void write(int b) throws IOException + { + this.write(BigInteger.valueOf(b).toByteArray()); } @Override - public void write(byte[] b) throws IOException { - if (isClosed) return; - base.write(b); - base.flush(); + public void write(byte[] b) throws IOException + { + this.write(b, 0, b.length); } @Override - public void write(byte[] b, int off, int len) throws IOException { - if (isClosed) return; - try { + public void write(byte[] b, int off, int len) throws IOException + { + if (isClosed) + return; + + try + { base.write(b, off, len); base.flush(); - } catch (SshException e) { - if (!e.getMessage().contains("channel already closed")) throw e; + } + catch (SshChannelClosedException e) + { + // ignored. } } @Override - public void close() { + public void close() throws IOException + { isClosed = true; + base.close(); } } diff --git a/src/main/java/com/ryanmichela/sshd/MkpasswdCommand.java b/src/main/java/com/ryanmichela/sshd/MkpasswdCommand.java index 6022bc3..60cdc66 100644 --- a/src/main/java/com/ryanmichela/sshd/MkpasswdCommand.java +++ b/src/main/java/com/ryanmichela/sshd/MkpasswdCommand.java @@ -39,7 +39,6 @@ class MkpasswdCommand implements CommandExecutor // Dumb but whatever. Some people are really dense. if (algoritm.equalsIgnoreCase("PLAIN")) { - sender.sendMessage("Your hash: " + password); // I mean c'mon... sender.sendMessage("Bro really? it's literally your unencrypted password..."); }