Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

Commit

Permalink
This should actually fix rmichela#10
Browse files Browse the repository at this point in the history
  • Loading branch information
Justasic committed Oct 6, 2019
1 parent 1b4c7c2 commit 0afba39
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 28 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.ryanmichela</groupId>
<artifactId>sshd</artifactId>
<version>1.3.6</version>
<version>1.3.6.1</version>
<url>https://github.com/Justasic/Bukkit-SSHD/</url>

<properties>
Expand Down Expand Up @@ -171,4 +171,4 @@
</build>

<packaging>jar</packaging>
</project>
</project>
3 changes: 1 addition & 2 deletions src/main/java/com/ryanmichela/sshd/ConsoleLogFormatter.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ public static String ColorizeString(String str)
return result;
}

public
String format(LogRecord logrecord)
public String format(LogRecord logrecord)
{
try
{
Expand Down
9 changes: 2 additions & 7 deletions src/main/java/com/ryanmichela/sshd/ConsoleShellFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void run()
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(
Expand All @@ -153,17 +153,12 @@ public void run()
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)
{
Expand Down
42 changes: 26 additions & 16 deletions src/main/java/com/ryanmichela/sshd/FlushyOutputStream.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
1 change: 0 additions & 1 deletion src/main/java/com/ryanmichela/sshd/MkpasswdCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
// 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...");
}
Expand Down

0 comments on commit 0afba39

Please sign in to comment.