Таймауты на соединение

pull/39/head
L_DelOff 2023-12-17 15:11:13 +03:00
parent 3a967e399b
commit 25b73feb48
2 changed files with 6 additions and 0 deletions

View File

@ -5,6 +5,7 @@ import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Repository;
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
import ru.ldeloff.servermonitorbot.config.SshConfig;
@ -20,6 +21,9 @@ public class SshRepositoryImpl implements SshRepository {
private final List<SshServer> sshServers;
@Value("${ssh.timeout:5000}")
private int TIMEOUT;
@Autowired
public SshRepositoryImpl(SshConfig sshConfig) {
this.sshServers = sshConfig.getServers();
@ -48,6 +52,7 @@ public class SshRepositoryImpl implements SshRepository {
sshServer.getPort());
session.setPassword(sshServer.getPassword());
session.setConfig("StrictHostKeyChecking", "no");
session.setTimeout(TIMEOUT);
session.connect();
return session;
}

View File

@ -17,6 +17,7 @@ bot:
- telegramId: 123456789
role: admin
ssh:
timeout: 5000
servers:
-
name: "Server Name"