From fd337f1b6e3f3532ceba1b1855e7b72d3fcd1871 Mon Sep 17 00:00:00 2001 From: Iru Cai Date: Fri, 25 Nov 2016 19:14:50 +0800 Subject: Use channelClosed() to handle channel close message TODO: Now connection will be closed when a channel close, this should be handled according to RFC 4254. --- src/protocol/fqterm_ssh_socket.cpp | 1 + src/protocol/internal/fqterm_ssh_channel.cpp | 7 +++++-- src/protocol/internal/fqterm_ssh_channel.h | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src/protocol') diff --git a/src/protocol/fqterm_ssh_socket.cpp b/src/protocol/fqterm_ssh_socket.cpp index fff03dd..20612bf 100644 --- a/src/protocol/fqterm_ssh_socket.cpp +++ b/src/protocol/fqterm_ssh_socket.cpp @@ -157,6 +157,7 @@ void FQTermSSHSocket::init(int ssh_version) { FQ_VERIFY(connect(ssh_channel_, SIGNAL(channelOK()), this, SLOT(channelOK()))); FQ_VERIFY(connect(ssh_channel_, SIGNAL(channelReadyRead(const char *, int)), this, SLOT(channelReadyRead(const char *, int)))); FQ_VERIFY(connect(ssh_channel_, SIGNAL(channelError(QString)), this, SLOT(handleError(QString)))); + FQ_VERIFY(connect(ssh_channel_, SIGNAL(channelClosed()), this, SIGNAL(connectionClosed()))); key_exchanger_->initKex(packet_receiver_, packet_sender_); } diff --git a/src/protocol/internal/fqterm_ssh_channel.cpp b/src/protocol/internal/fqterm_ssh_channel.cpp index 38a755a..1e338c9 100644 --- a/src/protocol/internal/fqterm_ssh_channel.cpp +++ b/src/protocol/internal/fqterm_ssh_channel.cpp @@ -360,8 +360,11 @@ void FQTermSSH2Channel::processChannelPacket() { // byte SSH_MSG_CHANNEL_EOF // uint32 recipient channel // FIXME: this error would cause the connection closed, while only the channel need be closed in ssh2. - emit channelError(tr("Channel closed by the server.")); - break; + packet_sender_->startPacket(SSH2_MSG_CHANNEL_CLOSE); + packet_sender_->putInt(server_channel_id_); + packet_sender_->write(); + emit channelClosed(); + break; case SSH2_MSG_CHANNEL_REQUEST: // byte SSH_MSG_CHANNEL_REQUEST // uint32 recipient channel diff --git a/src/protocol/internal/fqterm_ssh_channel.h b/src/protocol/internal/fqterm_ssh_channel.h index 9922528..b0673ba 100644 --- a/src/protocol/internal/fqterm_ssh_channel.h +++ b/src/protocol/internal/fqterm_ssh_channel.h @@ -57,6 +57,7 @@ signals: void channelOK(); void channelReadyRead(const char *data, int len); void channelError(QString); + void channelClosed(); }; class FQTermSSH1Channel: public FQTermSSHChannel { -- cgit v1.2.3