Skip to content

A modern and elegant dashboard for network traffic visualization and analysis.

feat: Introduce per-proxy traffic breakdown and detailed IP information for domains and IPs.

luolei9f7814bcfc97
diff --git a/apps/collector/src/api.ts b/apps/collector/src/api.ts
index eb6947f..3caeb7f 100644
--- a/apps/collector/src/api.ts
+++ b/apps/collector/src/api.ts
@@ -110,6 +110,61 @@ export class APIServer {
return this.db.getIPStats(backendId, parseInt(limit as string) || 50);
});
+ // Get per-proxy traffic breakdown for a specific domain
+ app.get('/api/stats/domains/proxy-stats', async (request, reply) => {
+ const backendId = getBackendId(request);
+
+ if (backendId === null) {
+ return reply.status(404).send({ error: 'No backend specified or active' });
+ }
+
+ const { domain } = request.query as { domain?: string };
+ if (!domain) {
+ return reply.status(400).send({ error: 'Domain parameter is required' });
+ }
+
+ return this.db.getDomainProxyStats(backendId, domain);
+ });
+
+ // Get IP details for a specific domain (includes geoIP and traffic)
+ app.get('/api/stats/domains/ip-details', async (request, reply) => {
+ const backendId = getBackendId(request);
+
+ if (backendId === null) {
+ return reply.status(404).send({ error: 'No backend specified or active' });
+ }
+
+ const { domain } = request.query as { domain?: string };
+ if (!domain) {
+ return reply.status(400).send({ error: 'Domain parameter is required' });
+ }
+
+ // Get the domain's IPs directly from database
+ const domainData = this.db.getDomainByName(backendId, domain);
+ if (!domainData || !domainData.ips || domainData.ips.length === 0) {
+ return [];
+ }
+
+ // Get IP details
+ return this.db.getIPStatsByIPs(backendId, domainData.ips);
+ });
+
+ // Get per-proxy traffic breakdown for a specific IP
+ app.get('/api/stats/ips/proxy-stats', async (request, reply) => {
+ const backendId = getBackendId(request);
+
+ if (backendId === null) {
+ return reply.status(404).send({ error: 'No backend specified or active' });
+ }
+
+ const { ip } = request.query as { ip?: string };
+ if (!ip) {
+ return reply.status(400).send({ error: 'IP parameter is required' });
+ }
+
+ return this.db.getIPProxyStats(backendId, ip);
+ });
+
// Get proxy/chain statistics for a specific backend
app.get('/api/stats/proxies', async (request, reply) => {
const backendId = getBackendId(request);
diff --git a/apps/collector/src/db.ts b/apps/collector/src/db.ts
index 467d3a4..db9e11c 100644
--- a/apps/collector/src/db.ts
+++ b/apps/collector/src/db.ts
@@ -1,7 +1,7 @@
import Database from 'better-sqlite3';
import path from 'path';
import fs from 'fs';
-import type { Connection, DomainStats, IPStats, HourlyStats, DailyStats, ProxyStats, RuleStats } from '@clashmaster/shared';
+import type { Connection, DomainStats, IPStats, HourlyStats, DailyStats, ProxyStats, RuleStats, ProxyTrafficStats } from '@clashmaster/shared';
export interface TrafficUpdate {
domain: string;
@@ -64,6 +64,7 @@ export class StatsDatabase {
last_seen DATETIME,
asn TEXT,
geoip TEXT,
+ chains TEXT,
PRIMARY KEY (backend_id, ip),
FOREIGN KEY (backend_id) REFERENCES backend_configs(id) ON DELETE CASCADE
);
@@ -245,6 +246,15 @@ export class StatsDatabase {
console.log('[DB] Adding listening column to backend_configs...');
this.db.exec(`ALTER TABLE backend_configs ADD COLUMN listening BOOLEAN DEFAULT 1;`);
}
+
+ // Check if ip_stats has chains column (added for proxy display per IP)
+ const ipStatsInfo = this.db.prepare(`PRAGMA table_info(ip_stats)`).all() as { name: string }[];
+ const hasIPChains = ipStatsInfo.some(col => col.name === 'chains');
+
+ if (!hasIPChains) {
+ console.log('[DB] Adding chains column to ip_stats...');
+ this.db.exec(`ALTER TABLE ip_stats ADD COLUMN chains TEXT;`);
+ }
}
private performMigration() {
@@ -305,6 +315,7 @@ export class StatsDatabase {
last_seen DATETIME,
asn TEXT,
geoip TEXT,
+ chains TEXT,
PRIMARY KEY (backend_id, ip),
FOREIGN KEY (backend_id) REFERENCES backend_configs(id) ON DELETE CASCADE
);
@@ -312,7 +323,7 @@ export class StatsDatabase {
this.db.exec(`
INSERT INTO ip_stats_new
SELECT ${defaultBackendId} as backend_id, ip, domains, total_upload, total_download,
- total_connections, last_seen, asn, geoip
+ total_connections, last_seen, asn, geoip, NULL
FROM ip_stats;
`);
this.db.exec(`DROP TABLE ip_stats;`);
@@ -511,8 +522,8 @@ export class StatsDatabase {
// Update IP stats with backend_id
const ipStmt = this.db.prepare(`
- INSERT INTO ip_stats (backend_id, ip, domains, total_upload, total_download, total_connections, last_seen)
- VALUES (@backendId, @ip, @domain, @upload, @download, 1, @timestamp)
+ INSERT INTO ip_stats (backend_id, ip, domains, total_upload, total_download, total_connections, last_seen, chains)
+ VALUES (@backendId, @ip, @domain, @upload, @download, 1, @timestamp, @chain)
ON CONFLICT(backend_id, ip) DO UPDATE SET
domains = CASE
WHEN ip_stats.domains IS NULL THEN @domain
@@ -522,7 +533,12 @@ export class StatsDatabase {
total_upload = total_upload + @upload,
total_download = total_download + @download,
total_connections = total_connections + 1,
- last_seen = @timestamp
+ last_seen = @timestamp,
+ chains = CASE
+ WHEN ip_stats.chains IS NULL THEN @chain
+ WHEN INSTR(ip_stats.chains, @chain) > 0 THEN ip_stats.chains
+ ELSE ip_stats.chains || ',' || @chain
+ END
`);
ipStmt.run({
backendId,
@@ -530,7 +546,8 @@ export class StatsDatabase {
domain: update.domain || 'unknown',
upload: update.upload,
download: update.download,
- timestamp
+ timestamp,
+ chain: update.chain
});
// Update proxy stats with backend_id
@@ -611,6 +628,35 @@ export class StatsDatabase {
transaction();
}
+ // Get a specific domain by name
+ getDomainByName(backendId: number, domain: string): DomainStats | null {
+ const stmt = this.db.prepare(`
+ SELECT domain, total_upload as totalUpload, total_download as totalDownload,
+ total_connections as totalConnections, last_seen as lastSeen, ips, rules, chains
+ FROM domain_stats
+ WHERE backend_id = ? AND domain = ?
+ `);
+ const row = stmt.get(backendId, domain) as {
+ domain: string;
+ totalUpload: number;
+ totalDownload: number;
+ totalConnections: number;
+ lastSeen: string;
+ ips: string;
+ rules: string | null;
+ chains: string | null;
+ } | undefined;
+
+ if (!row) return null;
+
+ return {
+ ...row,
+ ips: row.ips ? row.ips.split(',') : [],
+ rules: row.rules ? row.rules.split(',') : [],
+ chains: row.chains ? row.chains.split(',') : [],
+ } as DomainStats;
+ }
+
// Get all domain stats for a specific backend
getDomainStats(backendId: number, limit = 100): DomainStats[] {
const stmt = this.db.prepare(`
@@ -640,6 +686,60 @@ export class StatsDatabase {
})) as DomainStats[];
}
+ // Get IP stats for specific IPs (used for domain IP details)
+ getIPStatsByIPs(backendId: number, ips: string[]): IPStats[] {
+ if (ips.length === 0) return [];
+
+ const placeholders = ips.map(() => '?').join(',');
+ const stmt = this.db.prepare(`
+ SELECT
+ i.ip,
+ i.domains,
+ i.total_upload as totalUpload,
+ i.total_download as totalDownload,
+ i.total_connections as totalConnections,
+ i.last_seen as lastSeen,
+ COALESCE(i.asn, g.asn) as asn,
+ CASE
+ WHEN g.country IS NOT NULL THEN
+ json_array(
+ g.country,
+ COALESCE(g.country_name, g.country),
+ COALESCE(g.city, ''),
+ COALESCE(g.as_name, '')
+ )
+ WHEN i.geoip IS NOT NULL THEN
+ json(i.geoip)
+ ELSE
+ NULL
+ END as geoIP,
+ i.chains
+ FROM ip_stats i
+ LEFT JOIN geoip_cache g ON i.ip = g.ip
+ WHERE i.backend_id = ? AND i.ip IN (${placeholders})
+ ORDER BY (i.total_upload + i.total_download) DESC
+ `);
+ const rows = stmt.all(backendId, ...ips) as Array<{
+ ip: string;
+ domains: string;
+ totalUpload: number;
+ totalDownload: number;
+ totalConnections: number;
+ lastSeen: string;
+ asn: string | null;
+ geoIP: string | null;
+ chains: string | null;
+ }>;
+
+ return rows.map(row => ({
+ ...row,
+ domains: row.domains ? row.domains.split(',') : [],
+ geoIP: row.geoIP ? JSON.parse(row.geoIP).filter(Boolean) : undefined,
+ asn: row.asn || undefined,
+ chains: row.chains ? row.chains.split(',') : [],
+ })) as IPStats[];
+ }
+
// Get all IP stats for a specific backend
getIPStats(backendId: number, limit = 100): IPStats[] {
const stmt = this.db.prepare(`
@@ -654,6 +754,7 @@ export class StatsDatabase {
CASE
WHEN g.country IS NOT NULL THEN
json_array(
+ g.country,
COALESCE(g.country_name, g.country),
COALESCE(g.city, ''),
COALESCE(g.as_name, '')
@@ -662,7 +763,8 @@ export class StatsDatabase {
json(i.geoip)
ELSE
NULL
- END as geoIP
+ END as geoIP,
+ i.chains
FROM ip_stats i
LEFT JOIN geoip_cache g ON i.ip = g.ip
WHERE i.backend_id = ?
@@ -678,6 +780,7 @@ export class StatsDatabase {
lastSeen: string;
asn: string | null;
geoIP: string | null;
+ chains: string | null;
}>;
return rows.map(row => ({
@@ -685,6 +788,7 @@ export class StatsDatabase {
domains: row.domains ? row.domains.split(',') : [],
geoIP: row.geoIP ? JSON.parse(row.geoIP).filter(Boolean) : undefined,
asn: row.asn || undefined,
+ chains: row.chains ? row.chains.split(',') : [],
})) as IPStats[];
}
@@ -943,6 +1047,36 @@ export class StatsDatabase {
};
}
+ // Get per-proxy traffic breakdown for a specific domain
+ getDomainProxyStats(backendId: number, domain: string): ProxyTrafficStats[] {
+ const stmt = this.db.prepare(`
+ SELECT chain,
+ SUM(upload) as totalUpload,
+ SUM(download) as totalDownload,
+ COUNT(*) as totalConnections
+ FROM connection_logs
+ WHERE backend_id = ? AND domain = ?
+ GROUP BY chain
+ ORDER BY (SUM(upload) + SUM(download)) DESC
+ `);
+ return stmt.all(backendId, domain) as ProxyTrafficStats[];
+ }
+
+ // Get per-proxy traffic breakdown for a specific IP
+ getIPProxyStats(backendId: number, ip: string): ProxyTrafficStats[] {
+ const stmt = this.db.prepare(`
+ SELECT chain,
+ SUM(upload) as totalUpload,
+ SUM(download) as totalDownload,
+ COUNT(*) as totalConnections
+ FROM connection_logs
+ WHERE backend_id = ? AND ip = ?
+ GROUP BY chain
+ ORDER BY (SUM(upload) + SUM(download)) DESC
+ `);
+ return stmt.all(backendId, ip) as ProxyTrafficStats[];
+ }
+
// Get recent connections for a specific backend
getRecentConnections(backendId: number, limit = 100): Connection[] {
const stmt = this.db.prepare(`
diff --git a/apps/web/components/domains-table.tsx b/apps/web/components/domains-table.tsx
index 0660157..f38966f 100644
--- a/apps/web/components/domains-table.tsx
+++ b/apps/web/components/domains-table.tsx
@@ -1,14 +1,15 @@
"use client";
-import { useState, useMemo } from "react";
-import { Search, ArrowUpDown, ArrowDown, ArrowUp, ChevronLeft, ChevronRight, Rows3, ChevronDown, ChevronUp, Globe, Server } from "lucide-react";
+import { useState, useMemo, useCallback } from "react";
+import { Search, ArrowUpDown, ArrowDown, ArrowUp, ChevronLeft, ChevronRight, Rows3, ChevronDown, ChevronUp, Globe, Server, Waypoints, Loader2 } from "lucide-react";
import { useTranslations } from "next-intl";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { Favicon } from "@/components/favicon";
import { formatBytes, formatNumber, formatDuration } from "@/lib/utils";
import { cn } from "@/lib/utils";
-import type { DomainStats } from "@clashmaster/shared";
+import type { DomainStats, ProxyTrafficStats, IPStats } from "@clashmaster/shared";
+import { api } from "@/lib/api";
import {
DropdownMenu,
DropdownMenuContent,
@@ -42,6 +43,19 @@ const getIPGradient = (ip: string) => {
return colors[Math.abs(hash) % colors.length];
};
+// Country flag emoji mapping
+const COUNTRY_FLAGS: Record<string, string> = {
+ US: "๐Ÿ‡บ๐Ÿ‡ธ", CN: "๐Ÿ‡จ๐Ÿ‡ณ", JP: "๐Ÿ‡ฏ๐Ÿ‡ต", SG: "๐Ÿ‡ธ๐Ÿ‡ฌ", HK: "๐Ÿ‡ญ๐Ÿ‡ฐ",
+ TW: "๐Ÿ‡น๐Ÿ‡ผ", KR: "๐Ÿ‡ฐ๐Ÿ‡ท", GB: "๐Ÿ‡ฌ๐Ÿ‡ง", DE: "๐Ÿ‡ฉ๐Ÿ‡ช", FR: "๐Ÿ‡ซ๐Ÿ‡ท",
+ NL: "๐Ÿ‡ณ๐Ÿ‡ฑ", CA: "๐Ÿ‡จ๐Ÿ‡ฆ", AU: "๐Ÿ‡ฆ๐Ÿ‡บ", IN: "๐Ÿ‡ฎ๐Ÿ‡ณ", BR: "๐Ÿ‡ง๐Ÿ‡ท",
+ RU: "๐Ÿ‡ท๐Ÿ‡บ", SE: "๐Ÿ‡ธ๐Ÿ‡ช", CH: "๐Ÿ‡จ๐Ÿ‡ญ", IL: "๐Ÿ‡ฎ๐Ÿ‡ฑ", ID: "๐Ÿ‡ฎ๐Ÿ‡ฉ",
+ LOCAL: "๐Ÿ ",
+};
+
+function getCountryFlag(country: string): string {
+ return COUNTRY_FLAGS[country] || COUNTRY_FLAGS[country.toUpperCase()] || "๐ŸŒ";
+}
+
export function DomainsTable({ data }: DomainsTableProps) {
const t = useTranslations("domains");
const [search, setSearch] = useState("");
@@ -50,6 +64,40 @@ export function DomainsTable({ data }: DomainsTableProps) {
const [currentPage, setCurrentPage] = useState(1);
const [pageSize, setPageSize] = useState<PageSize>(10);
const [expandedDomain, setExpandedDomain] = useState<string | null>(null);
+ const [proxyStats, setProxyStats] = useState<Record<string, ProxyTrafficStats[]>>({});
+ const [proxyStatsLoading, setProxyStatsLoading] = useState<string | null>(null);
+ const [ipDetails, setIPDetails] = useState<Record<string, IPStats[]>>({});
+ const [ipDetailsLoading, setIPDetailsLoading] = useState<string | null>(null);
+
+ // Fetch proxy stats when a domain is expanded
+ const fetchProxyStats = useCallback(async (domain: string) => {
+ if (proxyStats[domain]) return; // Already cached
+ setProxyStatsLoading(domain);
+ try {
+ const stats = await api.getDomainProxyStats(domain);
+ setProxyStats(prev => ({ ...prev, [domain]: stats }));
+ } catch (err) {
+ console.error(`Failed to fetch proxy stats for ${domain}:`, err);
+ setProxyStats(prev => ({ ...prev, [domain]: [] }));
+ } finally {
+ setProxyStatsLoading(null);
+ }
+ }, [proxyStats]);
+
+ // Fetch IP details when a domain is expanded
+ const fetchIPDetails = useCallback(async (domain: string) => {
+ if (ipDetails[domain]) return; // Already cached
+ setIPDetailsLoading(domain);
+ try {
+ const details = await api.getDomainIPDetails(domain);
+ setIPDetails(prev => ({ ...prev, [domain]: details }));
+ } catch (err) {
+ console.error(`Failed to fetch IP details for ${domain}:`, err);
+ setIPDetails(prev => ({ ...prev, [domain]: [] }));
+ } finally {
+ setIPDetailsLoading(null);
+ }
+ }, [ipDetails]);
const handleSort = (key: SortKey) => {
if (sortKey === key) {
@@ -96,7 +144,12 @@ export function DomainsTable({ data }: DomainsTableProps) {
};
const toggleExpand = (domain: string) => {
- setExpandedDomain(expandedDomain === domain ? null : domain);
+ const newExpanded = expandedDomain === domain ? null : domain;
+ setExpandedDomain(newExpanded);
+ if (newExpanded) {
+ fetchProxyStats(newExpanded);
+ fetchIPDetails(newExpanded);
+ }
};
const SortIcon = ({ column }: { column: SortKey }) => {
@@ -167,6 +220,9 @@ export function DomainsTable({ data }: DomainsTableProps) {
{t("domain")}
<SortIcon column="domain" />
</div>
+ <div className="col-span-2 flex items-center">
+ {t("proxy")}
+ </div>
<div
className="col-span-2 flex items-center justify-end cursor-pointer hover:text-foreground transition-colors"
onClick={() => handleSort("totalDownload")}
@@ -175,14 +231,14 @@ export function DomainsTable({ data }: DomainsTableProps) {
<SortIcon column="totalDownload" />
</div>
<div
- className="col-span-2 flex items-center justify-end cursor-pointer hover:text-foreground transition-colors"
+ className="col-span-1 flex items-center justify-end cursor-pointer hover:text-foreground transition-colors"
onClick={() => handleSort("totalUpload")}
>
{t("upload")}
<SortIcon column="totalUpload" />
</div>
<div
- className="col-span-2 flex items-center justify-end cursor-pointer hover:text-foreground transition-colors"
+ className="col-span-1 flex items-center justify-end cursor-pointer hover:text-foreground transition-colors"
onClick={() => handleSort("totalConnections")}
>
{t("conn")}
@@ -253,19 +309,41 @@ export function DomainsTable({ data }: DomainsTableProps) {
</div>
</div>
+ {/* Proxy */}
+ <div className="col-span-2 flex items-center gap-1.5 min-w-0">
+ {domain.chains && domain.chains.length > 0 ? (
+ <div className="flex items-center gap-1.5">
+ <span
+ className="inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md bg-orange-500/10 text-orange-600 dark:text-orange-400 text-[11px] font-medium truncate max-w-[120px]"
+ title={domain.chains[0]}
+ >
+ <Waypoints className="h-2.5 w-2.5 shrink-0" />
+ {domain.chains[0]}
+ </span>
+ {domain.chains.length > 1 && (
+ <span className="text-[11px] text-muted-foreground shrink-0">
+ +{domain.chains.length - 1}
+ </span>
+ )}
+ </div>
+ ) : (
+ <span className="text-xs text-muted-foreground">-</span>
+ )}
+ </div>
+
{/* Download */}
<div className="col-span-2 text-right tabular-nums text-sm">
<span className="text-blue-500">{formatBytes(domain.totalDownload)}</span>
</div>
{/* Upload */}
- <div className="col-span-2 text-right tabular-nums text-sm">
+ <div className="col-span-1 text-right tabular-nums text-sm">
<span className="text-purple-500">{formatBytes(domain.totalUpload)}</span>
</div>
{/* Connections */}
- <div className="col-span-2 flex items-center justify-end">
- <span className="px-2.5 py-1 rounded-full bg-secondary text-xs font-medium">
+ <div className="col-span-1 flex items-center justify-end">
+ <span className="px-2 py-0.5 rounded-full bg-secondary text-xs font-medium">
{formatNumber(domain.totalConnections)}
</span>
</div>
@@ -343,6 +421,24 @@ export function DomainsTable({ data }: DomainsTableProps) {
</Button>
</div>
+ {/* Proxy info */}
+ {domain.chains && domain.chains.length > 0 && (
+ <div className="flex items-center gap-1.5 mb-1.5 pl-[30px]">
+ <span
+ className="inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md bg-orange-500/10 text-orange-600 dark:text-orange-400 text-[11px] font-medium truncate max-w-[120px]"
+ title={domain.chains[0]}
+ >
+ <Waypoints className="h-2.5 w-2.5 shrink-0" />
+ {domain.chains[0]}
+ </span>
+ {domain.chains.length > 1 && (
+ <span className="text-[11px] text-muted-foreground shrink-0">
+ +{domain.chains.length - 1}
+ </span>
+ )}
+ </div>
+ )}
+
{/* Bottom: Stats row */}
<div className="flex items-center justify-between text-xs pl-[30px]">
<span className="text-blue-500 tabular-nums">โ†“ {formatBytes(domain.totalDownload)}</span>
@@ -353,29 +449,163 @@ export function DomainsTable({ data }: DomainsTableProps) {
</div>
</div>
- {/* Expanded IP List */}
+ {/* Expanded Details: Proxy Traffic + IP List */}
{isExpanded && (
<div className="px-4 sm:px-5 pb-4 bg-secondary/5">
- <div className="pt-2 pb-1 px-1">
- <p className="text-xs font-medium text-muted-foreground mb-2 flex items-center gap-1.5">
- <Globe className="h-3 w-3" />
- {t("associatedIPs")}
- </p>
- <div className="flex flex-wrap gap-2">
- {domain.ips.map((ip) => {
- const gradient = getIPGradient(ip);
- return (
- <div
- key={ip}
- className="flex items-center gap-2 px-2.5 py-1.5 sm:px-3 sm:py-2 rounded-lg bg-card border border-border/50 hover:border-primary/30 hover:shadow-sm transition-all"
- >
- <div className={`w-5 h-5 sm:w-6 sm:h-6 rounded-md bg-gradient-to-br ${gradient} flex items-center justify-center shrink-0`}>
- <Server className="w-2.5 h-2.5 sm:w-3 sm:h-3 text-white" />
- </div>
- <code className="text-xs font-mono break-all">{ip}</code>
- </div>
- );
- })}
+ <div className="pt-3 grid grid-cols-1 sm:grid-cols-2 gap-4">
+ {/* Proxy Traffic Breakdown */}
+ <div className="px-1">
+ <p className="text-xs font-medium text-muted-foreground mb-2.5 flex items-center gap-1.5">
+ <Waypoints className="h-3 w-3" />
+ {t("proxyTraffic")}
+ </p>
+ {proxyStatsLoading === domain.domain ? (
+ <div className="flex items-center justify-center py-4">
+ <Loader2 className="h-4 w-4 animate-spin text-muted-foreground" />
+ </div>
+ ) : (proxyStats[domain.domain] && proxyStats[domain.domain].length > 0) ? (
+ <div className="space-y-2">
+ {proxyStats[domain.domain].map((ps) => {
+ const totalTraffic = domain.totalDownload + domain.totalUpload;
+ const proxyTraffic = ps.totalDownload + ps.totalUpload;
+ const percent = totalTraffic > 0 ? (proxyTraffic / totalTraffic) * 100 : 0;
+ const proxyTotal = ps.totalDownload + ps.totalUpload;
+ const downloadPercent = proxyTotal > 0 ? (ps.totalDownload / proxyTotal) * 100 : 0;
+ const uploadPercent = proxyTotal > 0 ? (ps.totalUpload / proxyTotal) * 100 : 0;
+ return (
+ <div
+ key={ps.chain}
+ className="px-3 py-2 rounded-lg bg-card border border-border/50"
+ >
+ <div className="flex items-center justify-between mb-1.5">
+ <span className="inline-flex items-center gap-1.5 text-xs font-medium truncate max-w-[60%]" title={ps.chain}>
+ <Waypoints className="h-3 w-3 text-orange-500 shrink-0" />
+ {ps.chain}
+ </span>
+ <span className="text-[11px] text-muted-foreground tabular-nums shrink-0">
+ {percent.toFixed(1)}%
+ </span>
+ </div>
+ <div className="w-full h-1.5 rounded-full bg-secondary/80 mb-1.5 overflow-hidden flex">
+ {/* Download portion - blue */}
+ <div
+ className="h-full bg-blue-500 transition-all"
+ style={{ width: `${Math.max(percent * (downloadPercent / 100), 0.5)}%` }}
+ />
+ {/* Upload portion - purple */}
+ <div
+ className="h-full bg-purple-500 transition-all"
+ style={{ width: `${Math.max(percent * (uploadPercent / 100), 0.5)}%` }}
+ />
+ </div>
+ <div className="flex items-center gap-3 text-[11px] tabular-nums">
+ <span className="text-blue-500">โ†“ {formatBytes(ps.totalDownload)}</span>
+ <span className="text-purple-500">โ†‘ {formatBytes(ps.totalUpload)}</span>
+ <span className="text-muted-foreground">{formatNumber(ps.totalConnections)} {t("conn")}</span>
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ ) : (
+ <div className="flex flex-wrap gap-1.5">
+ {domain.chains.map((chain) => (
+ <span
+ key={chain}
+ className="inline-flex items-center gap-1 px-2 py-1 rounded-md bg-orange-500/10 text-orange-600 dark:text-orange-400 text-xs font-medium"
+ >
+ <Waypoints className="h-3 w-3 shrink-0" />
+ {chain}
+ </span>
+ ))}
+ </div>
+ )}
+ </div>
+
+ {/* Associated IPs */}
+ <div className="px-1">
+ <p className="text-xs font-medium text-muted-foreground mb-2.5 flex items-center gap-1.5">
+ <Globe className="h-3 w-3" />
+ {t("associatedIPs")}
+ </p>
+ {ipDetailsLoading === domain.domain ? (
+ <div className="flex items-center justify-center py-4">
+ <Loader2 className="h-4 w-4 animate-spin text-muted-foreground" />
+ </div>
+ ) : (ipDetails[domain.domain] && ipDetails[domain.domain].length > 0) ? (
+ <div className="space-y-2">
+ {(() => {
+ const totalIPTraffic = ipDetails[domain.domain].reduce((sum, ip) => sum + ip.totalDownload + ip.totalUpload, 0);
+ return ipDetails[domain.domain].map((ipStat) => {
+ const flag = ipStat.geoIP && ipStat.geoIP.length > 0
+ ? getCountryFlag(ipStat.geoIP[0])
+ : "๐ŸŒ";
+ const location = ipStat.geoIP && ipStat.geoIP.length > 1
+ ? ipStat.geoIP[1]
+ : ipStat.geoIP?.[0] || null;
+ const ipTraffic = ipStat.totalDownload + ipStat.totalUpload;
+ const percent = totalIPTraffic > 0 ? (ipTraffic / totalIPTraffic) * 100 : 0;
+ const downloadPercent = ipTraffic > 0 ? (ipStat.totalDownload / ipTraffic) * 100 : 0;
+ const uploadPercent = ipTraffic > 0 ? (ipStat.totalUpload / ipTraffic) * 100 : 0;
+ return (
+ <div
+ key={ipStat.ip}
+ className="px-3 py-2 rounded-lg bg-card border border-border/50 hover:border-primary/30 hover:shadow-sm transition-all"
+ >
+ <div className="flex items-center justify-between mb-1.5">
+ <div className="flex items-center gap-1.5">
+ <Waypoints className="h-3 w-3 text-orange-500 shrink-0" />
+ <code className="text-xs font-mono">{ipStat.ip}</code>
+ </div>
+ <span className="text-[11px] text-muted-foreground tabular-nums shrink-0">
+ {percent.toFixed(1)}%
+ </span>
+ </div>
+ <div className="w-full h-1.5 rounded-full bg-secondary/80 mb-1.5 overflow-hidden flex">
+ <div
+ className="h-full bg-blue-500 transition-all"
+ style={{ width: `${Math.max(percent * (downloadPercent / 100), 0.5)}%` }}
+ />
+ <div
+ className="h-full bg-purple-500 transition-all"
+ style={{ width: `${Math.max(percent * (uploadPercent / 100), 0.5)}%` }}
+ />
+ </div>
+ <div className="flex items-center justify-between">
+ <div className="flex items-center gap-3 text-[11px] tabular-nums">
+ <span className="text-blue-500">โ†“ {formatBytes(ipStat.totalDownload)}</span>
+ <span className="text-purple-500">โ†‘ {formatBytes(ipStat.totalUpload)}</span>
+ <span className="text-muted-foreground">{formatNumber(ipStat.totalConnections)} conn</span>
+ </div>
+ {location && (
+ <span className="text-[11px] text-muted-foreground">
+ {flag} {location}
+ </span>
+ )}
+ </div>
+ </div>
+ );
+ });
+ })()}
+ </div>
+ ) : (
+ <div className="flex flex-wrap gap-2">
+ {domain.ips.map((ip) => {
+ const gradient = getIPGradient(ip);
+ return (
+ <div
+ key={ip}
+ className="flex items-center gap-2 px-2.5 py-1.5 sm:px-3 sm:py-2 rounded-lg bg-card border border-border/50 hover:border-primary/30 hover:shadow-sm transition-all"
+ >
+ <div className={`w-5 h-5 sm:w-6 sm:h-6 rounded-md bg-gradient-to-br ${gradient} flex items-center justify-center shrink-0`}>
+ <Server className="w-2.5 h-2.5 sm:w-3 sm:h-3 text-white" />
+ </div>
+ <code className="text-xs font-mono break-all">{ip}</code>
+ </div>
+ );
+ })}
+ </div>
+ )}
</div>
</div>
</div>
diff --git a/apps/web/components/ips-table.tsx b/apps/web/components/ips-table.tsx
index 0c06a67..e4354d0 100644
--- a/apps/web/components/ips-table.tsx
+++ b/apps/web/components/ips-table.tsx
@@ -1,13 +1,14 @@
"use client";
-import { useState, useMemo } from "react";
-import { Search, ArrowUpDown, ArrowDown, ArrowUp, ChevronLeft, ChevronRight, Rows3, Globe, Server, ChevronDown, ChevronUp, Link2 } from "lucide-react";
+import { useState, useMemo, useCallback } from "react";
+import { Search, ArrowUpDown, ArrowDown, ArrowUp, ChevronLeft, ChevronRight, Rows3, Globe, Server, ChevronDown, ChevronUp, Link2, Waypoints, Loader2 } from "lucide-react";
import { useTranslations } from "next-intl";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { formatBytes, formatNumber } from "@/lib/utils";
import { cn } from "@/lib/utils";
-import type { IPStats } from "@clashmaster/shared";
+import type { IPStats, ProxyTrafficStats } from "@clashmaster/shared";
+import { api } from "@/lib/api";
import {
DropdownMenu,
DropdownMenuContent,
@@ -55,6 +56,19 @@ const getDomainColor = (domain: string) => {
return IP_COLORS[Math.abs(hash) % IP_COLORS.length];
};
+// Country flag emoji mapping
+const COUNTRY_FLAGS: Record<string, string> = {
+ US: "๐Ÿ‡บ๐Ÿ‡ธ", CN: "๐Ÿ‡จ๐Ÿ‡ณ", JP: "๐Ÿ‡ฏ๐Ÿ‡ต", SG: "๐Ÿ‡ธ๐Ÿ‡ฌ", HK: "๐Ÿ‡ญ๐Ÿ‡ฐ",
+ TW: "๐Ÿ‡น๐Ÿ‡ผ", KR: "๐Ÿ‡ฐ๐Ÿ‡ท", GB: "๐Ÿ‡ฌ๐Ÿ‡ง", DE: "๐Ÿ‡ฉ๐Ÿ‡ช", FR: "๐Ÿ‡ซ๐Ÿ‡ท",
+ NL: "๐Ÿ‡ณ๐Ÿ‡ฑ", CA: "๐Ÿ‡จ๐Ÿ‡ฆ", AU: "๐Ÿ‡ฆ๐Ÿ‡บ", IN: "๐Ÿ‡ฎ๐Ÿ‡ณ", BR: "๐Ÿ‡ง๐Ÿ‡ท",
+ RU: "๐Ÿ‡ท๐Ÿ‡บ", SE: "๐Ÿ‡ธ๐Ÿ‡ช", CH: "๐Ÿ‡จ๐Ÿ‡ญ", IL: "๐Ÿ‡ฎ๐Ÿ‡ฑ", ID: "๐Ÿ‡ฎ๐Ÿ‡ฉ",
+ LOCAL: "๐Ÿ ",
+};
+
+function getCountryFlag(country: string): string {
+ return COUNTRY_FLAGS[country] || COUNTRY_FLAGS[country.toUpperCase()] || "๐ŸŒ";
+}
+
export function IPsTable({ data }: IPsTableProps) {
const t = useTranslations("ips");
const [search, setSearch] = useState("");
@@ -63,6 +77,23 @@ export function IPsTable({ data }: IPsTableProps) {
const [currentPage, setCurrentPage] = useState(1);
const [pageSize, setPageSize] = useState<PageSize>(10);
const [expandedIP, setExpandedIP] = useState<string | null>(null);
+ const [proxyStats, setProxyStats] = useState<Record<string, ProxyTrafficStats[]>>({});
+ const [proxyStatsLoading, setProxyStatsLoading] = useState<string | null>(null);
+
+ // Fetch proxy stats when an IP is expanded
+ const fetchProxyStats = useCallback(async (ip: string) => {
+ if (proxyStats[ip]) return; // Already cached
+ setProxyStatsLoading(ip);
+ try {
+ const stats = await api.getIPProxyStats(ip);
+ setProxyStats(prev => ({ ...prev, [ip]: stats }));
+ } catch (err) {
+ console.error(`Failed to fetch proxy stats for ${ip}:`, err);
+ setProxyStats(prev => ({ ...prev, [ip]: [] }));
+ } finally {
+ setProxyStatsLoading(null);
+ }
+ }, [proxyStats]);
const handleSort = (key: SortKey) => {
if (sortKey === key) {
@@ -110,7 +141,11 @@ export function IPsTable({ data }: IPsTableProps) {
};
const toggleExpand = (ip: string) => {
- setExpandedIP(expandedIP === ip ? null : ip);
+ const newExpanded = expandedIP === ip ? null : ip;
+ setExpandedIP(newExpanded);
+ if (newExpanded) {
+ fetchProxyStats(newExpanded);
+ }
};
const SortIcon = ({ column }: { column: SortKey }) => {
@@ -180,6 +215,9 @@ export function IPsTable({ data }: IPsTableProps) {
<SortIcon column="ip" />
</div>
<div className="col-span-2 flex items-center">
+ {t("proxy")}
+ </div>
+ <div className="col-span-1 flex items-center">
{t("location")}
</div>
<div
@@ -190,7 +228,7 @@ export function IPsTable({ data }: IPsTableProps) {
<SortIcon column="totalDownload" />
</div>
<div
- className="col-span-2 flex items-center justify-end cursor-pointer hover:text-foreground transition-colors"
+ className="col-span-1 flex items-center justify-end cursor-pointer hover:text-foreground transition-colors"
onClick={() => handleSort("totalUpload")}
>
{t("upload")}
@@ -257,25 +295,44 @@ export function IPsTable({ data }: IPsTableProps) {
>
{/* IP with Icon */}
<div className="col-span-3 flex items-center gap-3 min-w-0">
- <div className={`w-8 h-8 rounded-lg ${ipColor.bg} ${ipColor.text} flex items-center justify-center shrink-0`}>
- <Server className="w-4 h-4" />
+ <div className={`w-5 h-5 rounded-md ${ipColor.bg} ${ipColor.text} flex items-center justify-center shrink-0`}>
+ <Server className="w-3 h-3" />
</div>
<div className="min-w-0">
<code className="text-sm font-medium truncate block">{ip.ip}</code>
- {ip.asn && (
- <p className="text-xs text-muted-foreground truncate max-w-[150px]">
- {ip.asn}
- </p>
- )}
</div>
</div>
+ {/* Proxy */}
+ <div className="col-span-2 flex items-center gap-1.5 min-w-0">
+ {ip.chains && ip.chains.length > 0 ? (
+ <div className="flex items-center gap-1.5">
+ <span
+ className="inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md bg-orange-500/10 text-orange-600 dark:text-orange-400 text-[11px] font-medium truncate max-w-[120px]"
+ title={ip.chains[0]}
+ >
+ <Waypoints className="h-2.5 w-2.5 shrink-0" />
+ {ip.chains[0]}
+ </span>
+ {ip.chains.length > 1 && (
+ <span className="text-[11px] text-muted-foreground shrink-0">
+ +{ip.chains.length - 1}
+ </span>
+ )}
+ </div>
+ ) : (
+ <span className="text-xs text-muted-foreground">-</span>
+ )}
+ </div>
+
{/* Location */}
- <div className="col-span-2 flex items-center">
+ <div className="col-span-1 flex items-center">
{ip.geoIP && ip.geoIP.length > 0 ? (
<div className="flex items-center gap-1.5">
- <Globe className="w-3 h-3 text-muted-foreground shrink-0" />
- <span className="text-xs truncate">{ip.geoIP[0]}</span>
+ <span className="text-sm" title={ip.geoIP[1] || ip.geoIP[0]}>
+ {getCountryFlag(ip.geoIP[0])}
+ </span>
+ <span className="text-xs truncate">{ip.geoIP[1] || ip.geoIP[0]}</span>
</div>
) : (
<span className="text-xs text-muted-foreground">-</span>
@@ -288,7 +345,7 @@ export function IPsTable({ data }: IPsTableProps) {
</div>
{/* Upload */}
- <div className="col-span-2 text-right tabular-nums text-sm">
+ <div className="col-span-1 text-right tabular-nums text-sm">
<span className="text-purple-500">{formatBytes(ip.totalUpload)}</span>
</div>
@@ -336,23 +393,17 @@ export function IPsTable({ data }: IPsTableProps) {
>
{/* Top: IP Icon + IP + Location + Expand */}
<div className="flex items-center gap-2.5 mb-2">
- <div className={`w-7 h-7 rounded-lg ${ipColor.bg} ${ipColor.text} flex items-center justify-center shrink-0`}>
- <Server className="w-3.5 h-3.5" />
+ <div className={`w-5 h-5 rounded-md ${ipColor.bg} ${ipColor.text} flex items-center justify-center shrink-0`}>
+ <Server className="w-3 h-3" />
</div>
<div className="flex-1 min-w-0">
<code className="text-sm font-medium truncate block">{ip.ip}</code>
- <div className="flex items-center gap-1.5 text-xs text-muted-foreground">
- {ip.geoIP && ip.geoIP.length > 0 ? (
- <>
- <Globe className="w-3 h-3 shrink-0" />
- <span className="truncate">{ip.geoIP[0]}</span>
- </>
- ) : ip.asn ? (
- <span className="truncate">{ip.asn}</span>
- ) : (
- <span>-</span>
- )}
- </div>
+ {ip.geoIP && ip.geoIP.length > 0 && (
+ <div className="flex items-center gap-1.5 text-xs text-muted-foreground">
+ <span className="text-sm">{getCountryFlag(ip.geoIP[0])}</span>
+ <span className="truncate">{ip.geoIP[1] || ip.geoIP[0]}</span>
+ </div>
+ )}
</div>
<Button
variant="ghost"
@@ -374,6 +425,24 @@ export function IPsTable({ data }: IPsTableProps) {
</Button>
</div>
+ {/* Proxy info */}
+ {ip.chains && ip.chains.length > 0 && (
+ <div className="flex items-center gap-1.5 mb-1.5 pl-[38px]">
+ <span
+ className="inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md bg-orange-500/10 text-orange-600 dark:text-orange-400 text-[11px] font-medium truncate max-w-[120px]"
+ title={ip.chains[0]}
+ >
+ <Waypoints className="h-2.5 w-2.5 shrink-0" />
+ {ip.chains[0]}
+ </span>
+ {ip.chains.length > 1 && (
+ <span className="text-[11px] text-muted-foreground shrink-0">
+ +{ip.chains.length - 1}
+ </span>
+ )}
+ </div>
+ )}
+
{/* Bottom: Stats row */}
<div className="flex items-center justify-between text-xs pl-[38px]">
<span className="text-blue-500 tabular-nums">โ†“ {formatBytes(ip.totalDownload)}</span>
@@ -384,29 +453,101 @@ export function IPsTable({ data }: IPsTableProps) {
</div>
</div>
- {/* Expanded Domains List */}
+ {/* Expanded Details: Proxy Traffic + Domains List */}
{isExpanded && (
<div className="px-4 sm:px-5 pb-4 bg-secondary/5">
- <div className="pt-2 pb-1 px-1">
- <p className="text-xs font-medium text-muted-foreground mb-2 flex items-center gap-1.5">
- <Link2 className="h-3 w-3" />
- {t("associatedDomains")}
- </p>
- <div className="flex flex-wrap gap-2">
- {ip.domains.map((domain) => {
- const domainColor = getDomainColor(domain);
- return (
- <div
- key={domain}
- className="flex items-center gap-2 px-2.5 py-1.5 sm:px-3 sm:py-2 rounded-lg bg-card border border-border/50 hover:border-primary/30 hover:shadow-sm transition-all"
- >
- <div className={`w-5 h-5 sm:w-6 sm:h-6 rounded-md ${domainColor.bg} ${domainColor.text} flex items-center justify-center shrink-0`}>
- <Globe className="w-2.5 h-2.5 sm:w-3 sm:h-3" />
+ <div className="pt-3 grid grid-cols-1 sm:grid-cols-2 gap-4">
+ {/* Proxy Traffic Breakdown */}
+ <div className="px-1">
+ <p className="text-xs font-medium text-muted-foreground mb-2.5 flex items-center gap-1.5">
+ <Waypoints className="h-3 w-3" />
+ {t("proxyTraffic")}
+ </p>
+ {proxyStatsLoading === ip.ip ? (
+ <div className="flex items-center justify-center py-4">
+ <Loader2 className="h-4 w-4 animate-spin text-muted-foreground" />
+ </div>
+ ) : (proxyStats[ip.ip] && proxyStats[ip.ip].length > 0) ? (
+ <div className="space-y-2">
+ {proxyStats[ip.ip].map((ps) => {
+ const totalTraffic = ip.totalDownload + ip.totalUpload;
+ const proxyTraffic = ps.totalDownload + ps.totalUpload;
+ const percent = totalTraffic > 0 ? (proxyTraffic / totalTraffic) * 100 : 0;
+ const proxyTotal = ps.totalDownload + ps.totalUpload;
+ const downloadPercent = proxyTotal > 0 ? (ps.totalDownload / proxyTotal) * 100 : 0;
+ const uploadPercent = proxyTotal > 0 ? (ps.totalUpload / proxyTotal) * 100 : 0;
+ return (
+ <div
+ key={ps.chain}
+ className="px-3 py-2 rounded-lg bg-card border border-border/50"
+ >
+ <div className="flex items-center justify-between mb-1.5">
+ <span className="inline-flex items-center gap-1.5 text-xs font-medium truncate max-w-[60%]" title={ps.chain}>
+ <Waypoints className="h-3 w-3 text-orange-500 shrink-0" />
+ {ps.chain}
+ </span>
+ <span className="text-[11px] text-muted-foreground tabular-nums shrink-0">
+ {percent.toFixed(1)}%
+ </span>
+ </div>
+ <div className="w-full h-1.5 rounded-full bg-secondary/80 mb-1.5 overflow-hidden flex">
+ <div
+ className="h-full bg-blue-500 transition-all"
+ style={{ width: `${Math.max(percent * (downloadPercent / 100), 0.5)}%` }}
+ />
+ <div
+ className="h-full bg-purple-500 transition-all"
+ style={{ width: `${Math.max(percent * (uploadPercent / 100), 0.5)}%` }}
+ />
+ </div>
+ <div className="flex items-center gap-3 text-[11px] tabular-nums">
+ <span className="text-blue-500">โ†“ {formatBytes(ps.totalDownload)}</span>
+ <span className="text-purple-500">โ†‘ {formatBytes(ps.totalUpload)}</span>
+ <span className="text-muted-foreground">{formatNumber(ps.totalConnections)} {t("conn")}</span>
+ </div>
+ </div>
+ );
+ })}
+ </div>
+ ) : (ip.chains && ip.chains.length > 0) ? (
+ <div className="flex flex-wrap gap-1.5">
+ {ip.chains.map((chain) => (
+ <span
+ key={chain}
+ className="inline-flex items-center gap-1 px-2 py-1 rounded-md bg-orange-500/10 text-orange-600 dark:text-orange-400 text-xs font-medium"
+ >
+ <Waypoints className="h-3 w-3 shrink-0" />
+ {chain}
+ </span>
+ ))}
+ </div>
+ ) : (
+ <span className="text-xs text-muted-foreground">-</span>
+ )}
+ </div>
+
+ {/* Associated Domains */}
+ <div className="px-1">
+ <p className="text-xs font-medium text-muted-foreground mb-2.5 flex items-center gap-1.5">
+ <Link2 className="h-3 w-3" />
+ {t("associatedDomains")}
+ </p>
+ <div className="flex flex-wrap gap-2">
+ {ip.domains.map((domain) => {
+ const domainColor = getDomainColor(domain);
+ return (
+ <div
+ key={domain}
+ className="flex items-center gap-2 px-2.5 py-1.5 sm:px-3 sm:py-2 rounded-lg bg-card border border-border/50 hover:border-primary/30 hover:shadow-sm transition-all"
+ >
+ <div className={`w-5 h-5 sm:w-6 sm:h-6 rounded-md ${domainColor.bg} ${domainColor.text} flex items-center justify-center shrink-0`}>
+ <Globe className="w-2.5 h-2.5 sm:w-3 sm:h-3" />
+ </div>
+ <span className="text-xs font-medium truncate max-w-[180px] sm:max-w-[200px]">{domain}</span>
</div>
- <span className="text-xs font-medium truncate max-w-[180px] sm:max-w-[200px]">{domain}</span>
- </div>
- );
- })}
+ );
+ })}
+ </div>
</div>
</div>
</div>
diff --git a/apps/web/lib/api.ts b/apps/web/lib/api.ts
index 27eeaa0..7c90507 100644
--- a/apps/web/lib/api.ts
+++ b/apps/web/lib/api.ts
@@ -8,6 +8,7 @@ import type {
HourlyStats,
DailyStats,
TrafficTrendPoint,
+ ProxyTrafficStats,
} from "@clashmaster/shared";
const API_BASE = "/api";
@@ -162,6 +163,21 @@ export const api = {
buildUrl(`${API_BASE}/stats/connections`, { backendId, limit })
),
+ getDomainProxyStats: (domain: string, backendId?: number) =>
+ fetchJson<ProxyTrafficStats[]>(
+ buildUrl(`${API_BASE}/stats/domains/proxy-stats`, { domain, backendId })
+ ),
+
+ getDomainIPDetails: (domain: string, backendId?: number) =>
+ fetchJson<IPStats[]>(
+ buildUrl(`${API_BASE}/stats/domains/ip-details`, { domain, backendId })
+ ),
+
+ getIPProxyStats: (ip: string, backendId?: number) =>
+ fetchJson<ProxyTrafficStats[]>(
+ buildUrl(`${API_BASE}/stats/ips/proxy-stats`, { ip, backendId })
+ ),
+
search: (q: string) =>
fetchJson<DomainStats[]>(
`${API_BASE}/search?q=${encodeURIComponent(q)}`
diff --git a/apps/web/messages/en.json b/apps/web/messages/en.json
index 6d8ce5e..d1464a9 100644
--- a/apps/web/messages/en.json
+++ b/apps/web/messages/en.json
@@ -6,7 +6,7 @@
"nav": {
"overview": "Overview",
"domains": "Domains",
- "countries": "Countries",
+ "countries": "Regions",
"proxies": "Proxies",
"rules": "Rules",
"network": "Network",
@@ -84,7 +84,7 @@
"viewAll": "View all"
},
"topCountries": {
- "title": "Top Countries",
+ "title": "Top Regions",
"viewAll": "View all",
"sortByTraffic": "Sort by traffic",
"sortByConnections": "Sort by connections"
@@ -107,6 +107,8 @@
"unknown": "Unknown",
"ips": "IPs",
"ipCount": "IPs",
+ "proxy": "Proxy",
+ "proxyTraffic": "Proxy Traffic Breakdown",
"associatedIPs": "Associated IP Addresses",
"domainsCount": "domains",
"showing": "Showing",
@@ -124,6 +126,8 @@
"location": "Location",
"domains": "Domains",
"domainCount": "Domains",
+ "proxy": "Proxy",
+ "proxyTraffic": "Proxy Traffic Breakdown",
"associatedDomains": "Associated Domains",
"download": "Download",
"upload": "Upload",
@@ -136,9 +140,9 @@
"total": "Total"
},
"countries": {
- "title": "Countries",
- "details": "Country Details",
- "distribution": "Country Traffic Distribution",
+ "title": "Regions",
+ "details": "Region Details",
+ "distribution": "Regional Traffic Distribution",
"continents": "Continents:",
"noData": "No data",
"connections": "connections"
@@ -166,12 +170,12 @@
"comingSoon": "Real-time connection monitoring coming soon..."
},
"map": {
- "title": "Global Traffic Distribution",
+ "title": "Global Regional Traffic",
"total": "Total",
"download": "Download",
"upload": "Upload",
"connections": "Connections",
- "hoverHint": "Hover over countries for details",
+ "hoverHint": "Hover over regions for details",
"traffic": "Traffic:",
"low": "Low",
"high": "High"
diff --git a/apps/web/messages/zh.json b/apps/web/messages/zh.json
index 014beeb..cc94842 100644
--- a/apps/web/messages/zh.json
+++ b/apps/web/messages/zh.json
@@ -6,7 +6,7 @@
"nav": {
"overview": "ๆฆ‚่งˆ",
"domains": "ๅŸŸๅ",
- "countries": "ๅ›ฝๅฎถ",
+ "countries": "ๅœฐๅŒบ",
"proxies": "ไปฃ็†",
"rules": "่ง„ๅˆ™",
"network": "็ฝ‘็ปœ",
@@ -84,7 +84,7 @@
"viewAll": "ๆŸฅ็œ‹ๅ…จ้ƒจ"
},
"topCountries": {
- "title": "Top ๅ›ฝๅฎถ",
+ "title": "็ƒญ้—จๅœฐๅŒบ",
"viewAll": "ๆŸฅ็œ‹ๅ…จ้ƒจ",
"sortByTraffic": "ๆŒ‰ๆต้‡ๆŽ’ๅบ",
"sortByConnections": "ๆŒ‰่ฟžๆŽฅๆŽ’ๅบ"
@@ -107,6 +107,8 @@
"unknown": "ๆœช็Ÿฅ",
"ips": "IPๆ•ฐ",
"ipCount": "IPๆ•ฐ",
+ "proxy": "ไปฃ็†่Š‚็‚น",
+ "proxyTraffic": "ไปฃ็†่Š‚็‚นๆต้‡ๆ˜Ž็ป†",
"associatedIPs": "ๅ…ณ่” IP ๅœฐๅ€",
"domainsCount": "ไธชๅŸŸๅ",
"showing": "ๆ˜พ็คบ",
@@ -124,6 +126,8 @@
"location": "ไฝ็ฝฎ",
"domains": "ๅŸŸๅ",
"domainCount": "ๅŸŸๅๆ•ฐ",
+ "proxy": "ไปฃ็†่Š‚็‚น",
+ "proxyTraffic": "ไปฃ็†่Š‚็‚นๆต้‡ๆ˜Ž็ป†",
"associatedDomains": "ๅ…ณ่”ๅŸŸๅ",
"download": "ไธ‹่ฝฝ",
"upload": "ไธŠไผ ",
@@ -136,9 +140,9 @@
"total": "ๆ€ป่ฎก"
},
"countries": {
- "title": "ๅ›ฝๅฎถ/ๅœฐๅŒบ",
- "details": "ๅ›ฝๅฎถ/ๅœฐๅŒบ่ฏฆๆƒ…",
- "distribution": "ๅ›ฝๅฎถ/ๅœฐๅŒบๆต้‡ๅˆ†ๅธƒ",
+ "title": "ๅœฐๅŒบ",
+ "details": "ๅœฐๅŒบ่ฏฆๆƒ…",
+ "distribution": "ๅœฐๅŒบๆต้‡ๅˆ†ๅธƒ",
"continents": "ๅคงๆดฒ๏ผš",
"noData": "ๆš‚ๆ— ๆ•ฐๆฎ",
"connections": "่ฟžๆŽฅ"
@@ -166,12 +170,12 @@
"comingSoon": "ๅฎžๆ—ถ่ฟžๆŽฅ็›‘ๆŽงๅŠŸ่ƒฝๅผ€ๅ‘ไธญ..."
},
"map": {
- "title": "ๅ…จ็ƒๆต้‡ๅˆ†ๅธƒ",
+ "title": "ๅ…จ็ƒๅœฐๅŒบๆต้‡",
"total": "ๆ€ป่ฎก",
"download": "ไธ‹่ฝฝ",
"upload": "ไธŠไผ ",
"connections": "่ฟžๆŽฅๆ•ฐ",
- "hoverHint": "ๆ‚ฌๅœๆŸฅ็œ‹ๅ›ฝๅฎถ่ฏฆๆƒ…",
+ "hoverHint": "ๆ‚ฌๅœๆŸฅ็œ‹ๅœฐๅŒบ่ฏฆๆƒ…",
"traffic": "ๆต้‡๏ผš",
"low": "ไฝŽ",
"high": "้ซ˜"
diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts
index a0952ed..2e1f5ce 100644
--- a/packages/shared/src/index.ts
+++ b/packages/shared/src/index.ts
@@ -66,6 +66,7 @@ export interface IPStats {
lastSeen: string;
asn?: string;
geoIP?: string[];
+ chains?: string[];
}
export interface HourlyStats {
@@ -123,6 +124,14 @@ export interface CountryStats {
lastSeen?: string;
}
+// Per-proxy traffic breakdown for a specific domain or IP
+export interface ProxyTrafficStats {
+ chain: string;
+ totalUpload: number;
+ totalDownload: number;
+ totalConnections: number;
+}
+
// API Response Types
export interface StatsSummary {
totalUpload: number;