mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 12:34:37 +03:00
update user-agent
This commit is contained in:
@@ -38,7 +38,7 @@ namespace NekoGui_network {
|
|||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0))
|
||||||
request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
|
request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
|
||||||
#endif
|
#endif
|
||||||
request.setHeader(QNetworkRequest::KnownHeaders::UserAgentHeader, NekoGui::dataStore->user_agent);
|
request.setHeader(QNetworkRequest::KnownHeaders::UserAgentHeader, NekoGui::dataStore->GetUserAgent());
|
||||||
if (NekoGui::dataStore->sub_insecure) {
|
if (NekoGui::dataStore->sub_insecure) {
|
||||||
QSslConfiguration c;
|
QSslConfiguration c;
|
||||||
c.setPeerVerifyMode(QSslSocket::PeerVerifyMode::VerifyNone);
|
c.setPeerVerifyMode(QSslSocket::PeerVerifyMode::VerifyNone);
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ namespace NekoGui {
|
|||||||
_add(new configItem("extraCore", dynamic_cast<JsonStore *>(extraCore), itemType::jsonStore));
|
_add(new configItem("extraCore", dynamic_cast<JsonStore *>(extraCore), itemType::jsonStore));
|
||||||
_add(new configItem("inbound_auth", dynamic_cast<JsonStore *>(inbound_auth), itemType::jsonStore));
|
_add(new configItem("inbound_auth", dynamic_cast<JsonStore *>(inbound_auth), itemType::jsonStore));
|
||||||
|
|
||||||
_add(new configItem("user_agent", &user_agent, itemType::string));
|
_add(new configItem("user_agent2", &user_agent, itemType::string));
|
||||||
_add(new configItem("test_url", &test_latency_url, itemType::string));
|
_add(new configItem("test_url", &test_latency_url, itemType::string));
|
||||||
_add(new configItem("test_url_dl", &test_download_url, itemType::string));
|
_add(new configItem("test_url_dl", &test_download_url, itemType::string));
|
||||||
_add(new configItem("test_dl_timeout", &test_download_timeout, itemType::integer));
|
_add(new configItem("test_dl_timeout", &test_download_timeout, itemType::integer));
|
||||||
@@ -304,6 +304,22 @@ namespace NekoGui {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString DataStore::GetUserAgent(bool isDefault) const {
|
||||||
|
if (user_agent.isEmpty()) {
|
||||||
|
isDefault = true;
|
||||||
|
}
|
||||||
|
if (isDefault) {
|
||||||
|
QString version = SubStrBefore(NKR_VERSION, "-");
|
||||||
|
if (!version.contains(".")) version = "2.0";
|
||||||
|
if (IS_NEKO_BOX) {
|
||||||
|
return "NekoBox/PC/" + version + " (Prefer ClashMeta Format)";
|
||||||
|
} else {
|
||||||
|
return "NekoRay/PC/" + version + " (Prefer ClashMeta Format)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return user_agent;
|
||||||
|
}
|
||||||
|
|
||||||
// preset routing
|
// preset routing
|
||||||
Routing::Routing(int preset) : JsonStore() {
|
Routing::Routing(int preset) : JsonStore() {
|
||||||
if (preset == 1) {
|
if (preset == 1) {
|
||||||
|
|||||||
@@ -179,6 +179,8 @@ namespace NekoGui {
|
|||||||
DataStore();
|
DataStore();
|
||||||
|
|
||||||
void UpdateStartedId(int id);
|
void UpdateStartedId(int id);
|
||||||
|
|
||||||
|
QString GetUserAgent(bool isDefault = false) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern DataStore *dataStore;
|
extern DataStore *dataStore;
|
||||||
|
|||||||
@@ -263,16 +263,6 @@ int main(int argc, char* argv[]) {
|
|||||||
MW_dialog_message("", "Raise");
|
MW_dialog_message("", "Raise");
|
||||||
});
|
});
|
||||||
|
|
||||||
// Do preset update
|
|
||||||
if (NekoGui::dataStore->user_agent.isEmpty() || NekoGui::dataStore->user_agent.startsWith("Nekoray/1.0") || NekoGui::dataStore->user_agent.startsWith("ClashForAndroid")) {
|
|
||||||
if (IS_NEKO_BOX) {
|
|
||||||
NekoGui::dataStore->user_agent = "NekoBox/PC/2.0 (Prefer ClashMeta Format)";
|
|
||||||
} else {
|
|
||||||
NekoGui::dataStore->user_agent = "NekoRay/PC/2.0 (Prefer ClashMeta Format)";
|
|
||||||
}
|
|
||||||
NekoGui::dataStore->Save();
|
|
||||||
}
|
|
||||||
|
|
||||||
UI_InitMainWindow();
|
UI_InitMainWindow();
|
||||||
return QApplication::exec();
|
return QApplication::exec();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent)
|
|||||||
// Subscription
|
// Subscription
|
||||||
|
|
||||||
ui->user_agent->setText(NekoGui::dataStore->user_agent);
|
ui->user_agent->setText(NekoGui::dataStore->user_agent);
|
||||||
|
ui->user_agent->setPlaceholderText(NekoGui::dataStore->GetUserAgent(true));
|
||||||
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)
|
D_LOAD_BOOL(sub_insecure)
|
||||||
|
|||||||
Reference in New Issue
Block a user