summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIru Cai <mytbk920423@gmail.com>2018-04-28 21:55:16 +0800
committerIru Cai <mytbk920423@gmail.com>2018-04-30 15:20:28 +0800
commit8b2b2f18b2539bb73769b2196af977023903b2db (patch)
treecf8903e8394247df18fa2862b37f74068677b2bb
parentef70cc73c69d04e93c9af5fb49c5d762ba226801 (diff)
downloadfqterm-8b2b2f18b2539bb73769b2196af977023903b2db.tar.xz
Add a function to report connection info
-rw-r--r--res/pic/conn_info.pngbin0 -> 815 bytes
-rw-r--r--src/common/fqterm_shortcuthelper.cpp2
-rw-r--r--src/common/fqterm_shortcuthelper.h1
-rw-r--r--src/fqterm/fqterm_frame.cpp56
-rw-r--r--src/fqterm/fqterm_frame.h1
-rw-r--r--src/terminal/fqterm_session.h4
-rw-r--r--src/terminal/internal/fqterm_telnet.h4
7 files changed, 66 insertions, 2 deletions
diff --git a/res/pic/conn_info.png b/res/pic/conn_info.png
new file mode 100644
index 0000000..80d194b
--- /dev/null
+++ b/res/pic/conn_info.png
Binary files differ
diff --git a/src/common/fqterm_shortcuthelper.cpp b/src/common/fqterm_shortcuthelper.cpp
index f4395c4..432ddb2 100644
--- a/src/common/fqterm_shortcuthelper.cpp
+++ b/src/common/fqterm_shortcuthelper.cpp
@@ -52,6 +52,7 @@ void FQTermShortcutHelper::initShortcutDescriptionTable()
initShortcutDescriptionTableEntry(CASCADEWINDOWS, "cascadewindows", tr(""), tr("Cascade Windows"));
initShortcutDescriptionTableEntry(TILEWINDOWS, "tilewindows", tr(""), tr("Tils Windows"));
initShortcutDescriptionTableEntry(DISCONNECT, "disconnect", tr(""), tr("Disconnect Host"), "disconnect");
+ initShortcutDescriptionTableEntry(CONN_INFO, "conninfo", tr(""), tr("Connection Info"), "conn_info");
initShortcutDescriptionTableEntry(ADDRESSBOOK, "addressbook", tr("F2"), tr("Address Book"), "address_book");
initShortcutDescriptionTableEntry(QUICKLOGIN, "quicklogin", tr("F3"), tr("Quick Login"), "quick_login");
#if defined(__APPLE__)
@@ -171,6 +172,7 @@ void FQTermShortcutHelper::retranslateAction(int shortcut, const QString& text)
void FQTermShortcutHelper::retranslateActions() {
retranslateAction(CONNECT, tr("&Connect"));
retranslateAction(DISCONNECT, tr("&Disconnect"));
+ retranslateAction(CONN_INFO, tr("Connection Info"));
retranslateAction(ADDRESSBOOK, tr("&Address book"));
retranslateAction(QUICKLOGIN, tr("&Quick login"));
retranslateAction(COPY, tr("&Copy"));
diff --git a/src/common/fqterm_shortcuthelper.h b/src/common/fqterm_shortcuthelper.h
index 91904ac..03ecc4a 100644
--- a/src/common/fqterm_shortcuthelper.h
+++ b/src/common/fqterm_shortcuthelper.h
@@ -52,6 +52,7 @@ public:
FQTERM_APPLICATION_SHORTCUT_START = 0,
CONNECT,
DISCONNECT,
+ CONN_INFO,
ADDRESSBOOK, //F2
QUICKLOGIN, //F3
COPY, //Ctrl+Ins under lin & win, Ctrl+C under mac
diff --git a/src/fqterm/fqterm_frame.cpp b/src/fqterm/fqterm_frame.cpp
index a470595..dfeaa86 100644
--- a/src/fqterm/fqterm_frame.cpp
+++ b/src/fqterm/fqterm_frame.cpp
@@ -85,6 +85,8 @@
#include "defineescape.h"
#include "uaocodec.h"
+#include "connect_info.h"
+
#ifdef USE_DOTNET_STYLE
#include "dotnetstyle.h"
#endif //USE_DOTNET_STYLE
@@ -690,6 +692,56 @@ void FQTermFrame::disconnect() {
}
}
+static QString ssh2_info(conn_info_t *info)
+{
+ QString txt;
+ txt.append("\nhost key (SHA256): ");
+ const char *tab = "0123456789ABCDEF";
+ for (int i=0; i<32; i++) {
+ unsigned char b = info->ssh_proto_info.hash[i];
+ char hex[4] = { tab[(b>>4)], tab[b&0xf], ':', 0 };
+ if (i==31)
+ hex[2] = 0;
+ txt.append(hex);
+ }
+ txt.append(QString("\ncipher(c2s): %1\ncipher(s2c): %2")
+ .arg(info->ssh_proto_info.c2s_cipher)
+ .arg(info->ssh_proto_info.s2c_cipher));
+ if (info->ssh_proto_info.c2s_mac) {
+ txt.append(QString("\nMAC(c2s): %1")
+ .arg(info->ssh_proto_info.c2s_mac));
+ }
+ if (info->ssh_proto_info.s2c_mac) {
+ txt.append(QString("\nMAC(s2c): %1")
+ .arg(info->ssh_proto_info.s2c_mac));
+ }
+ return txt;
+}
+
+void FQTermFrame::conn_info()
+{
+ FQTermSession *sess = windowManager_->activeWindow()->getSession();
+ conn_info_t *info = sess->connectionInfo();
+ QString txt;
+ switch (info->proto) {
+ case PROTO_TELNET:
+ txt = "protocol: Telnet";
+ break;
+ case PROTO_LOCAL:
+ txt = "protocol: Local";
+ break;
+ case PROTO_SSH:
+ txt = QString("protocol: SSH %1")
+ .arg(info->ssh_proto_info.proto_version);
+ if (info->ssh_proto_info.proto_version == 2)
+ txt.append(ssh2_info(info));
+ break;
+ }
+ QMessageBox b(QMessageBox::Information, "Connection Information",
+ txt, QMessageBox::Ok, this);
+ b.exec();
+}
+
void FQTermFrame::copy() {
windowManager_->activeWindow()->copy();
}
@@ -1335,6 +1387,7 @@ void FQTermFrame::addMainTool() {
// the toolbar
toolBarMdiConnectTools_ = addToolBar("BBS operations");
toolBarMdiConnectTools_->setObjectName("BBS operations");
+ toolBarMdiConnectTools_->addAction(getAction(FQTermShortcutHelper::CONN_INFO));
FQTERM_ADDACTION(toolBarMdiConnectTools_, DISCONNECT, this, disconnect);
getAction(FQTermShortcutHelper::DISCONNECT)->setEnabled(false);
toolBarMdiConnectTools_->addSeparator();
@@ -1422,6 +1475,7 @@ void FQTermFrame::addMainMenu() {
FQTERM_ADDACTION(menuFile_, CONNECT, this, connectIt);
FQTERM_ADDACTION(menuFile_, DISCONNECT, this, disconnect);
+ FQTERM_ADDACTION(menuFile_, CONN_INFO, this, conn_info);
menuFile_->addSeparator();
FQTERM_ADDACTION(menuFile_, ADDRESSBOOK, this, addressBook);
FQTERM_ADDACTION(menuFile_, QUICKLOGIN, this, quickLogin);
@@ -1588,6 +1642,7 @@ void FQTermFrame::updateMenuToolBar() {
}
// update menu
+ getAction(FQTermShortcutHelper::CONN_INFO)->setEnabled(window->isConnected());
getAction(FQTermShortcutHelper::DISCONNECT)->setEnabled(window->isConnected());
getAction(FQTermShortcutHelper::COPYWITHCOLOR)->setChecked(window->getSession()->param().isColorCopy_);
getAction(FQTermShortcutHelper::RECTANGLESELECTION)->setChecked(window->getSession()->param().isRectSelect_);
@@ -1654,6 +1709,7 @@ void FQTermFrame::comboFontChanged(const QFont & font) {
}
void FQTermFrame::enableMenuToolBar(bool enable) {
+ getAction(FQTermShortcutHelper::CONN_INFO)->setEnabled(enable);
getAction(FQTermShortcutHelper::DISCONNECT)->setEnabled(enable);
getAction(FQTermShortcutHelper::COPY)->setEnabled(enable);
getAction(FQTermShortcutHelper::PASTE)->setEnabled(enable);
diff --git a/src/fqterm/fqterm_frame.h b/src/fqterm/fqterm_frame.h
index cdb1d01..e521403 100644
--- a/src/fqterm/fqterm_frame.h
+++ b/src/fqterm/fqterm_frame.h
@@ -118,6 +118,7 @@ class FQTermFrame: public QMainWindow {
void connectIt();
void disconnect();
+ void conn_info();
void copy();
void paste();
void searchIt();
diff --git a/src/terminal/fqterm_session.h b/src/terminal/fqterm_session.h
index e1f1df3..e28a590 100644
--- a/src/terminal/fqterm_session.h
+++ b/src/terminal/fqterm_session.h
@@ -35,6 +35,8 @@
#include "fqterm_param.h"
#include "fqterm_config.h"
#include "fqterm_convert.h"
+#include "internal/fqterm_telnet.h"
+#include "connect_info.h"
#ifdef HAVE_PYTHON
#include <Python.h>
#endif //HAVE_PYTHON
@@ -79,7 +81,6 @@ struct LineColorInfo {
class FQTermConfig;
class FQTermBuffer;
class FQTermTextLine;
-class FQTermTelnet;
class FQTermDecode;
class FQTermZmodem;
class ArticleCopyThread;
@@ -220,6 +221,7 @@ class FQTermSession: public QObject {
void stopLogging(bool);
bool isLogging();
+ conn_info_t * connectionInfo() { return telnet_->connectionInfo(); }
public:
diff --git a/src/terminal/internal/fqterm_telnet.h b/src/terminal/internal/fqterm_telnet.h
index 33e8c6e..1e086e0 100644
--- a/src/terminal/internal/fqterm_telnet.h
+++ b/src/terminal/internal/fqterm_telnet.h
@@ -23,6 +23,8 @@
#include <QAbstractSocket>
#include <QByteArray>
+#include "fqterm_socket.h"
+#include "connect_info.h"
namespace FQTerm {
@@ -52,7 +54,6 @@ struct fsm_trans {
* FQTermTelnet class definition
*-------------------------------------------------------------------------------
*/
-class FQTermSocket;
// Telnet connection, a wrapper of socket.
// It will translate raw NVT data from low level socket to ansi data,
@@ -84,6 +85,7 @@ class FQTermTelnet: public QObject {
bool readyForInput();
+ conn_info_t *connectionInfo() { return socket->connectionInfo(); }
signals:
void readyRead(int, int); // There are datas to be read out