mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-12-05 16:07:33 +00:00
feat(proxy): show exit IP and last check time in proxy list
- Expose latency_checked_at (from cached UpdatedAt) on admin proxy list - Show exit IP under location and last check time under created_at - Include region/city in quality check result - Quality check now updates row latency/IP/location on failure too, matching the backend snapshot Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0f66714571
commit
1ba1ae8ef0
9 files changed
+86
-64
No files matched your search
@@ -562,6 +562,7 @@ func ProxyWithAccountCountFromService(p *service.ProxyWithAccountCount) *ProxyWi
|
||||
QualityGrade: p.QualityGrade,
|
||||
QualitySummary: p.QualitySummary,
|
||||
QualityChecked: p.QualityChecked,
|
||||
LatencyChecked: p.LatencyChecked,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -607,6 +608,7 @@ func ProxyWithAccountCountFromServiceAdmin(p *service.ProxyWithAccountCount) *Ad
|
||||
QualityGrade: p.QualityGrade,
|
||||
QualitySummary: p.QualitySummary,
|
||||
QualityChecked: p.QualityChecked,
|
||||
LatencyChecked: p.LatencyChecked,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -461,20 +461,21 @@ type Proxy struct {
|
||||
|
||||
type ProxyWithAccountCount struct {
|
||||
Proxy
|
||||
AccountCount int64 `json:"account_count"`
|
||||
LatencyMs *int64 `json:"latency_ms,omitempty"`
|
||||
LatencyStatus string `json:"latency_status,omitempty"`
|
||||
LatencyMessage string `json:"latency_message,omitempty"`
|
||||
IPAddress string `json:"ip_address,omitempty"`
|
||||
Country string `json:"country,omitempty"`
|
||||
CountryCode string `json:"country_code,omitempty"`
|
||||
Region string `json:"region,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
QualityStatus string `json:"quality_status,omitempty"`
|
||||
QualityScore *int `json:"quality_score,omitempty"`
|
||||
QualityGrade string `json:"quality_grade,omitempty"`
|
||||
QualitySummary string `json:"quality_summary,omitempty"`
|
||||
QualityChecked *int64 `json:"quality_checked,omitempty"`
|
||||
AccountCount int64 `json:"account_count"`
|
||||
LatencyMs *int64 `json:"latency_ms,omitempty"`
|
||||
LatencyStatus string `json:"latency_status,omitempty"`
|
||||
LatencyMessage string `json:"latency_message,omitempty"`
|
||||
IPAddress string `json:"ip_address,omitempty"`
|
||||
Country string `json:"country,omitempty"`
|
||||
CountryCode string `json:"country_code,omitempty"`
|
||||
Region string `json:"region,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
QualityStatus string `json:"quality_status,omitempty"`
|
||||
QualityScore *int `json:"quality_score,omitempty"`
|
||||
QualityGrade string `json:"quality_grade,omitempty"`
|
||||
QualitySummary string `json:"quality_summary,omitempty"`
|
||||
QualityChecked *int64 `json:"quality_checked,omitempty"`
|
||||
LatencyChecked *time.Time `json:"latency_checked_at,omitempty"`
|
||||
}
|
||||
|
||||
// AdminProxy 是管理员接口使用的 proxy DTO(包含密码等敏感字段)。
|
||||
@@ -487,20 +488,21 @@ type AdminProxy struct {
|
||||
// AdminProxyWithAccountCount 是管理员接口使用的带账号统计的 proxy DTO。
|
||||
type AdminProxyWithAccountCount struct {
|
||||
AdminProxy
|
||||
AccountCount int64 `json:"account_count"`
|
||||
LatencyMs *int64 `json:"latency_ms,omitempty"`
|
||||
LatencyStatus string `json:"latency_status,omitempty"`
|
||||
LatencyMessage string `json:"latency_message,omitempty"`
|
||||
IPAddress string `json:"ip_address,omitempty"`
|
||||
Country string `json:"country,omitempty"`
|
||||
CountryCode string `json:"country_code,omitempty"`
|
||||
Region string `json:"region,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
QualityStatus string `json:"quality_status,omitempty"`
|
||||
QualityScore *int `json:"quality_score,omitempty"`
|
||||
QualityGrade string `json:"quality_grade,omitempty"`
|
||||
QualitySummary string `json:"quality_summary,omitempty"`
|
||||
QualityChecked *int64 `json:"quality_checked,omitempty"`
|
||||
AccountCount int64 `json:"account_count"`
|
||||
LatencyMs *int64 `json:"latency_ms,omitempty"`
|
||||
LatencyStatus string `json:"latency_status,omitempty"`
|
||||
LatencyMessage string `json:"latency_message,omitempty"`
|
||||
IPAddress string `json:"ip_address,omitempty"`
|
||||
Country string `json:"country,omitempty"`
|
||||
CountryCode string `json:"country_code,omitempty"`
|
||||
Region string `json:"region,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
QualityStatus string `json:"quality_status,omitempty"`
|
||||
QualityScore *int `json:"quality_score,omitempty"`
|
||||
QualityGrade string `json:"quality_grade,omitempty"`
|
||||
QualitySummary string `json:"quality_summary,omitempty"`
|
||||
QualityChecked *int64 `json:"quality_checked,omitempty"`
|
||||
LatencyChecked *time.Time `json:"latency_checked_at,omitempty"`
|
||||
}
|
||||
|
||||
type ProxyAccountSummary struct {
|
||||
|
||||
@@ -300,6 +300,8 @@ func (s *adminServiceImpl) CheckProxyQuality(ctx context.Context, id int64) (*Pr
|
||||
result.ExitIP = exitInfo.IP
|
||||
result.Country = exitInfo.Country
|
||||
result.CountryCode = exitInfo.CountryCode
|
||||
result.Region = exitInfo.Region
|
||||
result.City = exitInfo.City
|
||||
result.BaseLatencyMs = latencyMs
|
||||
result.Items = append(result.Items, ProxyQualityCheckItem{
|
||||
Target: "base_connectivity",
|
||||
@@ -587,6 +589,10 @@ func (s *adminServiceImpl) attachProxyLatency(ctx context.Context, proxies []Pro
|
||||
proxies[i].QualityGrade = info.QualityGrade
|
||||
proxies[i].QualitySummary = info.QualitySummary
|
||||
proxies[i].QualityChecked = info.QualityCheckedAt
|
||||
if !info.UpdatedAt.IsZero() {
|
||||
checkedAt := info.UpdatedAt
|
||||
proxies[i].LatencyChecked = &checkedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -605,6 +605,8 @@ type ProxyQualityCheckResult struct {
|
||||
ExitIP string `json:"exit_ip,omitempty"`
|
||||
Country string `json:"country,omitempty"`
|
||||
CountryCode string `json:"country_code,omitempty"`
|
||||
Region string `json:"region,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
BaseLatencyMs int64 `json:"base_latency_ms,omitempty"`
|
||||
PassedCount int `json:"passed_count"`
|
||||
WarnCount int `json:"warn_count"`
|
||||
|
||||
@@ -66,6 +66,7 @@ type ProxyWithAccountCount struct {
|
||||
QualityGrade string
|
||||
QualitySummary string
|
||||
QualityChecked *int64
|
||||
LatencyChecked *time.Time
|
||||
}
|
||||
|
||||
type ProxyAccountSummary struct {
|
||||
|
||||
@@ -123,6 +123,7 @@ export default {
|
||||
batchTest: 'Test All Proxies',
|
||||
testFailed: 'Failed',
|
||||
latencyFailed: 'Connection failed',
|
||||
lastCheckedAt: 'Checked {time}',
|
||||
batchTestEmpty: 'No proxies available for testing',
|
||||
batchTestDone: 'Batch test completed for {count} proxies',
|
||||
batchTestFailed: 'Batch test failed',
|
||||
|
||||
@@ -140,6 +140,7 @@ export default {
|
||||
batchTest: '批量测试',
|
||||
testFailed: '失败',
|
||||
latencyFailed: '链接失败',
|
||||
lastCheckedAt: '检测于 {time}',
|
||||
batchTestEmpty: '暂无可测试的代理',
|
||||
batchTestDone: '批量测试完成,共测试 {count} 个代理',
|
||||
batchTestFailed: '批量测试失败',
|
||||
|
||||
@@ -986,6 +986,7 @@ export interface Proxy {
|
||||
quality_grade?: string
|
||||
quality_summary?: string
|
||||
quality_checked?: number
|
||||
latency_checked_at?: string
|
||||
expires_at: string | null
|
||||
fallback_mode: 'none' | 'proxy' | 'direct'
|
||||
backup_proxy_id?: number | null
|
||||
@@ -1019,6 +1020,8 @@ export interface ProxyQualityCheckResult {
|
||||
exit_ip?: string
|
||||
country?: string
|
||||
country_code?: string
|
||||
region?: string
|
||||
city?: string
|
||||
base_latency_ms?: number
|
||||
passed_count: number
|
||||
warn_count: number
|
||||
|
||||
@@ -184,17 +184,22 @@
|
||||
</template>
|
||||
|
||||
<template #cell-location="{ row }">
|
||||
<div class="flex items-center gap-2">
|
||||
<img
|
||||
v-if="row.country_code"
|
||||
:src="flagUrl(row.country_code)"
|
||||
:alt="row.country || row.country_code"
|
||||
class="h-4 w-6 rounded-sm"
|
||||
/>
|
||||
<span v-if="formatLocation(row)" class="text-sm text-gray-700 dark:text-gray-200">
|
||||
{{ formatLocation(row) }}
|
||||
<div class="flex flex-col">
|
||||
<div class="flex items-center gap-2">
|
||||
<img
|
||||
v-if="row.country_code"
|
||||
:src="flagUrl(row.country_code)"
|
||||
:alt="row.country || row.country_code"
|
||||
class="h-4 w-6 rounded-sm"
|
||||
/>
|
||||
<span v-if="formatLocation(row)" class="text-sm text-gray-700 dark:text-gray-200">
|
||||
{{ formatLocation(row) }}
|
||||
</span>
|
||||
<span v-else class="text-sm text-gray-400">-</span>
|
||||
</div>
|
||||
<span v-if="row.ip_address" class="font-mono text-xs text-gray-500 dark:text-gray-400">
|
||||
{{ row.ip_address }}
|
||||
</span>
|
||||
<span v-else class="text-sm text-gray-400">-</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -253,7 +258,12 @@
|
||||
</template>
|
||||
|
||||
<template #cell-created_at="{ row }">
|
||||
<span class="text-xs text-gray-600 dark:text-gray-300">{{ formatDateTime(row.created_at) }}</span>
|
||||
<div class="flex flex-col text-xs">
|
||||
<span class="text-gray-600 dark:text-gray-300">{{ formatDateTime(row.created_at) }}</span>
|
||||
<span v-if="row.latency_checked_at" class="text-gray-500 dark:text-gray-400">
|
||||
{{ t('admin.proxies.lastCheckedAt', { time: formatDateTime(row.latency_checked_at) }) }}
|
||||
</span>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #cell-status="{ value }">
|
||||
@@ -1519,6 +1529,23 @@ const applyLatencyResult = (
|
||||
target.city = undefined
|
||||
}
|
||||
target.latency_message = result.message
|
||||
target.latency_checked_at = new Date().toISOString()
|
||||
}
|
||||
|
||||
// Mirrors the backend quality snapshot: it overwrites latency/IP/location whether or not
|
||||
// base connectivity passed, so the row stays consistent without a reload.
|
||||
const applyQualityLatencyResult = (proxyId: number, result: ProxyQualityCheckResult) => {
|
||||
const baseStep = result.items.find((item) => item.target === 'base_connectivity')
|
||||
applyLatencyResult(proxyId, {
|
||||
success: baseStep?.status === 'pass',
|
||||
latency_ms: result.base_latency_ms || undefined,
|
||||
message: result.summary,
|
||||
ip_address: result.exit_ip,
|
||||
country: result.country,
|
||||
country_code: result.country_code,
|
||||
region: result.region,
|
||||
city: result.city
|
||||
})
|
||||
}
|
||||
|
||||
const summarizeQualityStatus = (result: ProxyQualityCheckResult): Proxy['quality_status'] => {
|
||||
@@ -1607,17 +1634,7 @@ const handleQualityCheck = async (proxy: Proxy) => {
|
||||
qualityReport.value = result
|
||||
showQualityReportDialog.value = true
|
||||
|
||||
const baseStep = result.items.find((item) => item.target === 'base_connectivity')
|
||||
if (baseStep && baseStep.status === 'pass') {
|
||||
applyLatencyResult(proxy.id, {
|
||||
success: true,
|
||||
latency_ms: result.base_latency_ms,
|
||||
message: result.summary,
|
||||
ip_address: result.exit_ip,
|
||||
country: result.country,
|
||||
country_code: result.country_code
|
||||
})
|
||||
}
|
||||
applyQualityLatencyResult(proxy.id, result)
|
||||
applyQualityResult(proxy.id, result)
|
||||
|
||||
appStore.showSuccess(
|
||||
@@ -1649,20 +1666,7 @@ const runBatchProxyQualityChecks = async (ids: number[]) => {
|
||||
startQualityCheckingProxy(current)
|
||||
try {
|
||||
const result = await adminAPI.proxies.checkProxyQuality(current)
|
||||
const target = proxies.value.find((proxy) => proxy.id === current)
|
||||
if (target) {
|
||||
const baseStep = result.items.find((item) => item.target === 'base_connectivity')
|
||||
if (baseStep && baseStep.status === 'pass') {
|
||||
applyLatencyResult(current, {
|
||||
success: true,
|
||||
latency_ms: result.base_latency_ms,
|
||||
message: result.summary,
|
||||
ip_address: result.exit_ip,
|
||||
country: result.country,
|
||||
country_code: result.country_code
|
||||
})
|
||||
}
|
||||
}
|
||||
applyQualityLatencyResult(current, result)
|
||||
applyQualityResult(current, result)
|
||||
if (result.challenge_count > 0) {
|
||||
challenge++
|
||||
|
||||
Reference in new issue
Block a user