mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-25 07:21:14 +01:00
NetworkWidget: Reorganise SSL options group box
Create "Dump options" and "Security options" group boxes. Add "Network dump format" combo box. Add "Open dump folder" button.
This commit is contained in:
parent
5e4c6d42a1
commit
a8dc1e3f1c
@ -5,10 +5,15 @@
|
|||||||
#include "DolphinQt/Debugger/NetworkWidget.h"
|
#include "DolphinQt/Debugger/NetworkWidget.h"
|
||||||
|
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QDesktopServices>
|
||||||
#include <QGridLayout>
|
#include <QGridLayout>
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
#include <QHeaderView>
|
#include <QHeaderView>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QPushButton>
|
||||||
#include <QTableWidget>
|
#include <QTableWidget>
|
||||||
|
#include <QUrl>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -18,6 +23,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "Common/FileUtil.h"
|
||||||
#include "Core/Config/MainSettings.h"
|
#include "Core/Config/MainSettings.h"
|
||||||
#include "Core/IOS/Network/SSL.h"
|
#include "Core/IOS/Network/SSL.h"
|
||||||
#include "Core/IOS/Network/Socket.h"
|
#include "Core/IOS/Network/Socket.h"
|
||||||
@ -191,7 +197,8 @@ void NetworkWidget::CreateWidgets()
|
|||||||
widget->setLayout(layout);
|
widget->setLayout(layout);
|
||||||
layout->addWidget(CreateSocketTableGroup());
|
layout->addWidget(CreateSocketTableGroup());
|
||||||
layout->addWidget(CreateSSLContextGroup());
|
layout->addWidget(CreateSSLContextGroup());
|
||||||
layout->addWidget(CreateSSLOptionsGroup());
|
layout->addWidget(CreateDumpOptionsGroup());
|
||||||
|
layout->addWidget(CreateSecurityOptionsGroup());
|
||||||
layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding));
|
layout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding));
|
||||||
setWidget(widget);
|
setWidget(widget);
|
||||||
|
|
||||||
@ -200,6 +207,8 @@ void NetworkWidget::CreateWidgets()
|
|||||||
|
|
||||||
void NetworkWidget::ConnectWidgets()
|
void NetworkWidget::ConnectWidgets()
|
||||||
{
|
{
|
||||||
|
connect(m_dump_format_combo, QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||||
|
&NetworkWidget::OnDumpFormatComboChanged);
|
||||||
connect(m_dump_ssl_read_checkbox, &QCheckBox::stateChanged, [](int state) {
|
connect(m_dump_ssl_read_checkbox, &QCheckBox::stateChanged, [](int state) {
|
||||||
Config::SetBaseOrCurrent(Config::MAIN_NETWORK_SSL_DUMP_READ, state == Qt::Checked);
|
Config::SetBaseOrCurrent(Config::MAIN_NETWORK_SSL_DUMP_READ, state == Qt::Checked);
|
||||||
});
|
});
|
||||||
@ -215,8 +224,10 @@ void NetworkWidget::ConnectWidgets()
|
|||||||
connect(m_verify_certificates_checkbox, &QCheckBox::stateChanged, [](int state) {
|
connect(m_verify_certificates_checkbox, &QCheckBox::stateChanged, [](int state) {
|
||||||
Config::SetBaseOrCurrent(Config::MAIN_NETWORK_SSL_VERIFY_CERTIFICATES, state == Qt::Checked);
|
Config::SetBaseOrCurrent(Config::MAIN_NETWORK_SSL_VERIFY_CERTIFICATES, state == Qt::Checked);
|
||||||
});
|
});
|
||||||
connect(m_dump_as_pcap_checkbox, &QCheckBox::stateChanged, [](int state) {
|
connect(m_open_dump_folder, &QPushButton::pressed, [] {
|
||||||
Config::SetBaseOrCurrent(Config::MAIN_NETWORK_DUMP_AS_PCAP, state == Qt::Checked);
|
const std::string location = File::GetUserPath(D_DUMPSSL_IDX);
|
||||||
|
const QUrl url = QUrl::fromLocalFile(QString::fromStdString(location));
|
||||||
|
QDesktopServices::openUrl(url);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,13 +266,30 @@ void NetworkWidget::Update()
|
|||||||
}
|
}
|
||||||
m_ssl_table->resizeColumnsToContents();
|
m_ssl_table->resizeColumnsToContents();
|
||||||
|
|
||||||
m_dump_ssl_read_checkbox->setChecked(Config::Get(Config::MAIN_NETWORK_SSL_DUMP_READ));
|
const bool is_pcap = Config::Get(Config::MAIN_NETWORK_DUMP_AS_PCAP);
|
||||||
m_dump_ssl_write_checkbox->setChecked(Config::Get(Config::MAIN_NETWORK_SSL_DUMP_WRITE));
|
const bool is_ssl_read = Config::Get(Config::MAIN_NETWORK_SSL_DUMP_READ);
|
||||||
|
const bool is_ssl_write = Config::Get(Config::MAIN_NETWORK_SSL_DUMP_WRITE);
|
||||||
|
|
||||||
|
m_dump_ssl_read_checkbox->setChecked(is_ssl_read);
|
||||||
|
m_dump_ssl_write_checkbox->setChecked(is_ssl_write);
|
||||||
m_dump_root_ca_checkbox->setChecked(Config::Get(Config::MAIN_NETWORK_SSL_DUMP_ROOT_CA));
|
m_dump_root_ca_checkbox->setChecked(Config::Get(Config::MAIN_NETWORK_SSL_DUMP_ROOT_CA));
|
||||||
m_dump_peer_cert_checkbox->setChecked(Config::Get(Config::MAIN_NETWORK_SSL_DUMP_PEER_CERT));
|
m_dump_peer_cert_checkbox->setChecked(Config::Get(Config::MAIN_NETWORK_SSL_DUMP_PEER_CERT));
|
||||||
m_verify_certificates_checkbox->setChecked(
|
m_verify_certificates_checkbox->setChecked(
|
||||||
Config::Get(Config::MAIN_NETWORK_SSL_VERIFY_CERTIFICATES));
|
Config::Get(Config::MAIN_NETWORK_SSL_VERIFY_CERTIFICATES));
|
||||||
m_dump_as_pcap_checkbox->setChecked(Config::Get(Config::MAIN_NETWORK_DUMP_AS_PCAP));
|
|
||||||
|
const int combo_index = int([is_pcap, is_ssl_read, is_ssl_write]() -> FormatComboId {
|
||||||
|
if (is_pcap)
|
||||||
|
return FormatComboId::PCAP;
|
||||||
|
else if (is_ssl_read && is_ssl_write)
|
||||||
|
return FormatComboId::BinarySSL;
|
||||||
|
else if (is_ssl_read)
|
||||||
|
return FormatComboId::BinarySSLRead;
|
||||||
|
else if (is_ssl_write)
|
||||||
|
return FormatComboId::BinarySSLWrite;
|
||||||
|
else
|
||||||
|
return FormatComboId::None;
|
||||||
|
}());
|
||||||
|
m_dump_format_combo->setCurrentIndex(combo_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
QGroupBox* NetworkWidget::CreateSocketTableGroup()
|
QGroupBox* NetworkWidget::CreateSocketTableGroup()
|
||||||
@ -309,28 +337,98 @@ QGroupBox* NetworkWidget::CreateSSLContextGroup()
|
|||||||
return ssl_context_group;
|
return ssl_context_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
QGroupBox* NetworkWidget::CreateSSLOptionsGroup()
|
QGroupBox* NetworkWidget::CreateDumpOptionsGroup()
|
||||||
{
|
{
|
||||||
QGroupBox* ssl_options_group = new QGroupBox(tr("SSL options"));
|
auto* dump_options_group = new QGroupBox(tr("Dump options"));
|
||||||
QGridLayout* ssl_options_layout = new QGridLayout;
|
auto* dump_options_layout = new QVBoxLayout;
|
||||||
ssl_options_group->setLayout(ssl_options_layout);
|
dump_options_group->setLayout(dump_options_layout);
|
||||||
|
|
||||||
m_dump_ssl_read_checkbox = new QCheckBox(tr("Dump SSL read"));
|
m_dump_format_combo = CreateDumpFormatCombo();
|
||||||
m_dump_ssl_write_checkbox = new QCheckBox(tr("Dump SSL write"));
|
m_dump_format_combo->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
|
m_dump_ssl_read_checkbox = new QCheckBox(tr("Dump decrypted SSL reads"));
|
||||||
|
m_dump_ssl_write_checkbox = new QCheckBox(tr("Dump decrypted SSL writes"));
|
||||||
// i18n: CA stands for certificate authority
|
// i18n: CA stands for certificate authority
|
||||||
m_dump_root_ca_checkbox = new QCheckBox(tr("Dump root CA"));
|
m_dump_root_ca_checkbox = new QCheckBox(tr("Dump root CA certificates"));
|
||||||
m_dump_peer_cert_checkbox = new QCheckBox(tr("Dump peer certificates"));
|
m_dump_peer_cert_checkbox = new QCheckBox(tr("Dump peer certificates"));
|
||||||
m_verify_certificates_checkbox = new QCheckBox(tr("Verify certificates"));
|
m_open_dump_folder = new QPushButton(tr("Open dump folder"));
|
||||||
// i18n: PCAP is a file format
|
m_open_dump_folder->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||||
m_dump_as_pcap_checkbox = new QCheckBox(tr("Dump as PCAP"));
|
|
||||||
|
|
||||||
ssl_options_layout->addWidget(m_dump_ssl_read_checkbox, 0, 0);
|
auto* combo_label = new QLabel(tr("Network dump format:"));
|
||||||
ssl_options_layout->addWidget(m_dump_ssl_write_checkbox, 1, 0);
|
combo_label->setBuddy(m_dump_format_combo);
|
||||||
ssl_options_layout->addWidget(m_verify_certificates_checkbox, 2, 0);
|
auto* combo_layout = new QHBoxLayout;
|
||||||
ssl_options_layout->addWidget(m_dump_root_ca_checkbox, 0, 1);
|
combo_layout->addWidget(combo_label);
|
||||||
ssl_options_layout->addWidget(m_dump_peer_cert_checkbox, 1, 1);
|
const int combo_label_space =
|
||||||
ssl_options_layout->addWidget(m_dump_as_pcap_checkbox, 2, 1);
|
combo_label->fontMetrics().boundingRect(QStringLiteral("__")).width();
|
||||||
|
combo_layout->addItem(new QSpacerItem(combo_label_space, 0));
|
||||||
|
combo_layout->addWidget(m_dump_format_combo);
|
||||||
|
combo_layout->addStretch();
|
||||||
|
dump_options_layout->addLayout(combo_layout);
|
||||||
|
|
||||||
ssl_options_layout->setSpacing(1);
|
dump_options_layout->addWidget(m_dump_ssl_read_checkbox);
|
||||||
return ssl_options_group;
|
dump_options_layout->addWidget(m_dump_ssl_write_checkbox);
|
||||||
|
dump_options_layout->addWidget(m_dump_root_ca_checkbox);
|
||||||
|
dump_options_layout->addWidget(m_dump_peer_cert_checkbox);
|
||||||
|
dump_options_layout->addWidget(m_open_dump_folder);
|
||||||
|
|
||||||
|
dump_options_layout->setSpacing(1);
|
||||||
|
return dump_options_group;
|
||||||
|
}
|
||||||
|
|
||||||
|
QGroupBox* NetworkWidget::CreateSecurityOptionsGroup()
|
||||||
|
{
|
||||||
|
auto* security_options_group = new QGroupBox(tr("Security options"));
|
||||||
|
auto* security_options_layout = new QVBoxLayout;
|
||||||
|
security_options_group->setLayout(security_options_layout);
|
||||||
|
|
||||||
|
m_verify_certificates_checkbox = new QCheckBox(tr("Verify certificates"));
|
||||||
|
security_options_layout->addWidget(m_verify_certificates_checkbox);
|
||||||
|
|
||||||
|
security_options_layout->setSpacing(1);
|
||||||
|
return security_options_group;
|
||||||
|
}
|
||||||
|
|
||||||
|
QComboBox* NetworkWidget::CreateDumpFormatCombo()
|
||||||
|
{
|
||||||
|
auto* combo = new QComboBox();
|
||||||
|
|
||||||
|
combo->insertItem(int(FormatComboId::None), tr("None"));
|
||||||
|
// i18n: PCAP is a file format
|
||||||
|
combo->insertItem(int(FormatComboId::PCAP), tr("PCAP"));
|
||||||
|
combo->insertItem(int(FormatComboId::BinarySSL), tr("Binary SSL"));
|
||||||
|
combo->insertItem(int(FormatComboId::BinarySSLRead), tr("Binary SSL (read)"));
|
||||||
|
combo->insertItem(int(FormatComboId::BinarySSLWrite), tr("Binary SSL (write)"));
|
||||||
|
|
||||||
|
return combo;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetworkWidget::OnDumpFormatComboChanged(int index)
|
||||||
|
{
|
||||||
|
const auto combo_id = static_cast<FormatComboId>(index);
|
||||||
|
|
||||||
|
switch (combo_id)
|
||||||
|
{
|
||||||
|
case FormatComboId::PCAP:
|
||||||
|
break;
|
||||||
|
case FormatComboId::BinarySSL:
|
||||||
|
m_dump_ssl_read_checkbox->setChecked(true);
|
||||||
|
m_dump_ssl_write_checkbox->setChecked(true);
|
||||||
|
break;
|
||||||
|
case FormatComboId::BinarySSLRead:
|
||||||
|
m_dump_ssl_read_checkbox->setChecked(true);
|
||||||
|
m_dump_ssl_write_checkbox->setChecked(false);
|
||||||
|
break;
|
||||||
|
case FormatComboId::BinarySSLWrite:
|
||||||
|
m_dump_ssl_read_checkbox->setChecked(false);
|
||||||
|
m_dump_ssl_write_checkbox->setChecked(true);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
m_dump_ssl_read_checkbox->setChecked(false);
|
||||||
|
m_dump_ssl_write_checkbox->setChecked(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Enable raw or decrypted SSL choices for PCAP
|
||||||
|
const bool is_pcap = combo_id == FormatComboId::PCAP;
|
||||||
|
m_dump_ssl_read_checkbox->setEnabled(is_pcap);
|
||||||
|
m_dump_ssl_write_checkbox->setEnabled(is_pcap);
|
||||||
|
Config::SetBaseOrCurrent(Config::MAIN_NETWORK_DUMP_AS_PCAP, is_pcap);
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,9 @@
|
|||||||
|
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QCloseEvent;
|
class QCloseEvent;
|
||||||
|
class QComboBox;
|
||||||
class QGroupBox;
|
class QGroupBox;
|
||||||
|
class QPushButton;
|
||||||
class QShowEvent;
|
class QShowEvent;
|
||||||
class QTableWidget;
|
class QTableWidget;
|
||||||
class QTableWidgetItem;
|
class QTableWidgetItem;
|
||||||
@ -34,14 +36,28 @@ private:
|
|||||||
|
|
||||||
QGroupBox* CreateSocketTableGroup();
|
QGroupBox* CreateSocketTableGroup();
|
||||||
QGroupBox* CreateSSLContextGroup();
|
QGroupBox* CreateSSLContextGroup();
|
||||||
QGroupBox* CreateSSLOptionsGroup();
|
QGroupBox* CreateDumpOptionsGroup();
|
||||||
|
QGroupBox* CreateSecurityOptionsGroup();
|
||||||
|
QComboBox* CreateDumpFormatCombo();
|
||||||
|
|
||||||
|
void OnDumpFormatComboChanged(int index);
|
||||||
|
|
||||||
|
enum class FormatComboId : int
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
PCAP,
|
||||||
|
BinarySSL,
|
||||||
|
BinarySSLRead,
|
||||||
|
BinarySSLWrite,
|
||||||
|
};
|
||||||
|
|
||||||
QTableWidget* m_socket_table;
|
QTableWidget* m_socket_table;
|
||||||
QTableWidget* m_ssl_table;
|
QTableWidget* m_ssl_table;
|
||||||
|
QComboBox* m_dump_format_combo;
|
||||||
QCheckBox* m_dump_ssl_read_checkbox;
|
QCheckBox* m_dump_ssl_read_checkbox;
|
||||||
QCheckBox* m_dump_ssl_write_checkbox;
|
QCheckBox* m_dump_ssl_write_checkbox;
|
||||||
QCheckBox* m_dump_root_ca_checkbox;
|
QCheckBox* m_dump_root_ca_checkbox;
|
||||||
QCheckBox* m_dump_peer_cert_checkbox;
|
QCheckBox* m_dump_peer_cert_checkbox;
|
||||||
QCheckBox* m_verify_certificates_checkbox;
|
QCheckBox* m_verify_certificates_checkbox;
|
||||||
QCheckBox* m_dump_as_pcap_checkbox;
|
QPushButton* m_open_dump_folder;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user