Skip to content

Commit

Permalink
chore: update dependency com.hierynomus:sshj to v0.39.0 (#1506)
Browse files Browse the repository at this point in the history
  • Loading branch information
renovate[bot] authored Sep 28, 2024
1 parent bf37a10 commit 27f11e0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ mysqlConnector = "9.0.0"
# general
oshi = "6.6.4"
vavr = "0.10.4"
sshj = "0.38.0"
sshj = "0.39.0"
aerogel = "2.1.0"
awsSdk = "2.28.11"
unirest = "4.4.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@
import lombok.NonNull;
import net.schmizz.keepalive.KeepAlive;
import net.schmizz.keepalive.KeepAliveProvider;
import net.schmizz.sshj.common.Message;
import net.schmizz.sshj.common.SSHPacket;
import net.schmizz.sshj.connection.ConnectionImpl;
import net.schmizz.sshj.transport.TransportException;

public final class ActiveHeartbeatKeepAliveProvider extends KeepAliveProvider {

Expand All @@ -31,29 +28,8 @@ public final class ActiveHeartbeatKeepAliveProvider extends KeepAliveProvider {

@Override
public @NonNull KeepAlive provide(@NonNull ConnectionImpl connection) {
var keepAlive = new HeartbeatKeepAlive(connection);
var keepAlive = KeepAliveProvider.HEARTBEAT.provide(connection);
keepAlive.setKeepAliveInterval(HEARTBEAT_DELAY_SECONDS);
return keepAlive;
}

private static final class HeartbeatKeepAlive extends KeepAlive {

public HeartbeatKeepAlive(@NonNull ConnectionImpl conn) {
super(conn, "cloudnet-ssh-heartbeater");
}

@Override
protected void doKeepAlive() throws TransportException {
// when the server wants a strict key exchange, no other packets are allowed
// to be sent in that time interval (KEX_INIT must be the first packet). As it's
// very unlikely that a heartbeat is required during the timeframe anyway, we just
// don't execute the heartbeat until the key exchange is completed.
// Done by ensuring that the service is set. This means that the key
// exchange is done and the connection is up.
var transport = this.conn.getTransport();
if (this.conn.equals(transport.getService())) {
transport.write(new SSHPacket(Message.IGNORE));
}
}
}
}

0 comments on commit 27f11e0

Please sign in to comment.