mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 20:44:38 +03:00
feat: ignore subscription ssl error
This commit is contained in:
@@ -64,6 +64,7 @@ namespace NekoRay {
|
|||||||
_add(new configItem("check_include_pre", &check_include_pre, itemType::boolean));
|
_add(new configItem("check_include_pre", &check_include_pre, itemType::boolean));
|
||||||
_add(new configItem("sp_format", &system_proxy_format, itemType::string));
|
_add(new configItem("sp_format", &system_proxy_format, itemType::string));
|
||||||
_add(new configItem("sub_clear", &sub_clear, itemType::boolean));
|
_add(new configItem("sub_clear", &sub_clear, itemType::boolean));
|
||||||
|
_add(new configItem("sub_insecure", &sub_insecure, itemType::boolean));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataStore::UpdateStartedId(int id) {
|
void DataStore::UpdateStartedId(int id) {
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ namespace NekoRay {
|
|||||||
QString user_agent = "Nekoray/1.0 (Prefer Clash Format)";
|
QString user_agent = "Nekoray/1.0 (Prefer Clash Format)";
|
||||||
bool sub_use_proxy = false;
|
bool sub_use_proxy = false;
|
||||||
bool sub_clear = false;
|
bool sub_clear = false;
|
||||||
|
bool sub_insecure = false;
|
||||||
|
|
||||||
// Security
|
// Security
|
||||||
bool insecure_hint = true;
|
bool insecure_hint = true;
|
||||||
|
|||||||
@@ -35,7 +35,20 @@ namespace Qv2ray::common::network {
|
|||||||
// Set attribute
|
// Set attribute
|
||||||
request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
|
request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
|
||||||
request.setHeader(QNetworkRequest::KnownHeaders::UserAgentHeader, NekoRay::dataStore->user_agent);
|
request.setHeader(QNetworkRequest::KnownHeaders::UserAgentHeader, NekoRay::dataStore->user_agent);
|
||||||
|
if (NekoRay::dataStore->sub_insecure) {
|
||||||
|
QSslConfiguration c;
|
||||||
|
c.setPeerVerifyMode(QSslSocket::PeerVerifyMode::VerifyNone);
|
||||||
|
request.setSslConfiguration(c);
|
||||||
|
}
|
||||||
|
//
|
||||||
auto _reply = accessManager.get(request);
|
auto _reply = accessManager.get(request);
|
||||||
|
connect(_reply, &QNetworkReply::sslErrors, _reply, [](const QList<QSslError> &errors) {
|
||||||
|
QStringList error_str;
|
||||||
|
for (const auto &err: errors) {
|
||||||
|
error_str << err.errorString();
|
||||||
|
}
|
||||||
|
MW_show_log(QString("SSL Errors: %1 %2").arg(error_str.join(","), NekoRay::dataStore->sub_insecure ? "(Ignored)" : ""));
|
||||||
|
});
|
||||||
//
|
//
|
||||||
{
|
{
|
||||||
QEventLoop loop;
|
QEventLoop loop;
|
||||||
@@ -43,8 +56,10 @@ namespace Qv2ray::common::network {
|
|||||||
loop.exec();
|
loop.exec();
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
return NekoHTTPResponse{_reply->error() == QNetworkReply::NetworkError::NoError ? "" : _reply->errorString(),
|
auto result = NekoHTTPResponse{_reply->error() == QNetworkReply::NetworkError::NoError ? "" : _reply->errorString(),
|
||||||
_reply->readAll(), _reply->rawHeaderPairs()};
|
_reply->readAll(), _reply->rawHeaderPairs()};
|
||||||
|
_reply->deleteLater();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString NetworkRequestHelper::GetHeader(const QList<QPair<QByteArray, QByteArray>> &header, const QString &name) {
|
QString NetworkRequestHelper::GetHeader(const QList<QPair<QByteArray, QByteArray>> &header, const QString &name) {
|
||||||
|
|||||||
@@ -199,6 +199,10 @@
|
|||||||
<source>Clear servers before updating subscription</source>
|
<source>Clear servers before updating subscription</source>
|
||||||
<translation>更新订阅前清除服务器</translation>
|
<translation>更新订阅前清除服务器</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Ignore TLS errors when updating subscription</source>
|
||||||
|
<translation>更新订阅时忽略 TLS 错误</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>DialogEditGroup</name>
|
<name>DialogEditGroup</name>
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent)
|
|||||||
ui->user_agent->setText(NekoRay::dataStore->user_agent);
|
ui->user_agent->setText(NekoRay::dataStore->user_agent);
|
||||||
D_LOAD_BOOL(sub_use_proxy)
|
D_LOAD_BOOL(sub_use_proxy)
|
||||||
D_LOAD_BOOL(sub_clear)
|
D_LOAD_BOOL(sub_clear)
|
||||||
|
D_LOAD_BOOL(sub_insecure)
|
||||||
|
|
||||||
// Core
|
// Core
|
||||||
|
|
||||||
@@ -266,6 +267,7 @@ void DialogBasicSettings::accept() {
|
|||||||
NekoRay::dataStore->user_agent = ui->user_agent->text();
|
NekoRay::dataStore->user_agent = ui->user_agent->text();
|
||||||
D_SAVE_BOOL(sub_use_proxy)
|
D_SAVE_BOOL(sub_use_proxy)
|
||||||
D_SAVE_BOOL(sub_clear)
|
D_SAVE_BOOL(sub_clear)
|
||||||
|
D_SAVE_BOOL(sub_insecure)
|
||||||
|
|
||||||
// Core
|
// Core
|
||||||
|
|
||||||
|
|||||||
@@ -407,16 +407,6 @@
|
|||||||
<string>Subscription</string>
|
<string>Subscription</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_3">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QCheckBox" name="sub_use_proxy">
|
|
||||||
<property name="text">
|
|
||||||
<string>Use proxy when updating subscription</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="1">
|
|
||||||
<widget class="MyLineEdit" name="user_agent"/>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -424,13 +414,30 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="0" column="1">
|
||||||
|
<widget class="MyLineEdit" name="user_agent"/>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
<widget class="QCheckBox" name="sub_clear">
|
<widget class="QCheckBox" name="sub_clear">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Clear servers before updating subscription</string>
|
<string>Clear servers before updating subscription</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QCheckBox" name="sub_use_proxy">
|
||||||
|
<property name="text">
|
||||||
|
<string>Use proxy when updating subscription</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QCheckBox" name="sub_insecure">
|
||||||
|
<property name="text">
|
||||||
|
<string>Ignore TLS errors when updating subscription</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QWidget" name="tab_4">
|
<widget class="QWidget" name="tab_4">
|
||||||
|
|||||||
@@ -1101,7 +1101,6 @@ void MainWindow::display_qr_link(bool nkrFormat) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_menu_scan_qr_triggered() {
|
void MainWindow::on_menu_scan_qr_triggered() {
|
||||||
NO_ADD_TO_SUBSCRIPTION_GROUP
|
|
||||||
#ifndef NKR_NO_EXTERNAL
|
#ifndef NKR_NO_EXTERNAL
|
||||||
using namespace ZXingQt;
|
using namespace ZXingQt;
|
||||||
|
|
||||||
@@ -1124,6 +1123,8 @@ void MainWindow::on_menu_scan_qr_triggered() {
|
|||||||
if (text.isEmpty()) {
|
if (text.isEmpty()) {
|
||||||
MessageBoxInfo(software_name, tr("QR Code not found"));
|
MessageBoxInfo(software_name, tr("QR Code not found"));
|
||||||
} else {
|
} else {
|
||||||
|
show_log_impl("QR Code Result:\n" + text);
|
||||||
|
NO_ADD_TO_SUBSCRIPTION_GROUP
|
||||||
NekoRay::sub::groupUpdater->AsyncUpdate(text);
|
NekoRay::sub::groupUpdater->AsyncUpdate(text);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user