feat(cloudflare): 新增 Cloudflare 隧道独立模块并发布 v1.6.0
This commit is contained in:
@@ -37,6 +37,10 @@ import type {
|
||||
SystemLogEntry,
|
||||
NotifyTestPayload,
|
||||
UpdateStatus,
|
||||
CfMirror,
|
||||
CfRuntimeStatus,
|
||||
CfTunnel,
|
||||
CfTunnelPayload,
|
||||
} from './types'
|
||||
|
||||
export function asList<T>(value: T[] | null | undefined): T[] {
|
||||
@@ -474,4 +478,33 @@ export const api = {
|
||||
}
|
||||
return (await response.json()) as { message: string }
|
||||
},
|
||||
|
||||
listCfTunnels: () => request<CfTunnel[]>('/api/cloudflare/tunnels'),
|
||||
getCfTunnel: (id: number) => request<CfTunnel>(`/api/cloudflare/tunnels/${id}`),
|
||||
createCfTunnel: (payload: CfTunnelPayload) =>
|
||||
request<CfTunnel>('/api/cloudflare/tunnels', { method: 'POST', body: JSON.stringify(payload) }),
|
||||
updateCfTunnel: (id: number, payload: CfTunnelPayload) =>
|
||||
request<CfTunnel>(`/api/cloudflare/tunnels/${id}`, { method: 'PUT', body: JSON.stringify(payload) }),
|
||||
deleteCfTunnel: (id: number) =>
|
||||
request<{ ok: boolean }>(`/api/cloudflare/tunnels/${id}`, { method: 'DELETE' }),
|
||||
startCfTunnel: (id: number) =>
|
||||
request<CfTunnel>(`/api/cloudflare/tunnels/${id}/start`, { method: 'POST' }),
|
||||
stopCfTunnel: (id: number) =>
|
||||
request<CfTunnel>(`/api/cloudflare/tunnels/${id}/stop`, { method: 'POST' }),
|
||||
restartCfTunnel: (id: number) =>
|
||||
request<CfTunnel>(`/api/cloudflare/tunnels/${id}/restart`, { method: 'POST' }),
|
||||
getCfTunnelStatus: (id: number) =>
|
||||
request<CfRuntimeStatus>(`/api/cloudflare/tunnels/${id}/status`),
|
||||
getCfTunnelLogs: (id: number, lines = 200) =>
|
||||
request<{ output: string }>(`/api/cloudflare/tunnels/${id}/logs?lines=${lines}`),
|
||||
getCfTunnelConfig: (id: number) =>
|
||||
request<{ content: string }>(`/api/cloudflare/tunnels/${id}/config`),
|
||||
getCfBinary: () => request<{ version: string; mirrors: CfMirror[] }>('/api/cloudflare/binary'),
|
||||
downloadCfBinary: (mirror: string) =>
|
||||
request<{ ok: boolean; version: string }>('/api/cloudflare/binary/download', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ mirror }),
|
||||
}),
|
||||
getCfIngressCandidates: () =>
|
||||
request<{ hostnames: string[] }>('/api/cloudflare/ingress-candidates'),
|
||||
}
|
||||
|
||||
@@ -1038,3 +1038,61 @@ export interface StatusPagePayload {
|
||||
unknown: number
|
||||
routes: StatusPageRoute[]
|
||||
}
|
||||
|
||||
// Cloudflare Tunnel 独立模块
|
||||
export interface CfNetworkSettings {
|
||||
transport_protocol: string
|
||||
edge_ip_version: string
|
||||
ha_connections: number
|
||||
proxy_mode: string
|
||||
origin_ca_pool?: string
|
||||
no_tls_verify?: boolean
|
||||
http_host_header?: string
|
||||
}
|
||||
|
||||
export interface CfTunnel {
|
||||
id: number
|
||||
name: string
|
||||
mode: string
|
||||
tunnel_id: string
|
||||
account_tag: string
|
||||
config_path: string
|
||||
creds_path: string
|
||||
log_path: string
|
||||
network: CfNetworkSettings
|
||||
status: string
|
||||
last_error?: string
|
||||
metrics_port?: number
|
||||
auto_start: boolean
|
||||
created_at: string
|
||||
updated_at: string
|
||||
}
|
||||
|
||||
export interface CfRuntimeStatus {
|
||||
running: boolean
|
||||
status: string
|
||||
last_error?: string
|
||||
metrics_port?: number
|
||||
connections: number
|
||||
latency_ms: number
|
||||
bandwidth_in: number
|
||||
bandwidth_out: number
|
||||
transport: string
|
||||
bandwidth_notice?: string
|
||||
}
|
||||
|
||||
export interface CfMirror {
|
||||
id: string
|
||||
name: string
|
||||
base: string
|
||||
}
|
||||
|
||||
export interface CfTunnelPayload {
|
||||
name: string
|
||||
mode: string
|
||||
token?: string
|
||||
hostnames: string[]
|
||||
origin_service?: string
|
||||
network: CfNetworkSettings
|
||||
auto_start: boolean
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user