mirror of
https://github.com/tmate-io/tmate-ssh-server.git
synced 2020-11-18 19:53:51 -08:00
[libssh] keepalive implementation
This commit is contained in:
parent
a83c66d909
commit
2ad6723cc2
@ -379,6 +379,8 @@ LIBSSH_API int ssh_channel_write_stderr(ssh_channel channel,
|
|||||||
const void *data,
|
const void *data,
|
||||||
uint32_t len);
|
uint32_t len);
|
||||||
|
|
||||||
|
LIBSSH_API int ssh_send_keepalive(ssh_session session);
|
||||||
|
|
||||||
/* deprecated functions */
|
/* deprecated functions */
|
||||||
SSH_DEPRECATED LIBSSH_API int ssh_accept(ssh_session session);
|
SSH_DEPRECATED LIBSSH_API int ssh_accept(ssh_session session);
|
||||||
SSH_DEPRECATED LIBSSH_API int channel_write_stderr(ssh_channel channel,
|
SSH_DEPRECATED LIBSSH_API int channel_write_stderr(ssh_channel channel,
|
||||||
|
@ -1200,6 +1200,41 @@ int ssh_execute_message_callbacks(ssh_session session){
|
|||||||
return SSH_OK;
|
return SSH_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ssh_send_keepalive(ssh_session session)
|
||||||
|
{
|
||||||
|
/* TODO check the reply and all that */
|
||||||
|
struct ssh_string_struct *req;
|
||||||
|
int reply = 1;
|
||||||
|
int rc = SSH_ERROR;
|
||||||
|
|
||||||
|
enter_function();
|
||||||
|
req = ssh_string_from_char("keepalive@openssh.com");
|
||||||
|
if (req == NULL) {
|
||||||
|
ssh_set_error_oom(session);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buffer_add_u8(session->out_buffer, SSH2_MSG_GLOBAL_REQUEST) < 0 ||
|
||||||
|
buffer_add_ssh_string(session->out_buffer, req) < 0 ||
|
||||||
|
buffer_add_u8(session->out_buffer, reply == 0 ? 0 : 1) < 0) {
|
||||||
|
ssh_set_error_oom(session);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (packet_send(session) == SSH_ERROR)
|
||||||
|
goto out;
|
||||||
|
|
||||||
|
ssh_handle_packets(session, 0);
|
||||||
|
|
||||||
|
ssh_log(session, SSH_LOG_PACKET, "Sent a keepalive");
|
||||||
|
rc = SSH_OK;
|
||||||
|
|
||||||
|
out:
|
||||||
|
ssh_string_free(req);
|
||||||
|
leave_function();
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/* vim: set ts=4 sw=4 et cindent: */
|
/* vim: set ts=4 sw=4 et cindent: */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user