mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2026-01-11 08:19:05 +08:00
add process in connection list
This commit is contained in:
parent
60c9b4a8b9
commit
f1c12e05b3
@ -1,18 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
_ "unsafe"
|
||||
|
||||
"nekobox_core/internal/boxbox"
|
||||
"nekobox_core/internal/boxmain"
|
||||
_ "nekobox_core/internal/distro/all"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("sing-box:", boxbox.Version)
|
||||
fmt.Println()
|
||||
|
||||
// sing-box
|
||||
boxmain.Main()
|
||||
}
|
||||
@ -130,7 +130,13 @@ inline QString WrapIPV6Host(QString &str) {
|
||||
inline QString DisplayAddress(QString serverAddress, int serverPort) {
|
||||
if (serverAddress.isEmpty() && serverPort == 0) return {};
|
||||
return WrapIPV6Host(serverAddress) + ":" + Int2String(serverPort);
|
||||
};
|
||||
}
|
||||
|
||||
inline QString DisplayDest(const QString& dest, QString domain)
|
||||
{
|
||||
if (domain.isEmpty() || dest.split(":").first() == domain) return domain;
|
||||
return dest + " (" + domain + ")";
|
||||
}
|
||||
|
||||
// Format & Misc
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ namespace NekoGui_traffic
|
||||
Default,
|
||||
ByDownload,
|
||||
ByUpload,
|
||||
ByDomain
|
||||
ByProcess
|
||||
};
|
||||
|
||||
class ConnectionMetadata
|
||||
|
||||
@ -343,7 +343,7 @@
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Destination</string>
|
||||
<string>Destination (Domain)</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Click To Disable Sorting</string>
|
||||
@ -351,10 +351,10 @@
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>Domain</string>
|
||||
<string>Process</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Click To Sort By Domain</string>
|
||||
<string>Click To Sort By Process</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
|
||||
@ -473,6 +473,10 @@ namespace NekoGui {
|
||||
if (dataStore->spmode_vpn) {
|
||||
routeObj["auto_detect_interface"] = true;
|
||||
}
|
||||
if (dataStore->enable_stats && !status->forTest)
|
||||
{
|
||||
routeObj["find_process"] = true;
|
||||
}
|
||||
if (!status->forTest) routeObj["final"] = dataStore->routing->def_outbound;
|
||||
|
||||
auto routeChain = NekoGui::profileManager->GetRouteChain(NekoGui::dataStore->routing->current_route_id);
|
||||
|
||||
@ -107,12 +107,12 @@ namespace NekoGui_traffic
|
||||
return asc ? a.upload < b.upload : a.upload > b.upload;
|
||||
});
|
||||
}
|
||||
if (sort == ByDomain)
|
||||
if (sort == ByProcess)
|
||||
{
|
||||
std::sort(sorted.begin(), sorted.end(), [=](const ConnectionMetadata& a, const ConnectionMetadata& b)
|
||||
{
|
||||
if (a.domain == b.domain) return asc ? a.id > b.id : a.id < b.id;
|
||||
return asc ? a.domain > b.domain : a.domain < b.domain;
|
||||
if (a.process == b.process) return asc ? a.id > b.id : a.id < b.id;
|
||||
return asc ? a.process > b.process : a.process < b.process;
|
||||
});
|
||||
}
|
||||
runOnUiThread([=] {
|
||||
|
||||
@ -171,7 +171,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||
}
|
||||
if (index == 1)
|
||||
{
|
||||
NekoGui_traffic::connection_lister->setSort(NekoGui_traffic::ByDomain);
|
||||
NekoGui_traffic::connection_lister->setSort(NekoGui_traffic::ByProcess);
|
||||
NekoGui_traffic::connection_lister->ForceUpdate();
|
||||
}
|
||||
if (index == 4)
|
||||
@ -680,8 +680,7 @@ void MainWindow::on_commitDataRequest() {
|
||||
}
|
||||
|
||||
void MainWindow::on_menu_exit_triggered() {
|
||||
std::chrono::duration<double, std::milli> elapsed_milliseconds = std::chrono::steady_clock::now() - trayMenuTime;
|
||||
if (elapsed_milliseconds.count() < 150)
|
||||
if (std::chrono::duration<double, std::milli> elapsed_milliseconds = std::chrono::steady_clock::now() - trayMenuTime; elapsed_milliseconds.count() < 150)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -868,11 +867,11 @@ void MainWindow::UpdateConnectionList(const QMap<QString, NekoGui_traffic::Conne
|
||||
}
|
||||
|
||||
auto conn = toUpdate[key];
|
||||
// C0: Dest
|
||||
ui->connections->item(row, 0)->setText(conn.dest);
|
||||
// C0: Dest (Domain)
|
||||
ui->connections->item(row, 0)->setText(DisplayDest(conn.dest, conn.domain));
|
||||
|
||||
// C1: Domain
|
||||
ui->connections->item(row, 1)->setText(conn.domain);
|
||||
// C1: Process
|
||||
ui->connections->item(row, 1)->setText(conn.process);
|
||||
|
||||
// C2: Network
|
||||
ui->connections->item(row, 2)->setText(conn.network);
|
||||
@ -893,14 +892,14 @@ void MainWindow::UpdateConnectionList(const QMap<QString, NekoGui_traffic::Conne
|
||||
auto f0 = std::make_unique<QTableWidgetItem>();
|
||||
f0->setData(NekoGui_traffic::IDKEY, conn.id);
|
||||
|
||||
// C0: Dest
|
||||
// C0: Dest (Domain)
|
||||
auto f = f0->clone();
|
||||
f->setText(conn.dest);
|
||||
f->setText(DisplayDest(conn.dest, conn.domain));
|
||||
ui->connections->setItem(row, 0, f);
|
||||
|
||||
// C1: Domain
|
||||
// C1: Process
|
||||
f = f0->clone();
|
||||
f->setText(conn.domain);
|
||||
f->setText(conn.process);
|
||||
ui->connections->setItem(row, 1, f);
|
||||
|
||||
// C2: Network
|
||||
@ -939,14 +938,14 @@ void MainWindow::UpdateConnectionListWithRecreate(const QList<NekoGui_traffic::C
|
||||
auto f0 = std::make_unique<QTableWidgetItem>();
|
||||
f0->setData(NekoGui_traffic::IDKEY, conn.id);
|
||||
|
||||
// C0: Dest
|
||||
// C0: Dest (Domain)
|
||||
auto f = f0->clone();
|
||||
f->setText(conn.dest);
|
||||
f->setText(DisplayDest(conn.dest, conn.domain));
|
||||
ui->connections->setItem(row, 0, f);
|
||||
|
||||
// C1: Domain
|
||||
// C1: Process
|
||||
f = f0->clone();
|
||||
f->setText(conn.domain);
|
||||
f->setText(conn.process);
|
||||
ui->connections->setItem(row, 1, f);
|
||||
|
||||
// C2: Network
|
||||
|
||||
Loading…
Reference in New Issue
Block a user