SSH on bungee now works.
Had to rewrite the mkpasswd command and how the console was handled in the SSH session as many areas didn't use CRLF compared to Spigot which seems to work better. The config had to be done manually for the plugin since BungeeCord doesn't handle plugin configs as conveniently. Removed the test server I accidentally added to the git repo.
This commit is contained in:
parent
1c6028199b
commit
d38c75dd9e
@ -1,47 +0,0 @@
|
|||||||
forge_support: false
|
|
||||||
connection_throttle_limit: 3
|
|
||||||
timeout: 30000
|
|
||||||
online_mode: true
|
|
||||||
log_commands: false
|
|
||||||
listeners:
|
|
||||||
- query_port: 25577
|
|
||||||
motd: '&1Another Bungee server'
|
|
||||||
tab_list: GLOBAL_PING
|
|
||||||
query_enabled: false
|
|
||||||
proxy_protocol: false
|
|
||||||
forced_hosts:
|
|
||||||
pvp.md-5.net: pvp
|
|
||||||
ping_passthrough: false
|
|
||||||
priorities:
|
|
||||||
- lobby
|
|
||||||
bind_local_address: true
|
|
||||||
host: 0.0.0.0:25577
|
|
||||||
max_players: 1
|
|
||||||
tab_size: 60
|
|
||||||
force_default_server: false
|
|
||||||
connection_throttle: 4000
|
|
||||||
groups:
|
|
||||||
md_5:
|
|
||||||
- admin
|
|
||||||
log_pings: true
|
|
||||||
ip_forward: false
|
|
||||||
prevent_proxy_connections: false
|
|
||||||
network_compression_threshold: 256
|
|
||||||
disabled_commands:
|
|
||||||
- disabledcommandhere
|
|
||||||
stats: 8d157bd9-a8be-441b-8dec-fd61c19393e5
|
|
||||||
permissions:
|
|
||||||
default:
|
|
||||||
- bungeecord.command.server
|
|
||||||
- bungeecord.command.list
|
|
||||||
admin:
|
|
||||||
- bungeecord.command.alert
|
|
||||||
- bungeecord.command.end
|
|
||||||
- bungeecord.command.ip
|
|
||||||
- bungeecord.command.reload
|
|
||||||
servers:
|
|
||||||
lobby:
|
|
||||||
motd: '&1Just another BungeeCord - Forced Host'
|
|
||||||
address: localhost:25565
|
|
||||||
restricted: false
|
|
||||||
player_limit: -1
|
|
@ -1 +0,0 @@
|
|||||||
{}
|
|
@ -1,8 +0,0 @@
|
|||||||
version: 2
|
|
||||||
modules:
|
|
||||||
- jenkins://cmd_alert
|
|
||||||
- jenkins://cmd_find
|
|
||||||
- jenkins://cmd_list
|
|
||||||
- jenkins://cmd_send
|
|
||||||
- jenkins://cmd_server
|
|
||||||
- jenkins://reconnect_yaml
|
|
@ -1 +0,0 @@
|
|||||||
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDlOkUWRz4aOH8E0oX2Cx7WIqFdIK17n0aeLopLemE9xXPQnPQYKpxCXimU242GAF3c6UldRMWesrXqdyjaPOCe63NAgBpsc7v+nfDOZSYmN1OoBDTs/gDSIA/KlAK+c5W8kEQ108d0us5lmPT+KEKx8jo614jwSaKNRjPLY9G7pXcJ2u1q55wNW/6T/z//zzulo3Bvo6rFnj8hg85cFnOO/ZyiZbI72RO/ElAlP8Q+tpwRTP/JE5BR50sdf6jVuowsMw4BdTMi+U+ggRPbfOTowLoQybV8y/GM8F6+PCAi7ItZYgEYJvw3jjCl5F88hyrm5ayBo17tGKrrQ827HB0T zachery@Zachery
|
|
Binary file not shown.
@ -1,8 +0,0 @@
|
|||||||
§l§4 _____ _____ _ _ _____§r
|
|
||||||
§l§6 / ____/ ____| | | | __ \§r
|
|
||||||
§l§2| (___| (___ | |__| | | | |§r
|
|
||||||
§l§3 \___ \\___ \| __ | | | |§r
|
|
||||||
§l§9 ____) |___) | | | | |__| |§r
|
|
||||||
§l§5|_____/_____/|_| |_|_____/§r
|
|
||||||
|
|
||||||
===============================================
|
|
@ -1 +0,0 @@
|
|||||||
test: This configuration file works!
|
|
1212
bungee/proxy.log.0
1212
bungee/proxy.log.0
File diff suppressed because it is too large
Load Diff
@ -54,8 +54,10 @@ public class ConsoleCommandFactory implements CommandFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(ChannelSession cs, Environment environment) throws IOException {
|
public void start(ChannelSession cs, Environment environment) throws IOException
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
SshdPlugin.instance.getLogger()
|
SshdPlugin.instance.getLogger()
|
||||||
.info("[U: " + environment.getEnv().get(Environment.ENV_USER) + "] " + command);
|
.info("[U: " + environment.getEnv().get(Environment.ENV_USER) + "] " + command);
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ public class ConsoleLogFormatter extends Formatter
|
|||||||
stringbuilder.append(stringwriter.toString());
|
stringbuilder.append(stringwriter.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
return stringbuilder.toString();
|
return stringbuilder.toString().replace("\n", "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void colorize(LogRecord logrecord)
|
private void colorize(LogRecord logrecord)
|
||||||
|
@ -25,7 +25,7 @@ public class FlushyStreamHandler extends StreamHandler
|
|||||||
@Override
|
@Override
|
||||||
public synchronized void publish(LogRecord record)
|
public synchronized void publish(LogRecord record)
|
||||||
{
|
{
|
||||||
record.setMessage(record.getMessage().replace("\n", "\r\n"));
|
record.setMessage(record.getMessage().replace("\n", "\n\r"));
|
||||||
super.publish(record);
|
super.publish(record);
|
||||||
flush();
|
flush();
|
||||||
}
|
}
|
||||||
|
@ -5,24 +5,31 @@ import java.util.Arrays;
|
|||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
import net.md_5.bungee.api.plugin.Command;
|
import net.md_5.bungee.api.plugin.Command;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
|
|
||||||
import com.ryanmichela.sshd.Cryptography;
|
import com.ryanmichela.sshd.Cryptography;
|
||||||
import com.ryanmichela.sshd.SshdPlugin;
|
import com.ryanmichela.sshd.SshdPlugin;
|
||||||
|
|
||||||
public class MkpasswdCommand extends Command
|
public class MkpasswdCommand extends Command
|
||||||
{
|
{
|
||||||
|
|
||||||
public MkpasswdCommand()
|
public MkpasswdCommand()
|
||||||
{
|
{
|
||||||
super("mkpasswd");
|
super("mkpasswd");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SendSyntax(CommandSender sender, boolean invalid)
|
||||||
|
{
|
||||||
|
if (invalid)
|
||||||
|
sender.sendMessage(new ComponentBuilder("Invalid Syntax").color(ChatColor.RED).create());
|
||||||
|
sender.sendMessage(new ComponentBuilder("/mkpasswd <help|hash> <password>").color(ChatColor.GREEN).create());
|
||||||
|
sender.sendMessage(new ComponentBuilder("Supported Hashes: SHA256, PBKDF2, BCRYPT, PLAIN").color(ChatColor.BLUE).create());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args)
|
public void execute(CommandSender sender, String[] args)
|
||||||
{
|
{
|
||||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
|
||||||
String algoritm, password;
|
String algoritm, password;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Stupid bukkit, we have to concatenate the arguments together if they're using
|
// Stupid bukkit, we have to concatenate the arguments together if they're using
|
||||||
@ -33,40 +40,47 @@ public class MkpasswdCommand extends Command
|
|||||||
catch (ArrayIndexOutOfBoundsException e)
|
catch (ArrayIndexOutOfBoundsException e)
|
||||||
{
|
{
|
||||||
// ignore it.
|
// ignore it.
|
||||||
sender.sendMessage("Invalid Syntax");
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If they're console, allow regardless.
|
// If they're a player, check and make sure they have a permission
|
||||||
|
// If they're not a player (aka, the console), just return true.
|
||||||
|
boolean hasperm = (sender instanceof ProxiedPlayer) ? ((ProxiedPlayer)sender).hasPermission("sshd.mkpasswd") : true;
|
||||||
|
|
||||||
|
if (hasperm)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (player.hasPermission("sshd.mkpasswd"))
|
String hash = "";
|
||||||
{
|
|
||||||
// Dumb but whatever. Some people are really dense.
|
// Dumb but whatever. Some people are really dense.
|
||||||
if (algoritm.equalsIgnoreCase("PLAIN"))
|
if (algoritm.equalsIgnoreCase("PLAIN"))
|
||||||
sender.sendMessage(password);
|
|
||||||
else if (algoritm.equalsIgnoreCase("pbkdf2"))
|
|
||||||
sender.sendMessage(Cryptography.PBKDF2_HashPassword(password));
|
|
||||||
else if (algoritm.equalsIgnoreCase("bcrypt"))
|
|
||||||
sender.sendMessage(Cryptography.BCrypt_HashPassword(password));
|
|
||||||
else if (algoritm.equalsIgnoreCase("sha256"))
|
|
||||||
sender.sendMessage(Cryptography.SHA256_HashPassword(password));
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
sender.sendMessage("Invalid Syntax");
|
// I mean c'mon...
|
||||||
|
sender.sendMessage("Bro really? it's literally your unencrypted password...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if (algoritm.equalsIgnoreCase("pbkdf2"))
|
||||||
|
hash = Cryptography.PBKDF2_HashPassword(password);
|
||||||
|
else if (algoritm.equalsIgnoreCase("bcrypt"))
|
||||||
|
hash = Cryptography.BCrypt_HashPassword(password);
|
||||||
|
else if (algoritm.equalsIgnoreCase("sha256"))
|
||||||
|
hash = Cryptography.SHA256_HashPassword(password);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.SendSyntax(sender, !algoritm.equalsIgnoreCase("help"));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(new ComponentBuilder("Your Hash: " + hash).color(ChatColor.BLUE).create());
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
// since this is a player, send a failure message
|
// We're console, just print the stack trace.
|
||||||
sender.sendMessage("An error occured, please check console.");
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
class MkpasswdCommand implements CommandExecutor
|
class MkpasswdCommand implements CommandExecutor
|
||||||
|
@ -32,10 +32,9 @@ public final class SshdPlugin extends Plugin
|
|||||||
private File file;
|
private File file;
|
||||||
public Configuration configuration;
|
public Configuration configuration;
|
||||||
|
|
||||||
|
|
||||||
@Override public void onLoad()
|
@Override public void onLoad()
|
||||||
{
|
{
|
||||||
file = new File(ProxyServer.getInstance().getPluginsFolder()+ "/config.yml");
|
file = new File(getDataFolder(), "config.yml");
|
||||||
|
|
||||||
File authorizedKeys = new File(getDataFolder(), "authorized_keys");
|
File authorizedKeys = new File(getDataFolder(), "authorized_keys");
|
||||||
if (!authorizedKeys.exists())
|
if (!authorizedKeys.exists())
|
||||||
@ -59,13 +58,11 @@ public final class SshdPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
if (!file.exists())
|
if (!file.exists())
|
||||||
{
|
{
|
||||||
file.createNewFile();
|
// Copy our config file.
|
||||||
|
InputStream link = (getClass().getResourceAsStream("/config.yml"));
|
||||||
|
Files.copy(link, file.getAbsoluteFile().toPath());
|
||||||
}
|
}
|
||||||
configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
|
configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(file);
|
||||||
|
|
||||||
// more testing
|
|
||||||
configuration.set("test", "This configuration file works!");
|
|
||||||
ConfigurationProvider.getProvider(YamlConfiguration.class).save(configuration,file);
|
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
@ -76,10 +73,6 @@ public final class SshdPlugin extends Plugin
|
|||||||
// SSHD will log that it wrote bites to the output stream, which writes
|
// SSHD will log that it wrote bites to the output stream, which writes
|
||||||
// bytes to the output stream - ad nauseaum.
|
// bytes to the output stream - ad nauseaum.
|
||||||
getLogger().setLevel(Level.INFO);
|
getLogger().setLevel(Level.INFO);
|
||||||
|
|
||||||
// config testing
|
|
||||||
String printout = configuration.getString("test");
|
|
||||||
getLogger().info(printout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onEnable()
|
@Override public void onEnable()
|
||||||
|
@ -23,25 +23,33 @@ public final class SSHDCommandSender implements CommandSender
|
|||||||
@Override
|
@Override
|
||||||
public void sendMessage(String message)
|
public void sendMessage(String message)
|
||||||
{
|
{
|
||||||
if (message.indexOf('\n') != 0)
|
this.sendRawMessage(message + "\r");
|
||||||
this.sendRawMessage(message);
|
|
||||||
else
|
|
||||||
Arrays.asList(message.split("\n")).forEach(this::sendMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendRawMessage(String message)
|
public void sendRawMessage(String message)
|
||||||
{
|
{
|
||||||
if (this.console.ConsoleReader == null)
|
if (this.console.ConsoleReader == null)
|
||||||
return;
|
return;
|
||||||
/*
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.console.ConsoleReader.println(ConsoleLogFormatter.ColorizeString(message).replace("\n", "\n\r"));
|
this.console.ConsoleReader.println(ConsoleLogFormatter.ColorizeString(message).replace("\n", "\n\r"));
|
||||||
|
this.console.ConsoleReader.print(this.console.ConsoleReader.RESET_LINE + "");
|
||||||
|
this.console.ConsoleReader.flush();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.console.ConsoleReader.drawLine();
|
||||||
|
}
|
||||||
|
catch (Throwable ex)
|
||||||
|
{
|
||||||
|
this.console.ConsoleReader.getCursorBuffer().clear();
|
||||||
|
}
|
||||||
|
this.console.ConsoleReader.flush();
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
SshdPlugin.instance.getLogger().log(Level.SEVERE, "Error sending message to SSHDCommandSender", e);
|
SshdPlugin.instance.getLogger().log(Level.SEVERE, "Error sending message to SSHDCommandSender", e);
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user