Таймауты на соединение
parent
3a967e399b
commit
25b73feb48
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ bot:
|
|||
- telegramId: 123456789
|
||||
role: admin
|
||||
ssh:
|
||||
timeout: 5000
|
||||
servers:
|
||||
-
|
||||
name: "Server Name"
|
||||
|
|
Loading…
Reference in New Issue