tambahannya

This commit is contained in:
bipproduction
2025-09-25 14:22:55 +08:00
parent cd08c13ecf
commit 7e4791dc4b
2 changed files with 116 additions and 106 deletions

View File

@@ -97,14 +97,24 @@ async function fetchFrp(config: FrpConfig, url: string): Promise<ProxyResponse>
function sortProxies(proxies: Proxy[]): Proxy[] {
return [...proxies].sort((a, b) => {
// Urutan utama: status (online/running duluan)
const order = (status?: string) =>
status?.toLowerCase() === "online" || status?.toLowerCase() === "running"
? 0
: 1;
return order(a.status) - order(b.status);
const statusDiff = order(a.status) - order(b.status);
if (statusDiff !== 0) return statusDiff;
// Jika status sama, urutkan berdasarkan remotePort numerik (ascending)
const portA = a.conf?.remotePort ?? Number.MAX_SAFE_INTEGER;
const portB = b.conf?.remotePort ?? Number.MAX_SAFE_INTEGER;
return portA - portB;
});
}
function formatTable(headers: string[], rows: string[][]): string {
const allRows = [headers, ...rows];
const colWidths = headers.map((_, i) =>

View File

@@ -1,6 +1,6 @@
{
"name": "g3n",
"version": "1.0.8",
"version": "1.0.9",
"type": "module",
"bin": {
"g3n": "./bin/g3n.ts"