mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-09-25 16:13:24 +08:00
add pg default database
This commit is contained in:
@ -17,17 +17,23 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
public class SSHManager {
|
public class SSHManager {
|
||||||
|
|
||||||
public static Session getSSHSession(SSHInfo ssh) {
|
public static Session getSSHSession(SSHInfo ssh) {
|
||||||
Session session;
|
Session session = null;
|
||||||
try {
|
try {
|
||||||
byte[] passphrase = StringUtils.isNotBlank(ssh.getPassphrase()) ? StringUtils.getBytes(ssh.getPassphrase(),
|
if (StringUtils.isNotBlank(ssh.getKeyFile())) {
|
||||||
|
byte[] passphrase = StringUtils.isNotBlank(ssh.getPassphrase()) ? StringUtils.getBytes(
|
||||||
|
ssh.getPassphrase(),
|
||||||
"UTF-8") : null;
|
"UTF-8") : null;
|
||||||
session = JschUtil.getSession(ssh.getHostName(), Integer.parseInt(ssh.getPort()), ssh.getUserName(),
|
session = JschUtil.getSession(ssh.getHostName(), Integer.parseInt(ssh.getPort()), ssh.getUserName(),
|
||||||
ssh.getKeyFile(), passphrase);
|
ssh.getKeyFile(), passphrase);
|
||||||
|
} else if (StringUtils.isNotBlank(ssh.getUserName())) {
|
||||||
|
session = JschUtil.getSession(ssh.getHostName(), Integer.parseInt(ssh.getPort()), ssh.getUserName(),
|
||||||
|
ssh.getPassword());
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ConnectionException("connection.ssh.error", null, e);
|
throw new ConnectionException("connection.ssh.error", null, e);
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(ssh.getRHost()) && StringUtils.isNotBlank(ssh.getRPort())) {
|
if (session != null && StringUtils.isNotBlank(ssh.getRHost()) && StringUtils.isNotBlank(ssh.getRPort())) {
|
||||||
try {
|
try {
|
||||||
int localPort = !StringUtils.isBlank(ssh.getLocalPort()) ? Integer.parseInt(ssh.getLocalPort())
|
int localPort = !StringUtils.isBlank(ssh.getLocalPort()) ? Integer.parseInt(ssh.getLocalPort())
|
||||||
: NetUtil.getUsableLocalPort();
|
: NetUtil.getUsableLocalPort();
|
||||||
|
Reference in New Issue
Block a user