summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2016-11-25 19:14:50 +0800
committerIru Cai <mytbk920423@gmail.com>2018-04-29 16:51:12 +0800
commitfd337f1b6e3f3532ceba1b1855e7b72d3fcd1871 (patch)
tree949554894326d70e727bad6258934ded7dd8e300
parentf0ed386c8713db9955d9dd007f5a32f8cb4e251d (diff)
downloadfqterm-fd337f1b6e3f3532ceba1b1855e7b72d3fcd1871.tar.xz
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.
-rw-r--r--src/protocol/fqterm_ssh_socket.cpp1
-rw-r--r--src/protocol/internal/fqterm_ssh_channel.cpp7
-rw-r--r--src/protocol/internal/fqterm_ssh_channel.h1
3 files changed, 7 insertions, 2 deletions
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 {