mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 12:34:37 +03:00
update fmt
This commit is contained in:
@@ -1,14 +1,20 @@
|
|||||||
#include "ProfileFilter.hpp"
|
#include "ProfileFilter.hpp"
|
||||||
|
|
||||||
namespace NekoGui {
|
namespace NekoGui {
|
||||||
|
|
||||||
|
QString ProfileFilter_ent_key(const std::shared_ptr<NekoGui::ProxyEntity> &ent, bool by_address) {
|
||||||
|
by_address &= ent->type != "custom";
|
||||||
|
return by_address ? (ent->bean->DisplayAddress() + ent->bean->DisplayType())
|
||||||
|
: ent->bean->ToJsonBytes();
|
||||||
|
}
|
||||||
|
|
||||||
void ProfileFilter::Uniq(const QList<std::shared_ptr<ProxyEntity>> &in,
|
void ProfileFilter::Uniq(const QList<std::shared_ptr<ProxyEntity>> &in,
|
||||||
QList<std::shared_ptr<ProxyEntity>> &out,
|
QList<std::shared_ptr<ProxyEntity>> &out,
|
||||||
bool by_address, bool keep_last) {
|
bool by_address, bool keep_last) {
|
||||||
QMap<QString, std::shared_ptr<ProxyEntity>> hashMap;
|
QMap<QString, std::shared_ptr<ProxyEntity>> hashMap;
|
||||||
|
|
||||||
for (const auto &ent: in) {
|
for (const auto &ent: in) {
|
||||||
QString key = by_address ? (ent->bean->DisplayAddress() + ent->bean->DisplayType())
|
QString key = ProfileFilter_ent_key(ent, by_address);
|
||||||
: ent->bean->ToJsonBytes();
|
|
||||||
if (hashMap.contains(key)) {
|
if (hashMap.contains(key)) {
|
||||||
if (keep_last) {
|
if (keep_last) {
|
||||||
out.removeAll(hashMap[key]);
|
out.removeAll(hashMap[key]);
|
||||||
@@ -29,13 +35,11 @@ namespace NekoGui {
|
|||||||
QMap<QString, std::shared_ptr<ProxyEntity>> hashMap;
|
QMap<QString, std::shared_ptr<ProxyEntity>> hashMap;
|
||||||
|
|
||||||
for (const auto &ent: src) {
|
for (const auto &ent: src) {
|
||||||
QString key = by_address ? (ent->bean->DisplayAddress() + ent->bean->DisplayType())
|
QString key = ProfileFilter_ent_key(ent, by_address);
|
||||||
: ent->bean->ToJsonBytes();
|
|
||||||
hashMap[key] = ent;
|
hashMap[key] = ent;
|
||||||
}
|
}
|
||||||
for (const auto &ent: dst) {
|
for (const auto &ent: dst) {
|
||||||
QString key = by_address ? (ent->bean->DisplayAddress() + ent->bean->DisplayType())
|
QString key = ProfileFilter_ent_key(ent, by_address);
|
||||||
: ent->bean->ToJsonBytes();
|
|
||||||
if (hashMap.contains(key)) {
|
if (hashMap.contains(key)) {
|
||||||
if (keep_last) {
|
if (keep_last) {
|
||||||
out += ent;
|
out += ent;
|
||||||
@@ -53,13 +57,11 @@ namespace NekoGui {
|
|||||||
QMap<QString, bool> hashMap;
|
QMap<QString, bool> hashMap;
|
||||||
|
|
||||||
for (const auto &ent: dst) {
|
for (const auto &ent: dst) {
|
||||||
QString key = by_address ? (ent->bean->DisplayAddress() + ent->bean->DisplayType())
|
QString key = ProfileFilter_ent_key(ent, by_address);
|
||||||
: ent->bean->ToJsonBytes();
|
|
||||||
hashMap[key] = true;
|
hashMap[key] = true;
|
||||||
}
|
}
|
||||||
for (const auto &ent: src) {
|
for (const auto &ent: src) {
|
||||||
QString key = by_address ? (ent->bean->DisplayAddress() + ent->bean->DisplayType())
|
QString key = ProfileFilter_ent_key(ent, by_address);
|
||||||
: ent->bean->ToJsonBytes();
|
|
||||||
if (!hashMap.contains(key)) out += ent;
|
if (!hashMap.contains(key)) out += ent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,16 +13,6 @@ namespace NekoGui_fmt {
|
|||||||
auto url = QUrl("https://" + linkN);
|
auto url = QUrl("https://" + linkN);
|
||||||
|
|
||||||
bool SocksHttpBean::TryParseLink(const QString &link) {
|
bool SocksHttpBean::TryParseLink(const QString &link) {
|
||||||
if (!SubStrAfter(link, "://").contains(":")) {
|
|
||||||
// v2rayN shit format
|
|
||||||
DECODE_V2RAY_N_1
|
|
||||||
|
|
||||||
if (hasRemarks) name = url.fragment(QUrl::FullyDecoded);
|
|
||||||
serverAddress = url.host();
|
|
||||||
serverPort = url.port();
|
|
||||||
username = url.userName();
|
|
||||||
password = url.password();
|
|
||||||
} else {
|
|
||||||
auto url = QUrl(link);
|
auto url = QUrl(link);
|
||||||
if (!url.isValid()) return false;
|
if (!url.isValid()) return false;
|
||||||
auto query = GetQuery(url);
|
auto query = GetQuery(url);
|
||||||
@@ -36,11 +26,19 @@ namespace NekoGui_fmt {
|
|||||||
password = url.password();
|
password = url.password();
|
||||||
if (serverPort == -1) serverPort = socks_http_type == type_HTTP ? 443 : 1080;
|
if (serverPort == -1) serverPort = socks_http_type == type_HTTP ? 443 : 1080;
|
||||||
|
|
||||||
|
// v2rayN fmt
|
||||||
|
if (password.isEmpty() && !username.isEmpty()) {
|
||||||
|
QString n = DecodeB64IfValid(username);
|
||||||
|
if (!n.isEmpty()) {
|
||||||
|
username = SubStrBefore(n, ":");
|
||||||
|
password = SubStrAfter(n, ":");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
stream->security = GetQueryValue(query, "security", "");
|
stream->security = GetQueryValue(query, "security", "");
|
||||||
stream->sni = GetQueryValue(query, "sni");
|
stream->sni = GetQueryValue(query, "sni");
|
||||||
|
|
||||||
if (link.startsWith("https")) stream->security = "tls";
|
if (link.startsWith("https")) stream->security = "tls";
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -247,16 +247,12 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
tray->setContextMenu(ui->menu_program); // 创建托盘菜单
|
tray->setContextMenu(ui->menu_program); // 创建托盘菜单
|
||||||
tray->show(); // 让托盘图标显示在系统托盘上
|
tray->show(); // 让托盘图标显示在系统托盘上
|
||||||
connect(tray, &QSystemTrayIcon::activated, this, [=](QSystemTrayIcon::ActivationReason reason) {
|
connect(tray, &QSystemTrayIcon::activated, this, [=](QSystemTrayIcon::ActivationReason reason) {
|
||||||
switch (reason) {
|
if (reason == QSystemTrayIcon::Trigger) {
|
||||||
case QSystemTrayIcon::Trigger:
|
|
||||||
if (this->isVisible()) {
|
if (this->isVisible()) {
|
||||||
hide();
|
hide();
|
||||||
} else {
|
} else {
|
||||||
ACTIVE_THIS_WINDOW
|
ACTIVE_THIS_WINDOW
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -284,7 +280,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
|||||||
a->setCheckable(true);
|
a->setCheckable(true);
|
||||||
if (NekoGui::dataStore->started_id == pf->id) a->setChecked(true);
|
if (NekoGui::dataStore->started_id == pf->id) a->setChecked(true);
|
||||||
ui->menuActive_Server->addAction(a);
|
ui->menuActive_Server->addAction(a);
|
||||||
if (++active_server_item_count == 50) break;
|
if (++active_server_item_count == 100) break;
|
||||||
}
|
}
|
||||||
// active routing
|
// active routing
|
||||||
for (const auto &old: ui->menuActive_Routing->actions()) {
|
for (const auto &old: ui->menuActive_Routing->actions()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user