From 25b73feb482b68bc9bc07a0d6ae4f868f6321643 Mon Sep 17 00:00:00 2001 From: L_DelOff Date: Sun, 17 Dec 2023 15:11:13 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B0=D0=B9=D0=BC=D0=B0=D1=83=D1=82?= =?UTF-8?q?=D1=8B=20=D0=BD=D0=B0=20=D1=81=D0=BE=D0=B5=D0=B4=D0=B8=D0=BD?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../servermonitorbot/repository/SshRepositoryImpl.java | 5 +++++ src/main/resources/application.yml | 1 + 2 files changed, 6 insertions(+) diff --git a/src/main/java/ru/ldeloff/servermonitorbot/repository/SshRepositoryImpl.java b/src/main/java/ru/ldeloff/servermonitorbot/repository/SshRepositoryImpl.java index 8210141..42f2f72 100644 --- a/src/main/java/ru/ldeloff/servermonitorbot/repository/SshRepositoryImpl.java +++ b/src/main/java/ru/ldeloff/servermonitorbot/repository/SshRepositoryImpl.java @@ -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 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; } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index e4c33ae..721da82 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -17,6 +17,7 @@ bot: - telegramId: 123456789 role: admin ssh: + timeout: 5000 servers: - name: "Server Name"