tambahannya
This commit is contained in:
@@ -97,14 +97,24 @@ async function fetchFrp(config: FrpConfig, url: string): Promise<ProxyResponse>
|
|||||||
|
|
||||||
function sortProxies(proxies: Proxy[]): Proxy[] {
|
function sortProxies(proxies: Proxy[]): Proxy[] {
|
||||||
return [...proxies].sort((a, b) => {
|
return [...proxies].sort((a, b) => {
|
||||||
|
// Urutan utama: status (online/running duluan)
|
||||||
const order = (status?: string) =>
|
const order = (status?: string) =>
|
||||||
status?.toLowerCase() === "online" || status?.toLowerCase() === "running"
|
status?.toLowerCase() === "online" || status?.toLowerCase() === "running"
|
||||||
? 0
|
? 0
|
||||||
: 1;
|
: 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 {
|
function formatTable(headers: string[], rows: string[][]): string {
|
||||||
const allRows = [headers, ...rows];
|
const allRows = [headers, ...rows];
|
||||||
const colWidths = headers.map((_, i) =>
|
const colWidths = headers.map((_, i) =>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "g3n",
|
"name": "g3n",
|
||||||
"version": "1.0.8",
|
"version": "1.0.9",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"bin": {
|
"bin": {
|
||||||
"g3n": "./bin/g3n.ts"
|
"g3n": "./bin/g3n.ts"
|
||||||
|
|||||||
Reference in New Issue
Block a user