Files
ppanel-web/crates/migrate/go/migrate/sql/mysql/02101_subscribe_application.up.sql
T
2026-07-07 16:33:17 +08:00

28 lines
91 KiB
PL/PgSQL

DROP TABLE IF EXISTS `subscribe_application`;
CREATE TABLE IF NOT EXISTS `subscribe_application` (
`id` bigint NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'Application Name',
`icon` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT 'Application Icon',
`description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT 'Application Description',
`scheme` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'Application Scheme',
`user_agent` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT 'User Agent',
`is_default` tinyint(1) NOT NULL DEFAULT '0' COMMENT 'Is Default Application',
`subscribe_template` mediumtext CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci COMMENT 'Subscribe Template',
`output_format` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT 'yaml' COMMENT 'Output Format',
`download_link` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'Download Link',
`created_at` datetime(3) DEFAULT NULL COMMENT 'Create Time',
`updated_at` datetime(3) DEFAULT NULL COMMENT 'Update Time',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- ----------------------------
-- Records of subscribe_application
-- ----------------------------
BEGIN;
INSERT INTO `subscribe_application` (`id`, `name`, `icon`, `description`, `scheme`, `user_agent`, `is_default`, `subscribe_template`, `output_format`, `download_link`, `created_at`, `updated_at`) VALUES (1, 'Default', '', '', '', 'default', 1, '{{- $GiB := 1073741824.0 -}}\n{{- $used := printf \"%.2f\" (divf (add (.UserInfo.Download | default 0 | float64) (.UserInfo.Upload | default 0 | float64)) $GiB) -}}\n{{- $traffic := (.UserInfo.Traffic | default 0 | float64) -}}\n{{- $total := printf \"%.2f\" (divf $traffic $GiB) -}}\n\n{{- $ExpiredAt := \"\" -}}\n{{- $expStr := printf \"%v\" .UserInfo.ExpiredAt -}}\n{{- if regexMatch `^[0-9]+$` $expStr -}}\n {{- $ts := $expStr | float64 -}}\n {{- $sec := ternary (divf $ts 1000.0) $ts (ge (len $expStr) 13) -}}\n {{- $ExpiredAt = (date \"2006-01-02 15:04:05\" (unixEpoch ($sec | int64))) -}}\n{{- else -}}\n {{- $ExpiredAt = $expStr -}}\n{{- end -}}\n\n{{- $sortFields := list \"Sort\" \"Port\" \"Name\" -}}\n{{- $sortConfig := dict \"Sort\" \"asc\" \"Port\" \"asc\" \"Name\" \"asc\" -}}\n{{- $byKey := dict -}}\n{{- range $p := .Proxies -}}\n {{- $keyParts := list -}}\n {{- range $field := $sortFields -}}\n {{- $order := index $sortConfig $field -}}\n {{- $val := default \"\" (printf \"%v\" (index $p $field)) -}}\n {{- if or (eq $field \"Sort\") (eq $field \"Port\") -}}\n {{- $val = printf \"%08d\" (int (default 0 (index $p $field))) -}}\n {{- end -}}\n {{- if eq $order \"desc\" -}}\n {{- $val = printf \"~%s\" $val -}}\n {{- end -}}\n {{- $keyParts = append $keyParts $val -}}\n {{- end -}}\n {{- $_ := set $byKey (join \"|\" $keyParts) $p -}}\n{{- end -}}\n{{- $sorted := list -}}\n{{- range $k := sortAlpha (keys $byKey) -}}\n {{- $sorted = append $sorted (index $byKey $k) -}}\n{{- end -}}\n\n{{- $supportSet := dict \"shadowsocks\" true \"vmess\" true \"vless\" true \"trojan\" true \"hysteria2\" true \"hysteria\" true \"tuic\" true \"anytls\" true -}}\n{{- $supportedProxies := list -}}\n{{- range $proxy := $sorted -}}\n {{- if hasKey $supportSet $proxy.Type -}}\n {{- $supportedProxies = append $supportedProxies $proxy -}}\n {{- end -}}\n{{- end -}}\n\nREMARKS={{ .SiteName }}-{{ .SubscribeName }}\nSTATUS=Traffic: {{ $used }} GiB/{{ $total }} GiB | Expires: {{ $ExpiredAt }}\n# Generated at: {{ now | date \"2006-01-02 15:04:05\\n\" }}\n\n{{- range $proxy := $supportedProxies }}\n {{- $common := \"udp=1&tfo=1\" -}}\n\n {{- $server := $proxy.Server -}}\n {{- if and (contains $server \":\") (not (hasPrefix \"[\" $server)) -}}\n {{- $server = printf \"[%s]\" $server -}}\n {{- end -}}\n\n {{- $password := $.UserInfo.Password -}}\n {{- if and (eq $proxy.Type \"shadowsocks\") (ne (default \"\" $proxy.ServerKey) \"\") -}}\n {{- $method := $proxy.Method -}}\n {{- if or (hasPrefix \"2022-blake3-\" $method) (eq $method \"2022-blake3-aes-128-gcm\") (eq $method \"2022-blake3-aes-256-gcm\") -}}\n {{- $userKeyLen := ternary 16 32 (hasSuffix \"128-gcm\" $method) -}}\n {{- $pwdStr := printf \"%s\" $password -}}\n {{- $userKey := ternary $pwdStr (trunc $userKeyLen $pwdStr) (le (len $pwdStr) $userKeyLen) -}}\n {{- $serverB64 := b64enc $proxy.ServerKey -}}\n {{- $userB64 := b64enc $userKey -}}\n {{- $password = printf \"%s:%s\" $serverB64 $userB64 -}}\n {{- end -}}\n {{- end -}}\n\n {{- $SkipVerify := $proxy.AllowInsecure -}}\n\n {{- /* 公共传输层配置函数 */ -}}\n {{- $buildTransportParams := dict -}}\n {{- $transport := default \"tcp\" $proxy.Transport -}}\n {{- if ne $transport \"\" -}}\n {{- $_ := set $buildTransportParams \"type\" (ternary \"ws\" $transport (eq $transport \"websocket\")) -}}\n {{- end -}}\n {{- /* TCP 传输类型配置 */ -}}\n {{- if eq $transport \"tcp\" -}}\n {{- $headerType := default \"none\" $proxy.HeaderType -}}\n {{- if ne $headerType \"none\" -}}\n {{- $_ := set $buildTransportParams \"headerType\" $headerType -}}\n {{- end -}}\n {{- if and (eq $headerType \"http\") (ne (default \"\" $proxy.Host) \"\") -}}\n {{- $_ := set $buildTransportParams \"host\" $proxy.Host -}}\n {{- end -}}\n {{- if and (eq $headerType \"http\") (ne (default \"\" $proxy.Path) \"\") -}}\n {{- $_ := set $buildTransportParams \"path\" ($proxy.Path | urlquery) -}}\n {{- end -}}\n {{- end -}}\n {{- /* WebSocket/xhttp/httpupgrade 传输类型配置 */ -}}\n {{- if and (or (eq $transport \"ws\") (eq $transport \"websocket\") (eq $transport \"xhttp\") (eq $transport \"httpupgrade\")) (ne (default \"\" $proxy.Host) \"\") -}}\n {{- $_ := set $buildTransportParams \"host\" $proxy.Host -}}\n {{- end -}}\n {{- if and (or (eq $transport \"ws\") (eq $transport \"websocket\") (eq $transport \"xhttp\") (eq $transport \"httpupgrade\")) (ne (default \"\" $proxy.Path) \"\") -}}\n {{- $_ := set $buildTransportParams \"path\" ($proxy.Path | urlquery) -}}\n {{- end -}}\n {{- /* gRPC 传输类型配置 */ -}}\n {{- if and (eq $transport \"grpc\") (ne (default \"\" $proxy.ServiceName) \"\") -}}\n {{- $_ := set $buildTransportParams \"serviceName\" $proxy.ServiceName -}}\n {{- end -}}\n {{- /* xhttp 特有配置 */ -}}\n {{- if and (eq $transport \"xhttp\") (ne (default \"\" $proxy.XhttpMode) \"\") -}}\n {{- $_ := set $buildTransportParams \"mode\" $proxy.XhttpMode -}}\n {{- end -}}\n {{- if and (eq $transport \"xhttp\") (ne (default \"\" $proxy.XhttpExtra) \"\") -}}\n {{- $_ := set $buildTransportParams \"extra\" (urlquery $proxy.XhttpExtra) -}}\n {{- end -}}\n\n {{- /* 公共安全层配置 */ -}}\n {{- $buildSecurityParams := dict -}}\n {{- if or (eq $proxy.Security \"tls\") (eq $proxy.Security \"reality\") -}}\n {{- $_ := set $buildSecurityParams \"security\" $proxy.Security -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.SNI) \"\" -}}\n {{- $_ := set $buildSecurityParams \"sni\" $proxy.SNI -}}\n {{- end -}}\n {{- if $SkipVerify -}}\n {{- $_ := set $buildSecurityParams \"allowInsecure\" \"1\" -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.Fingerprint) \"\" -}}\n {{- $_ := set $buildSecurityParams \"fp\" $proxy.Fingerprint -}}\n {{- end -}}\n {{- if and (eq $proxy.Security \"reality\") (ne (default \"\" $proxy.RealityPublicKey) \"\") -}}\n {{- $_ := set $buildSecurityParams \"pbk\" $proxy.RealityPublicKey -}}\n {{- end -}}\n {{- if and (eq $proxy.Security \"reality\") (ne (default \"\" $proxy.RealityShortId) \"\") -}}\n {{- $_ := set $buildSecurityParams \"sid\" $proxy.RealityShortId -}}\n {{- end -}}\n {{- if $proxy.EchEnable -}}\n {{- $_ := set $buildSecurityParams \"ech\" (printf \"%s+udp://1.1.1.1\" (default \"\" $proxy.EchServerName) | urlquery) -}}\n {{- end -}}\n\n {{- if eq $proxy.Type \"shadowsocks\" }}\n {{- $params := list -}}\n {{- /* Shadowsocks 特有的 obfs 插件参数 */ -}}\n {{- if ne (default \"\" $proxy.Obfs) \"\" -}}\n {{- $params = append $params (printf \"obfs=%s\" $proxy.Obfs) -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.ObfsHost) \"\" -}}\n {{- $params = append $params (printf \"obfs-host=%s\" $proxy.ObfsHost) -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.ObfsPath) \"\" -}}\n {{- $params = append $params (printf \"obfs-uri=%s\" ($proxy.ObfsPath | urlquery)) -}}\n {{- end -}}\n {{- /* 使用公共传输层配置 */ -}}\n {{- range $key, $val := $buildTransportParams -}}\n {{- $params = append $params (printf \"%s=%s\" $key $val) -}}\n {{- end -}}\n {{- /* 使用公共安全层配置 */ -}}\n {{- range $key, $val := $buildSecurityParams -}}\n {{- $params = append $params (printf \"%s=%s\" $key $val) -}}\n {{- end -}}\n {{- /* 添加公共参数 */ -}}\n {{- $params = append $params $common }}\nss://{{ printf \"%s:%s\" (default \"aes-128-gcm\" $proxy.Method) $password | b64enc }}@{{ $server }}:{{ $proxy.Port }}?{{ join \"&\" $params }}#{{ $proxy.Name }}\n {{- else if eq $proxy.Type \"vmess\" }}\n {{- $vmessDict := dict \"v\" \"2\" \"ps\" $proxy.Name \"add\" $proxy.Server \"port\" (printf \"%d\" $proxy.Port) \"id\" $password \"aid\" \"0\" \"net\" \"tcp\" \"type\" \"none\" -}}\n {{- if hasKey $buildTransportParams \"type\" -}}\n {{- $_ := set $vmessDict \"net\" (index $buildTransportParams \"type\") -}}\n {{- end -}}\n {{- if hasKey $buildTransportParams \"host\" -}}\n {{- $_ := set $vmessDict \"host\" (index $buildTransportParams \"host\") -}}\n {{- end -}}\n {{- if hasKey $buildTransportParams \"path\" -}}\n {{- $_ := set $vmessDict \"path\" (index $buildTransportParams \"path\") -}}\n {{- end -}}\n {{- if and (eq $transport \"grpc\") (hasKey $buildTransportParams \"serviceName\") -}}\n {{- $_ := set $vmessDict \"path\" (index $buildTransportParams \"serviceName\") -}}\n {{- end -}}\n {{- if hasKey $buildTransportParams \"mode\" -}}\n {{- $_ := set $vmessDict \"xhttpMode\" (index $buildTransportParams \"mode\") -}}\n {{- end -}}\n {{- if hasKey $buildTransportParams \"extra\" -}}\n {{- $_ := set $vmessDict \"xhttpExtra\" (index $buildTransportParams \"extra\") -}}\n {{- end -}}\n {{- if hasKey $buildSecurityParams \"security\" -}}\n {{- $_ := set $vmessDict \"tls\" (index $buildSecurityParams \"security\") -}}\n {{- end -}}\n {{- if hasKey $buildSecurityParams \"sni\" -}}\n {{- $_ := set $vmessDict \"sni\" (index $buildSecurityParams \"sni\") -}}\n {{- end -}}\n {{- if hasKey $buildSecurityParams \"fp\" -}}\n {{- $_ := set $vmessDict \"fp\" (index $buildSecurityParams \"fp\") -}}\n {{- end -}}\n {{- if hasKey $buildSecurityParams \"allowInsecure\" -}}\n {{- $_ := set $vmessDict \"skip-cert-verify\" true -}}\n {{- end -}}\n {{- if hasKey $buildSecurityParams \"ech\" -}}\n {{- $_ := set $vmessDict \"ech\" (index $buildSecurityParams \"ech\") -}}\n {{- end }}\nvmess://{{ $vmessDict | toJson | b64enc }}\n {{- else if eq $proxy.Type \"vless\" }}\n {{- $params := list -}}\n {{- /* 1. Encryption 加密参数 */ -}}\n {{- $encryption := default \"none\" $proxy.Encryption -}}\n {{- if eq $encryption \"none\" -}}\n {{- $params = append $params \"encryption=none\" -}}\n {{- else -}}\n {{- $encParts := list -}}\n {{- $encParts = append $encParts $encryption -}}\n {{- if ne (default \"\" $proxy.EncryptionMode) \"\" -}}\n {{- $encParts = append $encParts $proxy.EncryptionMode -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.EncryptionRtt) \"\" -}}\n {{- $encParts = append $encParts $proxy.EncryptionRtt -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.EncryptionClientPadding) \"\" -}}\n {{- $encParts = append $encParts $proxy.EncryptionClientPadding -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.EncryptionPassword) \"\" -}}\n {{- $encParts = append $encParts $proxy.EncryptionPassword -}}\n {{- end -}}\n {{- $params = append $params (printf \"encryption=%s\" (join \".\" $encParts)) -}}\n {{- end -}}\n {{- /* 2. Flow 流控参数 */ -}}\n {{- if and (ne (default \"\" $proxy.Flow) \"\") (ne $proxy.Flow \"none\") -}}\n {{- $params = append $params (printf \"flow=%s\" $proxy.Flow) -}}\n {{- end -}}\n {{- /* 3. Security 安全参数 */ -}}\n {{- if hasKey $buildSecurityParams \"security\" -}}\n {{- $params = append $params (printf \"security=%s\" (index $buildSecurityParams \"security\")) -}}\n {{- end -}}\n {{- if hasKey $buildSecurityParams \"sni\" -}}\n {{- $params = append $params (printf \"sni=%s\" (index $buildSecurityParams \"sni\")) -}}\n {{- end -}}\n {{- if hasKey $buildSecurityParams \"fp\" -}}\n {{- $params = append $params (printf \"fp=%s\" (index $buildSecurityParams \"fp\")) -}}\n {{- end -}}\n {{- if hasKey $buildSecurityParams \"allowInsecure\" -}}\n {{- $params = append $params \"allowInsecure=1\" -}}\n {{- end -}}\n {{- if hasKey $buildSecurityParams \"pbk\" -}}\n {{- $params = append $params (printf \"pbk=%s\" (index $buildSecurityParams \"pbk\")) -}}\n {{- end -}}\n {{- if hasKey $buildSecurityParams \"sid\" -}}\n {{- $params = append $params (printf \"sid=%s\" (index $buildSecurityParams \"sid\")) -}}\n {{- end -}}\n {{- if hasKey $buildSecurityParams \"ech\" -}}\n {{- $params = append $params (printf \"ech=%s\" (index $buildSecurityParams \"ech\")) -}}\n {{- end -}}\n {{- /* 4. Transport 传输层参数 */ -}}\n {{- if hasKey $buildTransportParams \"type\" -}}\n {{- $params = append $params (printf \"type=%s\" (index $buildTransportParams \"type\")) -}}\n {{- end -}}\n {{- if hasKey $buildTransportParams \"host\" -}}\n {{- $params = append $params (printf \"host=%s\" (index $buildTransportParams \"host\")) -}}\n {{- end -}}\n {{- if hasKey $buildTransportParams \"path\" -}}\n {{- $params = append $params (printf \"path=%s\" (index $buildTransportParams \"path\")) -}}\n {{- end -}}\n {{- if hasKey $buildTransportParams \"serviceName\" -}}\n {{- $params = append $params (printf \"serviceName=%s\" (index $buildTransportParams \"serviceName\")) -}}\n {{- end -}}\n {{- if hasKey $buildTransportParams \"mode\" -}}\n {{- $params = append $params (printf \"mode=%s\" (index $buildTransportParams \"mode\")) -}}\n {{- end -}}\n {{- if hasKey $buildTransportParams \"extra\" -}}\n {{- $params = append $params (printf \"extra=%s\" (index $buildTransportParams \"extra\")) -}}\n {{- end -}}\n {{- /* 5. Common 通用参数 */ -}}\n {{- $params = append $params $common }}\nvless://{{ $password }}@{{ $server }}:{{ $proxy.Port }}?{{ join \"&\" $params }}#{{ $proxy.Name }}\n {{- else if eq $proxy.Type \"trojan\" }}\n {{- $params := list -}}\n {{- range $key, $val := $buildTransportParams -}}\n {{- $params = append $params (printf \"%s=%s\" $key $val) -}}\n {{- end -}}\n {{- range $key, $val := $buildSecurityParams -}}\n {{- $params = append $params (printf \"%s=%s\" $key $val) -}}\n {{- end -}}\n {{- $params = append $params $common }}\ntrojan://{{ $password }}@{{ $server }}:{{ $proxy.Port }}?{{ join \"&\" $params }}#{{ $proxy.Name }}\n {{- else if or (eq $proxy.Type \"hysteria2\") (eq $proxy.Type \"hysteria\") }}\n {{- $params := list -}}\n {{- if ne (default \"\" $proxy.SNI) \"\" -}}\n {{- $params = append $params (printf \"sni=%s\" $proxy.SNI) -}}\n {{- end -}}\n {{- if $proxy.AllowInsecure -}}\n {{- $params = append $params \"insecure=1\" -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.ObfsPassword) \"\" -}}\n {{- $params = append $params (printf \"obfs=salamander&obfs-password=%s\" $proxy.ObfsPassword) -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.HopPorts) \"\" -}}\n {{- $params = append $params (printf \"mport=%s\" $proxy.HopPorts) -}}\n {{- end }}\nhysteria2://{{- if ne $password \"\" -}}{{ $password }}@{{- end -}}{{ $server }}:{{ $proxy.Port }}?{{ join \"&\" (append $params $common) }}#{{ $proxy.Name | urlquery }}\n {{- else if eq $proxy.Type \"tuic\" }}\n {{- $params := list -}}\n {{- if ne (default \"\" $proxy.CongestionController) \"\" -}}\n {{- $params = append $params (printf \"congestion_controller=%s\" $proxy.CongestionController) -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.UDPRelayMode) \"\" -}}\n {{- $params = append $params (printf \"udp_relay_mode=%s\" $proxy.UDPRelayMode) -}}\n {{- end -}}\n {{- if $proxy.ReduceRtt -}}\n {{- $params = append $params \"reduce_rtt=1\" -}}\n {{- end -}}\n {{- if $proxy.DisableSNI -}}\n {{- $params = append $params \"disable_sni=1\" -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.SNI) \"\" -}}\n {{- $params = append $params (printf \"sni=%s\" $proxy.SNI) -}}\n {{- end -}}\n {{- if $proxy.AllowInsecure -}}\n {{- $params = append $params \"allow_insecure=1\" -}}\n {{- end -}}\n {{- $params = append $params $common }}\ntuic://{{ default \"\" $proxy.ServerKey }}:{{ $password }}@{{ $server }}:{{ $proxy.Port }}?{{ join \"&\" $params }}#{{ $proxy.Name }}\n {{- else if eq $proxy.Type \"anytls\" }}\n {{- $params := list -}}\n {{- /* 使用公共传输层配置 */ -}}\n {{- range $key, $val := $buildTransportParams -}}\n {{- $params = append $params (printf \"%s=%s\" $key $val) -}}\n {{- end -}}\n {{- /* 使用公共安全层配置 */ -}}\n {{- range $key, $val := $buildSecurityParams -}}\n {{- $params = append $params (printf \"%s=%s\" $key $val) -}}\n {{- end -}}\n {{- $params = append $params $common }}\nanytls://{{ $password }}@{{ $server }}:{{ $proxy.Port }}?{{ join \"&\" $params }}#{{ $proxy.Name }}\n {{- else if or (eq $proxy.Type \"http\") (eq $proxy.Type \"https\") }}\n {{- $user := default $password $proxy.Username }}\nhttp{{- if eq $proxy.Type \"https\" -}}s{{- end -}}://{{- if or (ne (default \"\" $user) \"\") (ne (default \"\" $password) \"\") -}}{{ $user }}:{{ $password }}@{{- end -}}{{ $server }}:{{ $proxy.Port }}#{{ $proxy.Name }}\n {{- else if or (eq $proxy.Type \"socks\") (eq $proxy.Type \"socks5\") (eq $proxy.Type \"socks5-tls\") }}\n {{- $user := default $password $proxy.Username }}\nsocks5://{{- if or (ne (default \"\" $user) \"\") (ne (default \"\" $password) \"\") -}}{{ $user }}:{{ $password }}@{{- end -}}{{ $server }}:{{ $proxy.Port }}{{- if eq $proxy.Type \"socks5-tls\" }}?tls=1{{- end }}#{{ $proxy.Name }}\n {{- end }}\n{{- end }}\n', 'base64', '{}', '2025-08-12 22:57:56.711', '2025-08-15 21:45:20.181');
INSERT INTO `subscribe_application` (`id`, `name`, `icon`, `description`, `scheme`, `user_agent`, `is_default`, `subscribe_template`, `output_format`, `download_link`, `created_at`, `updated_at`) VALUES (2, 'Shadowrocket', '', '', 'shadowrocket://add/sub://${window.btoa(url)}?remark=${encodeURIComponent(name)}', 'Shadowrocket', 0, '{{- $GiB := 1073741824.0 -}}\n{{- $used := printf \"%.2f\" (divf (add (.UserInfo.Download | default 0 | float64) (.UserInfo.Upload | default 0 | float64)) $GiB) -}}\n{{- $traffic := (.UserInfo.Traffic | default 0 | float64) -}}\n{{- $total := printf \"%.2f\" (divf $traffic $GiB) -}}\n\n{{- $ExpiredAt := \"\" -}}\n{{- $expStr := printf \"%v\" .UserInfo.ExpiredAt -}}\n{{- if regexMatch `^[0-9]+$` $expStr -}}\n {{- $ts := $expStr | float64 -}}\n {{- $sec := ternary (divf $ts 1000.0) $ts (ge (len $expStr) 13) -}}\n {{- $ExpiredAt = (date \"2006-01-02 15:04:05\" (unixEpoch ($sec | int64))) -}}\n{{- else -}}\n {{- $ExpiredAt = $expStr -}}\n{{- end -}}\n\n{{- $sortFields := list \"Sort\" \"Port\" \"Name\" -}}\n{{- $sortConfig := dict \"Sort\" \"asc\" \"Port\" \"asc\" \"Name\" \"asc\" -}}\n{{- $byKey := dict -}}\n{{- range $p := .Proxies -}}\n {{- $keyParts := list -}}\n {{- range $field := $sortFields -}}\n {{- $order := index $sortConfig $field -}}\n {{- $val := default \"\" (printf \"%v\" (index $p $field)) -}}\n {{- if or (eq $field \"Sort\") (eq $field \"Port\") -}}\n {{- $val = printf \"%08d\" (int (default 0 (index $p $field))) -}}\n {{- end -}}\n {{- if eq $order \"desc\" -}}\n {{- $val = printf \"~%s\" $val -}}\n {{- end -}}\n {{- $keyParts = append $keyParts $val -}}\n {{- end -}}\n {{- $_ := set $byKey (join \"|\" $keyParts) $p -}}\n{{- end -}}\n{{- $sorted := list -}}\n{{- range $k := sortAlpha (keys $byKey) -}}\n {{- $sorted = append $sorted (index $byKey $k) -}}\n{{- end -}}\n\n{{- $supportSet := dict \"shadowsocks\" true \"vmess\" true \"vless\" true \"trojan\" true \"hysteria2\" true \"hysteria\" true \"tuic\" true \"anytls\" true -}}\n{{- $supportedProxies := list -}}\n{{- range $proxy := $sorted -}}\n {{- if hasKey $supportSet $proxy.Type -}}\n {{- $supportedProxies = append $supportedProxies $proxy -}}\n {{- end -}}\n{{- end -}}\n\nREMARKS={{ .SiteName }}-{{ .SubscribeName }}\nSTATUS=Traffic: {{ $used }} GiB/{{ $total }} GiB | Expires: {{ $ExpiredAt }}\n# Generated at: {{ now | date \"2006-01-02 15:04:05\\n\" }}\n\n{{- range $proxy := $supportedProxies }}\n {{- $common := \"udp=1&tfo=1\" -}}\n\n {{- $server := $proxy.Server -}}\n {{- if and (contains $server \":\") (not (hasPrefix \"[\" $server)) -}}\n {{- $server = printf \"[%s]\" $server -}}\n {{- end -}}\n\n {{- $password := $.UserInfo.Password -}}\n {{- if and (eq $proxy.Type \"shadowsocks\") (ne (default \"\" $proxy.ServerKey) \"\") -}}\n {{- $method := $proxy.Method -}}\n {{- if or (hasPrefix \"2022-blake3-\" $method) (eq $method \"2022-blake3-aes-128-gcm\") (eq $method \"2022-blake3-aes-256-gcm\") -}}\n {{- $userKeyLen := ternary 16 32 (hasSuffix \"128-gcm\" $method) -}}\n {{- $pwdStr := printf \"%s\" $password -}}\n {{- $userKey := ternary $pwdStr (trunc $userKeyLen $pwdStr) (le (len $pwdStr) $userKeyLen) -}}\n {{- $serverB64 := b64enc $proxy.ServerKey -}}\n {{- $userB64 := b64enc $userKey -}}\n {{- $password = printf \"%s:%s\" $serverB64 $userB64 -}}\n {{- end -}}\n {{- end -}}\n\n {{- $SkipVerify := $proxy.AllowInsecure -}}\n\n {{- /* 公共传输层配置函数 */ -}}\n {{- $buildTransportParams := dict -}}\n {{- $transport := default \"tcp\" $proxy.Transport -}}\n {{- if ne $transport \"\" -}}\n {{- $_ := set $buildTransportParams \"type\" (ternary \"ws\" $transport (eq $transport \"websocket\")) -}}\n {{- end -}}\n {{- /* TCP 传输类型配置 */ -}}\n {{- if eq $transport \"tcp\" -}}\n {{- $headerType := default \"none\" $proxy.HeaderType -}}\n {{- if ne $headerType \"none\" -}}\n {{- $_ := set $buildTransportParams \"headerType\" $headerType -}}\n {{- end -}}\n {{- if and (eq $headerType \"http\") (ne (default \"\" $proxy.Host) \"\") -}}\n {{- $_ := set $buildTransportParams \"host\" $proxy.Host -}}\n {{- end -}}\n {{- if and (eq $headerType \"http\") (ne (default \"\" $proxy.Path) \"\") -}}\n {{- $_ := set $buildTransportParams \"path\" ($proxy.Path | urlquery) -}}\n {{- end -}}\n {{- end -}}\n {{- /* WebSocket/xhttp/httpupgrade 传输类型配置 */ -}}\n {{- if and (or (eq $transport \"ws\") (eq $transport \"websocket\") (eq $transport \"xhttp\") (eq $transport \"httpupgrade\")) (ne (default \"\" $proxy.Host) \"\") -}}\n {{- $_ := set $buildTransportParams \"host\" $proxy.Host -}}\n {{- end -}}\n {{- if and (or (eq $transport \"ws\") (eq $transport \"websocket\") (eq $transport \"xhttp\") (eq $transport \"httpupgrade\")) (ne (default \"\" $proxy.Path) \"\") -}}\n {{- $_ := set $buildTransportParams \"path\" ($proxy.Path | urlquery) -}}\n {{- end -}}\n {{- /* gRPC 传输类型配置 */ -}}\n {{- if and (eq $transport \"grpc\") (ne (default \"\" $proxy.ServiceName) \"\") -}}\n {{- $_ := set $buildTransportParams \"serviceName\" $proxy.ServiceName -}}\n {{- end -}}\n {{- /* xhttp 特有配置 */ -}}\n {{- if and (eq $transport \"xhttp\") (ne (default \"\" $proxy.XhttpMode) \"\") -}}\n {{- $_ := set $buildTransportParams \"mode\" $proxy.XhttpMode -}}\n {{- end -}}\n {{- if and (eq $transport \"xhttp\") (ne (default \"\" $proxy.XhttpExtra) \"\") -}}\n {{- $_ := set $buildTransportParams \"extra\" (urlquery $proxy.XhttpExtra) -}}\n {{- end -}}\n\n {{- /* 公共安全层配置 */ -}}\n {{- $buildSecurityParams := dict -}}\n {{- if or (eq $proxy.Security \"tls\") (eq $proxy.Security \"reality\") -}}\n {{- $_ := set $buildSecurityParams \"security\" $proxy.Security -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.SNI) \"\" -}}\n {{- $_ := set $buildSecurityParams \"sni\" $proxy.SNI -}}\n {{- end -}}\n {{- if $SkipVerify -}}\n {{- $_ := set $buildSecurityParams \"allowInsecure\" \"1\" -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.Fingerprint) \"\" -}}\n {{- $_ := set $buildSecurityParams \"fp\" $proxy.Fingerprint -}}\n {{- end -}}\n {{- if and (eq $proxy.Security \"reality\") (ne (default \"\" $proxy.RealityPublicKey) \"\") -}}\n {{- $_ := set $buildSecurityParams \"pbk\" $proxy.RealityPublicKey -}}\n {{- end -}}\n {{- if and (eq $proxy.Security \"reality\") (ne (default \"\" $proxy.RealityShortId) \"\") -}}\n {{- $_ := set $buildSecurityParams \"sid\" $proxy.RealityShortId -}}\n {{- end -}}\n\n {{- if eq $proxy.Type \"shadowsocks\" }}\n {{- $params := list -}}\n {{- /* Shadowsocks 特有的 obfs 插件参数 */ -}}\n {{- if ne (default \"\" $proxy.Obfs) \"\" -}}\n {{- $params = append $params (printf \"obfs=%s\" $proxy.Obfs) -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.ObfsHost) \"\" -}}\n {{- $params = append $params (printf \"obfs-host=%s\" $proxy.ObfsHost) -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.ObfsPath) \"\" -}}\n {{- $params = append $params (printf \"obfs-uri=%s\" ($proxy.ObfsPath | urlquery)) -}}\n {{- end -}}\n {{- /* 使用公共传输层配置 */ -}}\n {{- range $key, $val := $buildTransportParams -}}\n {{- $params = append $params (printf \"%s=%s\" $key $val) -}}\n {{- end -}}\n {{- /* 使用公共安全层配置 */ -}}\n {{- range $key, $val := $buildSecurityParams -}}\n {{- $params = append $params (printf \"%s=%s\" $key $val) -}}\n {{- end -}}\n {{- /* 添加公共参数 */ -}}\n {{- $params = append $params $common }}\nss://{{ printf \"%s:%s\" (default \"aes-128-gcm\" $proxy.Method) $password | b64enc }}@{{ $server }}:{{ $proxy.Port }}?{{ join \"&\" $params }}#{{ $proxy.Name }}\n {{- else if eq $proxy.Type \"vmess\" }}\n {{- $vmessDict := dict \"v\" \"2\" \"ps\" $proxy.Name \"add\" $proxy.Server \"port\" (printf \"%d\" $proxy.Port) \"id\" $password \"aid\" \"0\" \"net\" \"tcp\" \"type\" \"none\" -}}\n {{- if hasKey $buildTransportParams \"type\" -}}\n {{- $_ := set $vmessDict \"net\" (index $buildTransportParams \"type\") -}}\n {{- end -}}\n {{- if hasKey $buildTransportParams \"host\" -}}\n {{- $_ := set $vmessDict \"host\" (index $buildTransportParams \"host\") -}}\n {{- end -}}\n {{- if hasKey $buildTransportParams \"path\" -}}\n {{- $_ := set $vmessDict \"path\" (index $buildTransportParams \"path\") -}}\n {{- end -}}\n {{- if and (eq $transport \"grpc\") (hasKey $buildTransportParams \"serviceName\") -}}\n {{- $_ := set $vmessDict \"path\" (index $buildTransportParams \"serviceName\") -}}\n {{- end -}}\n {{- if hasKey $buildTransportParams \"mode\" -}}\n {{- $_ := set $vmessDict \"xhttpMode\" (index $buildTransportParams \"mode\") -}}\n {{- end -}}\n {{- if hasKey $buildTransportParams \"extra\" -}}\n {{- $_ := set $vmessDict \"xhttpExtra\" (index $buildTransportParams \"extra\") -}}\n {{- end -}}\n {{- if hasKey $buildSecurityParams \"security\" -}}\n {{- $_ := set $vmessDict \"tls\" (index $buildSecurityParams \"security\") -}}\n {{- end -}}\n {{- if hasKey $buildSecurityParams \"sni\" -}}\n {{- $_ := set $vmessDict \"sni\" (index $buildSecurityParams \"sni\") -}}\n {{- end -}}\n {{- if hasKey $buildSecurityParams \"fp\" -}}\n {{- $_ := set $vmessDict \"fp\" (index $buildSecurityParams \"fp\") -}}\n {{- end -}}\n {{- if hasKey $buildSecurityParams \"allowInsecure\" -}}\n {{- $_ := set $vmessDict \"skip-cert-verify\" true -}}\n {{- end }}\nvmess://{{ $vmessDict | toJson | b64enc }}\n {{- else if eq $proxy.Type \"vless\" }}\n {{- $params := list -}}\n {{- /* 1. Encryption 加密参数 */ -}}\n {{- $encryption := default \"none\" $proxy.Encryption -}}\n {{- if eq $encryption \"none\" -}}\n {{- $params = append $params \"encryption=none\" -}}\n {{- else -}}\n {{- $encParts := list -}}\n {{- $encParts = append $encParts $encryption -}}\n {{- if ne (default \"\" $proxy.EncryptionMode) \"\" -}}\n {{- $encParts = append $encParts $proxy.EncryptionMode -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.EncryptionRtt) \"\" -}}\n {{- $encParts = append $encParts $proxy.EncryptionRtt -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.EncryptionClientPadding) \"\" -}}\n {{- $encParts = append $encParts $proxy.EncryptionClientPadding -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.EncryptionPassword) \"\" -}}\n {{- $encParts = append $encParts $proxy.EncryptionPassword -}}\n {{- end -}}\n {{- $params = append $params (printf \"encryption=%s\" (join \".\" $encParts)) -}}\n {{- end -}}\n {{- /* 2. Flow 流控参数 */ -}}\n {{- if ne (default \"\" $proxy.Flow) \"none\" -}}\n {{- $params = append $params (printf \"flow=%s\" $proxy.Flow) -}}\n {{- end -}}\n {{- /* 3. Security 安全参数 */ -}}\n {{- if hasKey $buildSecurityParams \"security\" -}}\n {{- $params = append $params (printf \"security=%s\" (index $buildSecurityParams \"security\")) -}}\n {{- end -}}\n {{- if hasKey $buildSecurityParams \"sni\" -}}\n {{- $params = append $params (printf \"sni=%s\" (index $buildSecurityParams \"sni\")) -}}\n {{- end -}}\n {{- if hasKey $buildSecurityParams \"fp\" -}}\n {{- $params = append $params (printf \"fp=%s\" (index $buildSecurityParams \"fp\")) -}}\n {{- end -}}\n {{- if hasKey $buildSecurityParams \"allowInsecure\" -}}\n {{- $params = append $params \"allowInsecure=1\" -}}\n {{- end -}}\n {{- if hasKey $buildSecurityParams \"pbk\" -}}\n {{- $params = append $params (printf \"pbk=%s\" (index $buildSecurityParams \"pbk\")) -}}\n {{- end -}}\n {{- if hasKey $buildSecurityParams \"sid\" -}}\n {{- $params = append $params (printf \"sid=%s\" (index $buildSecurityParams \"sid\")) -}}\n {{- end -}}\n {{- /* 4. Transport 传输层参数 */ -}}\n {{- if hasKey $buildTransportParams \"type\" -}}\n {{- $params = append $params (printf \"type=%s\" (index $buildTransportParams \"type\")) -}}\n {{- end -}}\n {{- if hasKey $buildTransportParams \"host\" -}}\n {{- $params = append $params (printf \"host=%s\" (index $buildTransportParams \"host\")) -}}\n {{- end -}}\n {{- if hasKey $buildTransportParams \"path\" -}}\n {{- $params = append $params (printf \"path=%s\" (index $buildTransportParams \"path\")) -}}\n {{- end -}}\n {{- if hasKey $buildTransportParams \"serviceName\" -}}\n {{- $params = append $params (printf \"serviceName=%s\" (index $buildTransportParams \"serviceName\")) -}}\n {{- end -}}\n {{- if hasKey $buildTransportParams \"mode\" -}}\n {{- $params = append $params (printf \"mode=%s\" (index $buildTransportParams \"mode\")) -}}\n {{- end -}}\n {{- if hasKey $buildTransportParams \"extra\" -}}\n {{- $params = append $params (printf \"extra=%s\" (index $buildTransportParams \"extra\")) -}}\n {{- end -}}\n {{- /* 5. Common 通用参数 */ -}}\n {{- $params = append $params $common }}\nvless://{{ $password }}@{{ $server }}:{{ $proxy.Port }}?{{ join \"&\" $params }}#{{ $proxy.Name }}\n {{- else if eq $proxy.Type \"trojan\" }}\n {{- $params := list -}}\n {{- range $key, $val := $buildTransportParams -}}\n {{- $params = append $params (printf \"%s=%s\" $key $val) -}}\n {{- end -}}\n {{- range $key, $val := $buildSecurityParams -}}\n {{- $params = append $params (printf \"%s=%s\" $key $val) -}}\n {{- end -}}\n {{- $params = append $params $common }}\ntrojan://{{ $password }}@{{ $server }}:{{ $proxy.Port }}?{{ join \"&\" $params }}#{{ $proxy.Name }}\n {{- else if or (eq $proxy.Type \"hysteria2\") (eq $proxy.Type \"hysteria\") }}\n {{- $params := list -}}\n {{- if ne (default \"\" $proxy.SNI) \"\" -}}\n {{- $params = append $params (printf \"sni=%s\" $proxy.SNI) -}}\n {{- end -}}\n {{- if $proxy.AllowInsecure -}}\n {{- $params = append $params \"insecure=1\" -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.ObfsPassword) \"\" -}}\n {{- $params = append $params (printf \"obfs=salamander&obfs-password=%s\" $proxy.ObfsPassword) -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.HopPorts) \"\" -}}\n {{- $params = append $params (printf \"mport=%s\" $proxy.HopPorts) -}}\n {{- end }}\nhysteria2://{{- if ne $password \"\" -}}{{ $password }}@{{- end -}}{{ $server }}:{{ $proxy.Port }}?{{ join \"&\" (append $params $common) }}#{{ $proxy.Name | urlquery }}\n {{- else if eq $proxy.Type \"tuic\" }}\n {{- $params := list -}}\n {{- if ne (default \"\" $proxy.CongestionController) \"\" -}}\n {{- $params = append $params (printf \"congestion_controller=%s\" $proxy.CongestionController) -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.UDPRelayMode) \"\" -}}\n {{- $params = append $params (printf \"udp_relay_mode=%s\" $proxy.UDPRelayMode) -}}\n {{- end -}}\n {{- if $proxy.ReduceRtt -}}\n {{- $params = append $params \"reduce_rtt=1\" -}}\n {{- end -}}\n {{- if $proxy.DisableSNI -}}\n {{- $params = append $params \"disable_sni=1\" -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.SNI) \"\" -}}\n {{- $params = append $params (printf \"sni=%s\" $proxy.SNI) -}}\n {{- end -}}\n {{- if $proxy.AllowInsecure -}}\n {{- $params = append $params \"allow_insecure=1\" -}}\n {{- end -}}\n {{- $params = append $params $common }}\ntuic://{{ default \"\" $proxy.ServerKey }}:{{ $password }}@{{ $server }}:{{ $proxy.Port }}?{{ join \"&\" $params }}#{{ $proxy.Name }}\n {{- else if eq $proxy.Type \"anytls\" }}\n {{- $params := list -}}\n {{- /* 使用公共传输层配置 */ -}}\n {{- range $key, $val := $buildTransportParams -}}\n {{- $params = append $params (printf \"%s=%s\" $key $val) -}}\n {{- end -}}\n {{- /* 使用公共安全层配置 */ -}}\n {{- range $key, $val := $buildSecurityParams -}}\n {{- $params = append $params (printf \"%s=%s\" $key $val) -}}\n {{- end -}}\n {{- $params = append $params $common }}\nanytls://{{ $password }}@{{ $server }}:{{ $proxy.Port }}?{{ join \"&\" $params }}#{{ $proxy.Name }}\n {{- else if or (eq $proxy.Type \"http\") (eq $proxy.Type \"https\") }}\n {{- $user := default $password $proxy.Username }}\nhttp{{- if eq $proxy.Type \"https\" -}}s{{- end -}}://{{- if or (ne (default \"\" $user) \"\") (ne (default \"\" $password) \"\") -}}{{ $user }}:{{ $password }}@{{- end -}}{{ $server }}:{{ $proxy.Port }}#{{ $proxy.Name }}\n {{- else if or (eq $proxy.Type \"socks\") (eq $proxy.Type \"socks5\") (eq $proxy.Type \"socks5-tls\") }}\n {{- $user := default $password $proxy.Username }}\nsocks5://{{- if or (ne (default \"\" $user) \"\") (ne (default \"\" $password) \"\") -}}{{ $user }}:{{ $password }}@{{- end -}}{{ $server }}:{{ $proxy.Port }}{{- if eq $proxy.Type \"socks5-tls\" }}?tls=1{{- end }}#{{ $proxy.Name }}\n {{- end }}\n{{- end }}\n', 'base64', '{}', '2025-08-12 23:03:50.004', '2025-08-15 22:01:39.221');
INSERT INTO `subscribe_application` (`id`, `name`, `icon`, `description`, `scheme`, `user_agent`, `is_default`, `subscribe_template`, `output_format`, `download_link`, `created_at`, `updated_at`) VALUES (3, 'Clash', '', '', 'clash://install-config?url=${url}&name=${name}', 'Clash', 0, '{{- $GiB := 1073741824.0 -}}\n{{- $used := printf \"%.2f\" (divf (add (.UserInfo.Download | default 0 | float64) (.UserInfo.Upload | default 0 | float64)) $GiB) -}}\n{{- $traffic := (.UserInfo.Traffic | default 0 | float64) -}}\n{{- $total := printf \"%.2f\" (divf $traffic $GiB) -}}\n\n{{- $ExpiredAt := \"\" -}}\n{{- $expStr := printf \"%v\" .UserInfo.ExpiredAt -}}\n{{- if regexMatch `^[0-9]+$` $expStr -}}\n {{- $ts := $expStr | float64 -}}\n {{- $sec := ternary (divf $ts 1000.0) $ts (ge (len $expStr) 13) -}}\n {{- $ExpiredAt = (date \"2006-01-02 15:04:05\" (unixEpoch ($sec | int64))) -}}\n{{- else -}}\n {{- $ExpiredAt = $expStr -}}\n{{- end -}}\n\n{{- $sortFields := list \"Sort\" \"Port\" \"Name\" -}}\n{{- $sortConfig := dict \"Sort\" \"asc\" \"Port\" \"asc\" \"Name\" \"asc\" -}}\n{{- $byKey := dict -}}\n{{- range $p := .Proxies -}}\n {{- $keyParts := list -}}\n {{- range $field := $sortFields -}}\n {{- $order := index $sortConfig $field -}}\n {{- $val := default \"\" (printf \"%v\" (index $p $field)) -}}\n {{- if or (eq $field \"Sort\") (eq $field \"Port\") -}}\n {{- $val = printf \"%08d\" (int (default 0 (index $p $field))) -}}\n {{- end -}}\n {{- if eq $order \"desc\" -}}\n {{- $val = printf \"~%s\" $val -}}\n {{- end -}}\n {{- $keyParts = append $keyParts $val -}}\n {{- end -}}\n {{- $_ := set $byKey (join \"|\" $keyParts) $p -}}\n{{- end -}}\n{{- $sorted := list -}}\n{{- range $k := sortAlpha (keys $byKey) -}}\n {{- $sorted = append $sorted (index $byKey $k) -}}\n{{- end -}}\n\n{{- $supportSet := dict \"shadowsocks\" true \"vmess\" true \"vless\" true \"trojan\" true \"hysteria2\" true \"hysteria\" true \"tuic\" true \"anytls\" true -}}\n{{- $supportedProxies := list -}}\n{{- range $proxy := $sorted -}}\n {{- if hasKey $supportSet $proxy.Type -}}\n {{- $supportedProxies = append $supportedProxies $proxy -}}\n {{- end -}}\n{{- end -}}\n\n{{- $proxyNames := \"\" -}}\n{{- range $proxy := $supportedProxies -}}\n {{- if eq $proxyNames \"\" -}}\n {{- $proxyNames = printf \"%q\" $proxy.Name -}}\n {{- else -}}\n {{- $proxyNames = printf \"%s, %q\" $proxyNames $proxy.Name -}}\n {{- end -}}\n{{- end -}}\n\n# {{ .SiteName }}-{{ .SubscribeName }}\n# Traffic: {{ $used }} GiB/{{ $total }} GiB | Expires: {{ $ExpiredAt }}\n# Generated at: {{ now | date \"2006-01-02 15:04:05\" }}\n\nmode: rule\nipv6: true\nallow-lan: true\nbind-address: ''*''\nmixed-port: 10808\nlog-level: info\nunified-delay: true\ntcp-concurrent: true\nexternal-controller: ''0.0.0.0:9090''\nglobal-client-fingerprint: chrome\ntun:\n enable: true\n stack: system\n auto-route: true\ndns:\n enable: true\n cache-algorithm: arc\n listen: ''0.0.0.0:1053''\n ipv6: true\n use-hosts: true\n use-system-hosts: true\n respect-rules: false\n enhanced-mode: fake-ip\n fake-ip-range: 198.18.0.1/16\n fake-ip-filter:\n - ''*.lan''\n - ''localhost''\n - ''lens.l.google.com''\n - ''*.srv.nintendo.net''\n - ''*.stun.playstation.net''\n - ''xbox.*.*.microsoft.com''\n - ''*.xboxlive.com''\n - ''*.msftncsi.com''\n - ''*.msftconnecttest.com''\n - ''time.*.com''\n default-nameserver:\n - 223.5.5.5\n - 119.29.29.29\n nameserver:\n - https://cloudflare-dns.com/dns-query\n - https://dns.google/dns-query\n fallback:\n - tls://1.1.1.1\n - tls://8.8.8.8\n proxy-server-nameserver:\n - https://dns.alidns.com/dns-query\n - https://doh.pub/dns-query\n direct-nameserver:\n - system\n - https://dns.alidns.com/dns-query\n - https://doh.pub/dns-query\n direct-nameserver-follow-policy: false\n fallback-filter:\n geoip: true\n geoip-code: CN\n geosite:\n - gfw\n - youtube\n domain:\n - ''+.google.com''\n - ''+.facebook.com''\n - ''+.twitter.com''\n - ''+.telegram.org''\n\nproxies:\n{{- range $proxy := $supportedProxies }}\n {{- $server := $proxy.Server -}}\n {{- if and (contains $server \":\") (not (hasPrefix \"[\" $server)) -}}\n {{- $server = printf \"[%s]\" $server -}}\n {{- end -}}\n\n {{- $password := $.UserInfo.Password -}}\n {{- if and (eq $proxy.Type \"shadowsocks\") (ne (default \"\" $proxy.ServerKey) \"\") -}}\n {{- $method := $proxy.Method -}}\n {{- if or (hasPrefix \"2022-blake3-\" $method) (eq $method \"2022-blake3-aes-128-gcm\") (eq $method \"2022-blake3-aes-256-gcm\") -}}\n {{- $userKeyLen := ternary 16 32 (hasSuffix \"128-gcm\" $method) -}}\n {{- $pwdStr := printf \"%s\" $password -}}\n {{- $userKey := ternary $pwdStr (trunc $userKeyLen $pwdStr) (le (len $pwdStr) $userKeyLen) -}}\n {{- $serverB64 := b64enc $proxy.ServerKey -}}\n {{- $userB64 := b64enc $userKey -}}\n {{- $password = printf \"%s:%s\" $serverB64 $userB64 -}}\n {{- end -}}\n {{- end -}}\n\n {{- $SkipVerify := $proxy.AllowInsecure -}}\n\n{{- if eq $proxy.Type \"shadowsocks\" }}\n- name: {{ $proxy.Name | quote }}\n type: ss\n server: {{ $server }}\n port: {{ $proxy.Port }}\n cipher: {{ default \"aes-128-gcm\" $proxy.Method }}\n password: {{ $password }}\n udp: true\n tfo: true\n {{- if ne (default \"\" $proxy.Obfs) \"\" }}\n plugin: obfs\n plugin-opts:\n mode: {{ $proxy.Obfs }}\n host: {{ default \"\" $proxy.ObfsHost }}\n {{- end }}\n{{- else if eq $proxy.Type \"vmess\" }}\n- name: {{ $proxy.Name | quote }}\n type: vmess\n server: {{ $server }}\n port: {{ $proxy.Port }}\n uuid: {{ $password }}\n alterId: 0\n cipher: auto\n udp: true\n tfo: true\n {{- if or (eq $proxy.Transport \"websocket\") (eq $proxy.Transport \"ws\") }}\n network: ws\n ws-opts:\n path: {{ default \"/\" $proxy.Path }}\n {{- if ne (default \"\" $proxy.Host) \"\" }}\n headers:\n Host: {{ $proxy.Host }}\n {{- end }}\n {{- else if eq $proxy.Transport \"http\" }}\n network: http\n http-opts:\n method: GET\n path: [{{ default \"/\" $proxy.Path | quote }}]\n {{- if ne (default \"\" $proxy.Host) \"\" }}\n headers:\n Host: [{{ $proxy.Host | quote }}]\n {{- end }}\n {{- else if eq $proxy.Transport \"grpc\" }}\n network: grpc\n grpc-opts:\n grpc-service-name: {{ default \"grpc\" $proxy.ServiceName }}\n {{- end }}\n {{- if or (eq $proxy.Security \"tls\") (eq $proxy.Security \"reality\") }}\n tls: true\n {{- end }}\n {{- if ne (default \"\" $proxy.SNI) \"\" }}\n servername: {{ $proxy.SNI }}\n {{- end }}\n {{- if $SkipVerify }}\n skip-cert-verify: true\n {{- end }}\n {{- if ne (default \"\" $proxy.Fingerprint) \"\" }}\n client-fingerprint: {{ $proxy.Fingerprint }}\n {{- end }}\n {{- if $proxy.EchEnable }}\n ech-opts:\n enable: true\n {{- if ne (default \"\" $proxy.EchServerName) \"\" }}\n query-server-name: {{ $proxy.EchServerName }}\n {{- end }}\n {{- end }}\n{{- else if eq $proxy.Type \"vless\" }}\n {{- $encryptionStr := \"\" -}}\n {{- $encryption := default \"none\" $proxy.Encryption -}}\n {{- if eq $encryption \"none\" -}}\n {{- $encryptionStr = \"none\" -}}\n {{- else -}}\n {{- $encParts := list -}}\n {{- $encParts = append $encParts $encryption -}}\n {{- if ne (default \"\" $proxy.Encryption_Mode) \"\" -}}\n {{- $encParts = append $encParts $proxy.Encryption_Mode -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.EncryptionRtt) \"\" -}}\n {{- $encParts = append $encParts $proxy.EncryptionRtt -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.EncryptionClientPadding) \"\" -}}\n {{- $encParts = append $encParts $proxy.EncryptionClientPadding -}}\n {{- end -}}\n {{- if ne (default \"\" $proxy.EncryptionPassword) \"\" -}}\n {{- $encParts = append $encParts $proxy.EncryptionPassword -}}\n {{- end -}}\n {{- $encryptionStr = join \".\" $encParts -}}\n {{- end }}\n- name: {{ $proxy.Name | quote }}\n type: vless\n server: {{ $server }}\n port: {{ $proxy.Port }}\n uuid: {{ $password }}\n udp: true\n tfo: true\n encryption: {{ $encryptionStr }}\n {{- if ne (default \"\" $proxy.Flow) \"\" }}\n flow: {{ $proxy.Flow }}\n {{- end }}\n {{- if or (eq $proxy.Transport \"ws\") (eq $proxy.Transport \"websocket\") }}\n network: ws\n ws-opts:\n path: {{ default \"/\" $proxy.Path }}\n {{- if ne (default \"\" $proxy.Host) \"\" }}\n headers:\n Host: {{ $proxy.Host }}\n {{- end }}\n {{- else if eq $proxy.Transport \"http\" }}\n network: http\n http-opts:\n method: GET\n path: [{{ default \"/\" $proxy.Path | quote }}]\n {{- if ne (default \"\" $proxy.Host) \"\" }}\n headers:\n Host: [{{ $proxy.Host | quote }}]\n {{- end }}\n {{- else if eq $proxy.Transport \"httpupgrade\" }}\n network: httpupgrade\n httpupgrade-opts:\n path: {{ default \"/\" $proxy.Path }}\n {{- if ne (default \"\" $proxy.Host) \"\" }}\n headers:\n Host: {{ $proxy.Host }}\n {{- end }}\n {{- else if eq $proxy.Transport \"xhttp\" }}\n network: xhttp\n xhttp-opts:\n path: {{ default \"/\" $proxy.Path }}\n {{- if ne (default \"\" $proxy.Host) \"\" }}\n host: {{ $proxy.Host }}\n {{- end }}\n {{- if ne (default \"\" $proxy.XhttpMode) \"\" }}\n mode: {{ $proxy.XhttpMode }}\n {{- end }}\n {{- else if eq $proxy.Transport \"grpc\" }}\n network: grpc\n grpc-opts:\n grpc-service-name: {{ default \"grpc\" $proxy.ServiceName }}\n {{- end }}\n {{- if or (eq $proxy.Security \"tls\") (eq $proxy.Security \"reality\") }}\n tls: true\n {{- end }}\n {{- if ne (default \"\" $proxy.SNI) \"\" }}\n servername: {{ $proxy.SNI }}\n {{- end }}\n {{- if $proxy.AllowInsecure }}\n skip-cert-verify: true\n {{- end }}\n {{- if ne (default \"\" $proxy.Fingerprint) \"\" }}\n client-fingerprint: {{ $proxy.Fingerprint }}\n {{- end }}\n {{- if and (eq $proxy.Security \"reality\") (ne (default \"\" $proxy.RealityPublicKey) \"\") }}\n reality-opts:\n public-key: {{ $proxy.RealityPublicKey }}\n {{- if ne (default \"\" $proxy.RealityShortId) \"\" }}\n short-id: {{ $proxy.RealityShortId }}\n {{- end }}\n {{- end }}\n {{- if $proxy.EchEnable }}\n ech-opts:\n enable: true\n {{- if ne (default \"\" $proxy.EchServerName) \"\" }}\n query-server-name: {{ $proxy.EchServerName }}\n {{- end }}\n {{- end }}\n{{- else if eq $proxy.Type \"trojan\" }}\n- name: {{ $proxy.Name | quote }}\n type: trojan\n server: {{ $server }}\n port: {{ $proxy.Port }}\n password: {{ $password }}\n udp: true\n tfo: true\n {{- if or (eq $proxy.Security \"tls\") (eq $proxy.Security \"reality\") }}\n tls: true\n {{- end }}\n {{- if ne (default \"\" $proxy.SNI) \"\" }}\n sni: {{ $proxy.SNI }}\n {{- end }}\n {{- if $SkipVerify }}\n skip-cert-verify: true\n {{- end }}\n {{- if ne (default \"\" $proxy.Fingerprint) \"\" }}\n client-fingerprint: {{ $proxy.Fingerprint }}\n {{- end }}\n {{- if and (eq $proxy.Security \"reality\") (ne (default \"\" $proxy.RealityPublicKey) \"\") }}\n reality-opts:\n public-key: {{ $proxy.RealityPublicKey }}\n {{- if ne (default \"\" $proxy.RealityShortId) \"\" }}\n short-id: {{ $proxy.RealityShortId }}\n {{- end }}\n {{- end }}\n {{- if or (eq $proxy.Transport \"ws\") (eq $proxy.Transport \"websocket\") }}\n network: ws\n ws-opts:\n path: {{ default \"/\" $proxy.Path }}\n {{- if ne (default \"\" $proxy.Host) \"\" }}\n headers:\n Host: {{ $proxy.Host }}\n {{- end }}\n {{- else if eq $proxy.Transport \"http\" }}\n network: http\n http-opts:\n method: GET\n path: [{{ default \"/\" $proxy.Path | quote }}]\n {{- if ne (default \"\" $proxy.Host) \"\" }}\n headers:\n Host: [{{ $proxy.Host | quote }}]\n {{- end }}\n {{- else if eq $proxy.Transport \"grpc\" }}\n network: grpc\n grpc-opts:\n grpc-service-name: {{ default \"grpc\" $proxy.ServiceName }}\n {{- end }}\n {{- if $proxy.EchEnable }}\n ech-opts:\n enable: true\n {{- if ne (default \"\" $proxy.EchServerName) \"\" }}\n query-server-name: {{ $proxy.EchServerName }}\n {{- end }}\n {{- end }}\n{{- else if or (eq $proxy.Type \"hysteria2\") (eq $proxy.Type \"hysteria\") }}\n- name: {{ $proxy.Name | quote }}\n type: hysteria2\n server: {{ $server }}\n port: {{ $proxy.Port }}\n password: {{ $password }}\n udp: true\n tfo: true\n {{- if ne (default \"\" $proxy.SNI) \"\" }}\n sni: {{ $proxy.SNI }}\n {{- end }}\n {{- if $proxy.AllowInsecure }}\n skip-cert-verify: true\n {{- end }}\n {{- if ne (default \"\" $proxy.ObfsPassword) \"\" }}\n obfs: salamander\n obfs-password: {{ $proxy.ObfsPassword }}\n {{- end }}\n {{- if ne (default \"\" $proxy.HopPorts) \"\" }}\n ports: {{ $proxy.HopPorts }}\n {{- end }}\n {{- if ne (default 0 $proxy.HopInterval) 0 }}\n hop-interval: {{ $proxy.HopInterval }}\n {{- end }}\n {{- if ne (default \"\" (printf \"%v\" $proxy.UpMbps)) \"\" }}\n up: \"{{ $proxy.UpMbps }} Mbps\"\n {{- end }}\n {{- if ne (default \"\" (printf \"%v\" $proxy.DownMbps)) \"\" }}\n down: \"{{ $proxy.DownMbps }} Mbps\"\n {{- end }}\n {{- if $proxy.EchEnable }}\n ech-opts:\n enable: true\n {{- if ne (default \"\" $proxy.EchServerName) \"\" }}\n query-server-name: {{ $proxy.EchServerName }}\n {{- end }}\n {{- end }}\n{{- else if eq $proxy.Type \"tuic\" }}\n- name: {{ $proxy.Name | quote }}\n type: tuic\n server: {{ $server }}\n port: {{ $proxy.Port }}\n uuid: {{ default \"\" $proxy.ServerKey }}\n password: {{ $password }}\n udp: true\n tfo: true\n {{- if ne (default \"\" $proxy.SNI) \"\" }}\n sni: {{ $proxy.SNI }}\n {{- end }}\n {{- if $proxy.AllowInsecure }}\n skip-cert-verify: true\n {{- end }}\n {{- if $proxy.DisableSNI }}\n disable-sni: true\n {{- end }}\n {{- if $proxy.ReduceRtt }}\n reduce-rtt: true\n {{- end }}\n {{- if ne (default \"\" $proxy.UDPRelayMode) \"\" }}\n udp-relay-mode: {{ $proxy.UDPRelayMode }}\n {{- end }}\n {{- if ne (default \"\" $proxy.CongestionController) \"\" }}\n congestion-controller: {{ $proxy.CongestionController }}\n {{- end }}\n {{- if $proxy.EchEnable }}\n ech-opts:\n enable: true\n {{- if ne (default \"\" $proxy.EchServerName) \"\" }}\n query-server-name: {{ $proxy.EchServerName }}\n {{- end }}\n {{- end }}\n{{- else if eq $proxy.Type \"wireguard\" }}\n- name: {{ $proxy.Name | quote }}\n type: wireguard\n server: {{ $server }}\n port: {{ $proxy.Port }}\n private-key: {{ default \"\" $proxy.ServerKey }}\n public-key: {{ default \"\" $proxy.RealityPublicKey }}\n udp: true\n tfo: true\n {{- if ne (default \"\" $proxy.Path) \"\" }}\n preshared-key: {{ $proxy.Path }}\n {{- end }}\n {{- if ne (default \"\" $proxy.RealityServerAddr) \"\" }}\n ip: {{ $proxy.RealityServerAddr }}\n {{- end }}\n {{- if ne (default 0 $proxy.RealityServerPort) 0 }}\n ipv6: {{ $proxy.RealityServerPort }}\n {{- end }}\n{{- else if eq $proxy.Type \"anytls\" }}\n- name: {{ $proxy.Name | quote }}\n type: anytls\n server: {{ $server }}\n port: {{ $proxy.Port }}\n password: {{ $password }}\n udp: true\n tfo: true\n {{- if ne (default \"\" $proxy.SNI) \"\" }}\n sni: {{ $proxy.SNI }}\n {{- end }}\n {{- if $proxy.AllowInsecure }}\n skip-cert-verify: true\n {{- end }}\n {{- if ne (default \"\" $proxy.Fingerprint) \"\" }}\n client-fingerprint: {{ $proxy.Fingerprint }}\n {{- end }}\n {{- if $proxy.EchEnable }}\n ech-opts:\n enable: true\n {{- if ne (default \"\" $proxy.EchServerName) \"\" }}\n query-server-name: {{ $proxy.EchServerName }}\n {{- end }}\n {{- end }}\n{{- else }}\n- name: {{ $proxy.Name | quote }}\n type: {{ $proxy.Type }}\n server: {{ $server }}\n port: {{ $proxy.Port }}\n udp: true\n tfo: true\n{{- end }}\n{{- end }}\n\nproxy-groups:\n - { name: 🚀 Proxy, type: select, proxies: [🌏 Auto, 🎯 Direct, {{ $proxyNames }}] }\n - { name: 🍎 Apple, type: select, proxies: [🚀 Proxy, 🎯 Direct, {{ $proxyNames }}] }\n - { name: 🔍 Google, type: select, proxies: [🚀 Proxy, 🎯 Direct, {{ $proxyNames }}] }\n - { name: 🪟 Microsoft, type: select, proxies: [🚀 Proxy, 🎯 Direct, {{ $proxyNames }}] }\n - { name: 📺 GlobalMedia, type: select, proxies: [🚀 Proxy, 🎯 Direct, {{ $proxyNames }}] }\n - { name: 📟 Telegram, type: select, proxies: [🚀 Proxy, 🎯 Direct, {{ $proxyNames }}] }\n - { name: 🤖 AI, type: select, proxies: [🚀 Proxy, 🎯 Direct, {{ $proxyNames }}] }\n - { name: 🪙 Crypto, type: select, proxies: [🚀 Proxy, 🎯 Direct, {{ $proxyNames }}] }\n - { name: 🎮 Game, type: select, proxies: [🚀 Proxy, 🎯 Direct, {{ $proxyNames }}] }\n - { name: 🇨🇳 China, type: select, proxies: [🎯 Direct, 🚀 Proxy, {{ $proxyNames }}] }\n - { name: 🎯 Direct, type: select, proxies: [DIRECT], hidden: true }\n - { name: 🐠 Final, type: select, proxies: [🚀 Proxy, 🎯 Direct, {{ $proxyNames }}] }\n - { name: 🌏 Auto, type: url-test, proxies: [{{ $proxyNames }}] }\n\nrules:\n - RULE-SET, Apple, 🍎 Apple\n - RULE-SET, Google, 🔍 Google\n - RULE-SET, Microsoft, 🪟 Microsoft\n - RULE-SET, Github, 🪟 Microsoft\n - RULE-SET, HBO, 📺 GlobalMedia\n - RULE-SET, Disney, 📺 GlobalMedia\n - RULE-SET, TikTok, 📺 GlobalMedia\n - RULE-SET, Netflix, 📺 GlobalMedia\n - RULE-SET, GlobalMedia, 📺 GlobalMedia\n - RULE-SET, Telegram, 📟 Telegram\n - RULE-SET, OpenAI, 🤖 AI\n - RULE-SET, Gemini, 🤖 AI\n - RULE-SET, Copilot, 🤖 AI\n - RULE-SET, Claude, 🤖 AI\n - RULE-SET, Crypto, 🪙 Crypto\n - RULE-SET, Cryptocurrency, 🪙 Crypto\n - RULE-SET, Game, 🎮 Game\n - RULE-SET, Global, 🚀 Proxy\n - RULE-SET, ChinaMax, 🇨🇳 China\n - RULE-SET, Lan, 🎯 Direct\n - GEOIP, CN, 🇨🇳 China\n - MATCH, 🐠 Final\n\nrule-providers:\n Apple:\n type: http\n behavior: classical\n format: yaml\n url: https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Clash/Apple/Apple_Classical_No_Resolve.yaml\n interval: 86400\n Google:\n type: http\n behavior: classical\n format: yaml\n url: https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Clash/Google/Google_No_Resolve.yaml\n interval: 86400\n Microsoft:\n type: http\n behavior: classical\n format: yaml\n url: https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Clash/Microsoft/Microsoft.yaml\n interval: 86400\n Github:\n type: http\n behavior: classical\n format: yaml\n url: https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Clash/GitHub/GitHub.yaml\n interval: 86400\n HBO:\n type: http\n behavior: classical\n format: yaml\n url: https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Clash/HBO/HBO.yaml\n interval: 86400\n Disney:\n type: http\n behavior: classical\n format: yaml\n url: https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Clash/Disney/Disney.yaml\n interval: 86400\n TikTok:\n type: http\n behavior: classical\n format: yaml\n url: https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Clash/TikTok/TikTok.yaml\n interval: 86400\n Netflix:\n type: http\n behavior: classical\n format: yaml\n url: https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Clash/Netflix/Netflix.yaml\n interval: 86400\n GlobalMedia:\n type: http\n behavior: classical\n format: yaml\n url: https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Clash/GlobalMedia/GlobalMedia_Classical_No_Resolve.yaml\n interval: 86400\n Telegram:\n type: http\n behavior: classical\n format: yaml\n url: https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Clash/Telegram/Telegram_No_Resolve.yaml\n interval: 86400\n OpenAI:\n type: http\n behavior: classical\n format: yaml\n url: https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Clash/OpenAI/OpenAI.yaml\n interval: 86400\n Gemini:\n type: http\n behavior: classical\n format: yaml\n url: https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Clash/Gemini/Gemini.yaml\n interval: 86400\n Copilot:\n type: http\n behavior: classical\n format: yaml\n url: https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Clash/Copilot/Copilot.yaml\n interval: 86400\n Claude:\n type: http\n behavior: classical\n format: yaml\n url: https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Clash/Claude/Claude.yaml\n interval: 86400\n Crypto:\n type: http\n behavior: classical\n format: yaml\n url: https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Clash/Crypto/Crypto.yaml\n interval: 86400\n Cryptocurrency:\n type: http\n behavior: classical\n format: yaml\n url: https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Clash/Cryptocurrency/Cryptocurrency.yaml\n interval: 86400\n Game:\n type: http\n behavior: classical\n format: yaml\n url: https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Clash/Game/Game.yaml\n interval: 86400\n Global:\n type: http\n behavior: classical\n format: yaml\n url: https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Clash/Global/Global_Classical_No_Resolve.yaml\n interval: 86400\n ChinaMax:\n type: http\n behavior: classical\n format: yaml\n url: https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Clash/ChinaMax/ChinaMax_Classical_No_Resolve.yaml\n interval: 86400\n Lan:\n type: http\n behavior: classical\n format: yaml\n url: https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Clash/Lan/Lan.yaml\n interval: 86400\n\nurl-rewrite:\n - ^https?:\\/\\/(www.)?g\\.cn https://www.google.com 302\n - ^https?:\\/\\/(www.)?google\\.cn https://www.google.com 302\n', 'yaml', '{}', '2025-08-12 23:10:00.487', '2025-08-15 22:01:27.031');
INSERT INTO `subscribe_application` (`id`, `name`, `icon`, `description`, `scheme`, `user_agent`, `is_default`, `subscribe_template`, `output_format`, `download_link`, `created_at`, `updated_at`) VALUES (4, 'SingBox', '', '', 'sing-box://import-remote-profile?url=${encodeURIComponent(url)}#${name}', 'sing-box', 0, '{{- $GiB := 1073741824.0 -}}\n{{- $used := printf \"%.2f\" (divf (add (.UserInfo.Download | default 0 | float64) (.UserInfo.Upload | default 0 | float64)) $GiB) -}}\n{{- $traffic := (.UserInfo.Traffic | default 0 | float64) -}}\n{{- $total := printf \"%.2f\" (divf $traffic $GiB) -}}\n\n{{- $ExpiredAt := \"\" -}}\n{{- $expStr := printf \"%v\" .UserInfo.ExpiredAt -}}\n{{- if regexMatch `^[0-9]+$` $expStr -}}\n {{- $ts := $expStr | float64 -}}\n {{- $sec := ternary (divf $ts 1000.0) $ts (ge (len $expStr) 13) -}}\n {{- $ExpiredAt = (date \"2006-01-02 15:04:05\" (unixEpoch ($sec | int64))) -}}\n{{- else -}}\n {{- $ExpiredAt = $expStr -}}\n{{- end -}}\n\n{{- $sortFields := list \"Sort\" \"Port\" \"Name\" -}}\n{{- $sortConfig := dict \"Sort\" \"asc\" \"Port\" \"asc\" \"Name\" \"asc\" -}}\n{{- $byKey := dict -}}\n{{- range $p := .Proxies -}}\n {{- $keyParts := list -}}\n {{- range $field := $sortFields -}}\n {{- $order := index $sortConfig $field -}}\n {{- $val := default \"\" (printf \"%v\" (index $p $field)) -}}\n {{- if or (eq $field \"Sort\") (eq $field \"Port\") -}}\n {{- $val = printf \"%08d\" (int (default 0 (index $p $field))) -}}\n {{- end -}}\n {{- if eq $order \"desc\" -}}\n {{- $val = printf \"~%s\" $val -}}\n {{- end -}}\n {{- $keyParts = append $keyParts $val -}}\n {{- end -}}\n {{- $_ := set $byKey (join \"|\" $keyParts) $p -}}\n{{- end -}}\n{{- $sorted := list -}}\n{{- range $k := sortAlpha (keys $byKey) -}}\n {{- $sorted = append $sorted (index $byKey $k) -}}\n{{- end -}}\n\n{{- $supportedProxies := list -}}\n{{- range $proxy := $sorted -}}\n {{- $isSupported := false -}}\n {{- if or (eq $proxy.Type \"shadowsocks\") (eq $proxy.Type \"vmess\") (eq $proxy.Type \"trojan\") (eq $proxy.Type \"hysteria2\") (eq $proxy.Type \"hy2\") (eq $proxy.Type \"tuic\") (eq $proxy.Type \"anytls\") -}}\n {{- $isSupported = true -}}\n {{- else if eq $proxy.Type \"vless\" -}}\n {{- if or (eq $proxy.Transport \"ws\") (eq $proxy.Transport \"websocket\") (eq $proxy.Transport \"grpc\") (eq $proxy.Transport \"tcp\") (not $proxy.Transport) -}}\n {{- $isSupported = true -}}\n {{- end -}}\n {{- end -}}\n {{- if $isSupported -}}\n {{- $supportedProxies = append $supportedProxies $proxy -}}\n {{- end -}}\n{{- end -}}\n\n{{- define \"AllNodeNames\" -}}\n{{- $sortConfig := dict \"Sort\" \"asc\" -}}\n{{- $byKey := dict -}}\n{{- range $p := .Proxies -}}\n {{- $keyParts := list -}}\n {{- range $field, $order := $sortConfig -}}\n {{- $val := default \"\" (printf \"%v\" (index $p $field)) -}}\n {{- if or (eq $field \"Sort\") (eq $field \"Port\") -}}\n {{- $val = printf \"%08d\" (int (default 0 (index $p $field))) -}}\n {{- end -}}\n {{- if eq $order \"desc\" -}}\n {{- $val = printf \"~%s\" $val -}}\n {{- end -}}\n {{- $keyParts = append $keyParts $val -}}\n {{- end -}}\n {{- $_ := set $byKey (join \"|\" $keyParts) $p -}}\n{{- end -}}\n{{- $sorted := list -}}\n{{- range $k := sortAlpha (keys $byKey) -}}\n {{- $sorted = append $sorted (index $byKey $k) -}}\n{{- end -}}\n{{- $supportedProxies := list -}}\n{{- range $proxy := $sorted -}}\n {{- $isSupported := false -}}\n {{- if or (eq .Type \"shadowsocks\") (eq .Type \"vmess\") (eq .Type \"trojan\") (eq .Type \"hysteria2\") (eq .Type \"hy2\") (eq .Type \"tuic\") (eq .Type \"anytls\") -}}\n {{- $isSupported = true -}}\n {{- else if eq .Type \"vless\" -}}\n {{- if or (eq .Transport \"ws\") (eq .Transport \"websocket\") (eq .Transport \"grpc\") (eq .Transport \"tcp\") (not .Transport) -}}\n {{- $isSupported = true -}}\n {{- end -}}\n {{- end -}}\n {{- if $isSupported -}}\n {{- $supportedProxies = append $supportedProxies . -}}\n {{- end -}}\n{{- end -}}\n{{- $first := true -}}\n{{- range $supportedProxies -}}\n {{- if $first -}}\n \"{{ .Name }}\"\n {{- $first = false -}}\n {{- else -}}\n , \"{{ .Name }}\"\n {{- end -}}\n{{- end -}}\n{{- end -}}\n\n{{- define \"NodeOutbound\" -}}\n{{- $proxy := .proxy -}}\n{{- $server := $proxy.Server -}}\n{{- if and (contains $server \":\") (not (hasPrefix \"[\" $server)) -}}\n {{- $server = printf \"[%s]\" $server -}}\n{{- end -}}\n{{- $port := $proxy.Port -}}\n{{- $name := $proxy.Name -}}\n{{- $pwd := $.UserInfo.Password -}}\n{{- $sni := or $proxy.SNI $server }}\n{{- $svc := $proxy.ServiceName }}\n\n{{- $tlsOpts := \"\" -}}\n{{- if or $sni $proxy.AllowInsecure $proxy.Fingerprint -}}\n {{- $tlsOpts = \"\\\"tls\\\": {\\\"enabled\\\": true\" -}}\n {{- if $sni -}}\n {{- $tlsOpts = printf \"%s, \\\"server_name\\\": \\\"%s\\\"\" $tlsOpts $sni -}}\n {{- end -}}\n {{- if $proxy.AllowInsecure -}}\n {{- $tlsOpts = printf \"%s, \\\"insecure\\\": true\" $tlsOpts -}}\n {{- end -}}\n {{- if $proxy.Fingerprint -}}\n {{- $tlsOpts = printf \"%s, \\\"utls\\\": {\\\"enabled\\\": true, \\\"fingerprint\\\": \\\"%s\\\"}\" $tlsOpts ($proxy.Fingerprint) -}}\n {{- end -}}\n {{- $tlsOpts = printf \"%s}\" $tlsOpts -}}\n{{- end -}}\n\n{{- $transportOpts := \"\" -}}\n{{- if or (eq $proxy.Transport \"ws\") (eq $proxy.Transport \"websocket\") -}}\n {{- $wsPath := default \"/\" $proxy.Path -}}\n {{- $transportOpts = printf \"\\\"transport\\\": {\\\"type\\\": \\\"ws\\\", \\\"path\\\": \\\"%s\\\"\" $wsPath -}}\n {{- if $proxy.Host -}}\n {{- $transportOpts = printf \"%s, \\\"headers\\\": {\\\"Host\\\": \\\"%s\\\"}\" $transportOpts ($proxy.Host) -}}\n {{- end -}}\n {{- $transportOpts = printf \"%s}\" $transportOpts -}}\n{{- else if eq $proxy.Transport \"grpc\" -}}\n {{- $grpcService := default \"grpc\" $svc -}}\n {{- $transportOpts = printf \"\\\"transport\\\": {\\\"type\\\": \\\"grpc\\\", \\\"service_name\\\": \\\"%s\\\"}\" $grpcService -}}\n{{- end -}}\n\n{{- if eq $proxy.Type \"shadowsocks\" -}}\n {{- $method := default \"aes-128-gcm\" $proxy.Method -}}\n {{- $password := $pwd -}}\n {{- if $proxy.ServerKey -}}\n {{- $needBytes := ternary 16 32 (eq $proxy.Method \"2022-blake3-aes-128-gcm\") -}}\n {{- $cutLen := min $needBytes (len $pwd) | int -}}\n {{- $userCut := $pwd | trunc $cutLen -}}\n {{- $serverB64 := b64enc $proxy.ServerKey -}}\n {{- $userB64 := b64enc $userCut -}}\n {{- $password = printf \"%s:%s\" $serverB64 $userB64 -}}\n {{- end -}}\n{ \"type\": \"shadowsocks\", \"tag\": \"{{ $name }}\", \"server\": \"{{ $server }}\", \"server_port\": {{ $port }}, \"method\": \"{{ $method }}\", \"password\": \"{{ $password }}\" }\n\n{{- else if eq $proxy.Type \"trojan\" -}}\n{ \"type\": \"trojan\", \"tag\": \"{{ $name }}\", \"server\": \"{{ $server }}\", \"server_port\": {{ $port }}, \"password\": \"{{ $pwd }}\"{{ if $transportOpts }}, {{ $transportOpts }}{{ end }}, {{ $tlsOpts }} }\n\n{{- else if eq $proxy.Type \"vless\" -}}\n{{- $realityOpts := \"\" -}}\n{{- if $proxy.RealityPublicKey -}}\n {{- $realityOpts = printf \"\\\"reality\\\": { \\\"enabled\\\": true, \\\"public_key\\\": \\\"%s\\\"\" ($proxy.RealityPublicKey) -}}\n {{- if $proxy.RealityShortId -}}\n {{- $realityOpts = printf \"%s, \\\"short_id\\\": \\\"%s\\\"\" $realityOpts ($proxy.RealityShortId) -}}\n {{- end -}}\n {{- if $svc -}}\n {{- $realityOpts = printf \"%s, \\\"server_name\\\": \\\"%s\\\"\" $realityOpts ($svc) -}}\n {{- end -}}\n {{- $realityOpts = printf \"%s }\" $realityOpts -}}\n{{- end -}}\n{{- $flowOpts := \"\" -}}\n{{- if $proxy.Flow -}}\n {{- $flowOpts = printf \", \\\"flow\\\": \\\"%s\\\"\" ($proxy.Flow) -}}\n{{- end -}}\n{ \"type\": \"vless\", \"tag\": \"{{ $name }}\", \"server\": \"{{ $server }}\", \"server_port\": {{ $port }}, \"uuid\": \"{{ $pwd }}\"{{ $flowOpts }}{{ if $transportOpts }}, {{ $transportOpts }}{{ end }}{{ if $realityOpts }}, {{ $realityOpts }}{{ else if $tlsOpts }}, {{ $tlsOpts }}{{ end }} }\n\n{{- else if eq $proxy.Type \"vmess\" -}}\n{{- $vmessTLS := \"\" -}}\n{{- if and $tlsOpts (ne $proxy.Transport \"tcp\") -}}\n {{- $vmessTLS = $tlsOpts -}}\n{{- end -}}\n{ \"type\": \"vmess\", \"tag\": \"{{ $name }}\", \"server\": \"{{ $server }}\", \"server_port\": {{ $port }}, \"uuid\": \"{{ $pwd }}\", \"security\": \"auto\"{{ if $transportOpts }}, {{ $transportOpts }}{{ end }}{{ if $vmessTLS }}, {{ $vmessTLS }}{{ end }} }\n\n{{- else if or (eq $proxy.Type \"hysteria2\") (eq $proxy.Type \"hy2\") -}}\n{{- $obfsOpts := \"\" -}}\n{{- if $proxy.ObfsPassword -}}\n {{- $obfsOpts = printf \"\\\"obfs\\\": { \\\"type\\\": \\\"salamander\\\", \\\"password\\\": \\\"%s\\\" }\" ($proxy.ObfsPassword) -}}\n{{- end -}}\n{{- $hopPortsOpts := \"\" -}}\n{{- if $proxy.HopPorts -}}\n {{- $hopPortsOpts = printf \", \\\"ports\\\": \\\"%s\\\"\" ($proxy.HopPorts) -}}\n{{- end -}}\n{{- $hopIntervalOpts := \"\" -}}\n{{- if $proxy.HopInterval -}}\n {{- $hopIntervalOpts = printf \", \\\"hop_interval\\\": %v\" $proxy.HopInterval -}}\n{{- end -}}\n{ \"type\": \"hysteria2\", \"tag\": \"{{ $name }}\", \"server\": \"{{ $server }}\", \"server_port\": {{ $port }}, \"password\": \"{{ $pwd }}\"{{ if $obfsOpts }}, {{ $obfsOpts }}{{ end }}{{ $hopPortsOpts }}{{ $hopIntervalOpts }}, {{ $tlsOpts }} }\n\n{{- else if eq $proxy.Type \"tuic\" -}}\n{{- $tuicServerKey := $proxy.ServerKey -}}\n{{- $tuicOpts := \"\" -}}\n{{- if $proxy.DisableSNI -}}\n {{- $tuicOpts = printf \"%s, \\\"disable_sni\\\": %v\" $tuicOpts $proxy.DisableSNI -}}\n{{- end -}}\n{{- if $proxy.ReduceRtt -}}\n {{- $tuicOpts = printf \"%s, \\\"reduce_rtt\\\": %v\" $tuicOpts $proxy.ReduceRtt -}}\n{{- end -}}\n{{- if $proxy.UDPRelayMode -}}\n {{- $tuicOpts = printf \"%s, \\\"udp_relay_mode\\\": \\\"%s\\\"\" $tuicOpts ($proxy.UDPRelayMode) -}}\n{{- end -}}\n{{- if $proxy.CongestionController -}}\n {{- $tuicOpts = printf \"%s, \\\"congestion_control\\\": \\\"%s\\\"\" $tuicOpts ($proxy.CongestionController) -}}\n{{- end -}}\n{ \"type\": \"tuic\", \"tag\": \"{{ $name }}\", \"server\": \"{{ $server }}\", \"server_port\": {{ $port }}, \"uuid\": \"{{ $tuicServerKey }}\", \"password\": \"{{ $pwd }}\"{{ $tuicOpts }}, \"alpn\": [\"h3\"], {{ $tlsOpts }} }\n\n{{- else if eq $proxy.Type \"anytls\" -}}\n{{- $anytlsOpts := \"\" -}}\n{{- if $proxy.Method -}}\n {{- $anytlsOpts = printf \"%s, \\\"method\\\": \\\"%s\\\"\" $anytlsOpts ($proxy.Method) -}}\n{{- end -}}\n{{- if $proxy.ObfsPassword -}}\n {{- $anytlsOpts = printf \"%s, \\\"obfs\\\": \\\"%s\\\"\" $anytlsOpts ($proxy.ObfsPassword) -}}\n{{- end -}}\n{{- if $proxy.Path -}}\n {{- $anytlsOpts = printf \"%s, \\\"path\\\": \\\"%s\\\"\" $anytlsOpts ($proxy.Path) -}}\n{{- end -}}\n{{- if $proxy.Host -}}\n {{- $anytlsOpts = printf \"%s, \\\"host\\\": \\\"%s\\\"\" $anytlsOpts ($proxy.Host) -}}\n{{- end -}}\n{ \"type\": \"anytls\", \"tag\": \"{{ $name }}\", \"server\": \"{{ $server }}\", \"server_port\": {{ $port }}, \"password\": \"{{ $pwd }}\"{{ $anytlsOpts }}{{ if $tlsOpts }}, {{ $tlsOpts }}{{ end }} }\n\n{{- else if eq $proxy.Type \"wireguard\" -}}\n{{- $wgPrivateKey := $proxy.ServerKey -}}\n{{- $wgPublicKey := $proxy.RealityPublicKey -}}\n{{- $wgPreSharedOpts := \"\" -}}\n{{- if $proxy.Path -}}\n {{- $wgPreSharedOpts = printf \", \\\"pre_shared_key\\\": \\\"%s\\\"\" ($proxy.Path) -}}\n{{- end -}}\n{{- $wgLocalAddressOpts := \"\" -}}\n{{- if $proxy.RealityServerAddr -}}\n {{- $wgLocalAddressOpts = printf \", \\\"local_address\\\": [\\\"%s\\\"]\" ($proxy.RealityServerAddr) -}}\n{{- end -}}\n{ \"type\": \"wireguard\", \"tag\": \"{{ $name }}\", \"server\": \"{{ $server }}\", \"server_port\": {{ $port }}, \"private_key\": \"{{ $wgPrivateKey }}\", \"peer_public_key\": \"{{ $wgPublicKey }}\"{{ $wgPreSharedOpts }}{{ $wgLocalAddressOpts }} }\n\n{{- else if or (eq $proxy.Type \"http\") (eq $proxy.Type \"https\") -}}\n{{- $httpsTLSOpts := \"\" -}}\n{{- if and (eq $proxy.Type \"https\") $tlsOpts -}}\n {{- $httpsTLSOpts = printf \", %s\" $tlsOpts -}}\n{{- end -}}\n{ \"type\": \"http\", \"tag\": \"{{ $name }}\", \"server\": \"{{ $server }}\", \"server_port\": {{ $port }}, \"username\": \"{{ $pwd }}\", \"password\": \"{{ $pwd }}\"{{ $httpsTLSOpts }} }\n\n{{- else if or (eq $proxy.Type \"socks\") (eq $proxy.Type \"socks5\") -}}\n{ \"type\": \"socks\", \"tag\": \"{{ $name }}\", \"server\": \"{{ $server }}\", \"server_port\": {{ $port }}, \"version\": \"5\", \"username\": \"{{ $pwd }}\", \"password\": \"{{ $pwd }}\" }\n\n{{- else -}}\n{ \"type\": \"direct\", \"tag\": \"{{ $name }}\" }\n{{- end -}}\n{{- end -}}\n\n// 用户信息: 已用流量 {{ $used }}GB / 总流量 {{ $total }}GB, 过期时间: {{ $ExpiredAt }}\n{\n \"log\": {\n \"level\": \"info\",\n \"timestamp\": true\n },\n \"experimental\": {\n \"cache_file\": {\n \"enabled\": true,\n \"store_fakeip\": true,\n \"store_rdrc\": true\n },\n \"clash_api\": {\n \"external_controller\": \"127.0.0.1:9090\",\n \"access_control_allow_origin\": [\n \"http://127.0.0.1\",\n \"https://yacd.metacubex.one\",\n \"https://metacubex.github.io\",\n \"https://metacubexd.pages.dev\",\n \"https://board.zash.run.place\"\n ]\n }\n },\n \"dns\": {\n \"independent_cache\": true,\n \"servers\": [\n {\n \"tag\": \"google\",\n \"type\": \"https\",\n \"server\": \"8.8.8.8\",\n \"detour\": \"节点选择\"\n },\n {\n \"tag\": \"ali\",\n \"type\": \"https\",\n \"server\": \"223.5.5.5\"\n },\n {\n \"tag\": \"fakeip\",\n \"type\": \"fakeip\",\n \"inet4_range\": \"198.18.0.0/15\",\n \"inet6_range\": \"fc00::/18\"\n }\n ],\n \"rules\": [\n {\n \"clash_mode\": \"Direct\",\n \"server\": \"ali\"\n },\n {\n \"clash_mode\": \"Global\",\n \"server\": \"google\"\n },\n {\n \"query_type\": [\n \"A\",\n \"AAAA\"\n ],\n \"server\": \"fakeip\"\n },\n {\n \"rule_set\": \"geosite-cn\",\n \"server\": \"ali\"\n }\n ]\n },\n \"inbounds\": [\n {\n \"type\": \"tun\",\n \"address\": [\n \"172.18.0.1/30\",\n \"fdfe:dcba:9876::1/126\"\n ],\n \"auto_route\": true,\n \"strict_route\": true\n },\n {\n \"type\": \"mixed\",\n \"listen\": \"::\",\n \"listen_port\": 7890\n }\n ],\n \"outbounds\": [\n {\n \"tag\": \"节点选择\",\n \"type\": \"selector\",\n \"outbounds\": [{{ template \"AllNodeNames\" . }}, \"直连\"]\n },\n {\n \"tag\": \"Github\",\n \"type\": \"selector\",\n \"outbounds\": [\n \"节点选择\",\n \"直连\",\n {{ template \"AllNodeNames\" . }}\n ]\n },\n {\n \"tag\": \"Google\",\n \"type\": \"selector\",\n \"outbounds\": [\n \"节点选择\",\n \"直连\",\n {{ template \"AllNodeNames\" . }}\n ]\n },\n {\n \"tag\": \"Microsoft\",\n \"type\": \"selector\",\n \"outbounds\": [\n \"节点选择\",\n \"直连\",\n {{ template \"AllNodeNames\" . }}\n ]\n },\n {\n \"tag\": \"OpenAI\",\n \"type\": \"selector\",\n \"outbounds\": [\n \"节点选择\",\n \"直连\",\n {{ template \"AllNodeNames\" . }}\n ]\n },\n {\n \"tag\": \"Telegram\",\n \"type\": \"selector\",\n \"outbounds\": [\n \"节点选择\",\n \"直连\",\n {{ template \"AllNodeNames\" . }}\n ]\n },\n {\n \"tag\": \"Twitter\",\n \"type\": \"selector\",\n \"outbounds\": [\n \"节点选择\",\n \"直连\",\n {{ template \"AllNodeNames\" . }}\n ]\n },\n {\n \"tag\": \"Youtube\",\n \"type\": \"selector\",\n \"outbounds\": [\n \"节点选择\",\n \"直连\",\n {{ template \"AllNodeNames\" . }}\n ]\n },\n {\n \"tag\": \"国内\",\n \"type\": \"selector\",\n \"outbounds\": [\n \"直连\",\n \"节点选择\",\n {{ template \"AllNodeNames\" . }}\n ]\n },\n {{- range $i, $proxy := $supportedProxies }}\n {{ if $i }},{{ end }}\n {{ template \"NodeOutbound\" (dict \"proxy\" $proxy \"UserInfo\" $.UserInfo) }}\n {{- end }}\n {{- if gt (len $supportedProxies) 0 }},{{ end }}\n {\n \"tag\": \"直连\",\n \"type\": \"direct\"\n }\n ],\n \"route\": {\n \"default_domain_resolver\": {\n \"server\": \"ali\"\n },\n \"auto_detect_interface\": true,\n \"rules\": [\n {\n \"action\": \"sniff\"\n },\n {\n \"protocol\": \"dns\",\n \"action\": \"hijack-dns\"\n },\n {\n \"ip_is_private\": true,\n \"outbound\": \"直连\"\n },\n {\n \"rule_set\": \"anti-ad\",\n \"clash_mode\": \"Rule\",\n \"action\": \"reject\"\n },\n {\n \"clash_mode\": \"Direct\",\n \"outbound\": \"直连\"\n },\n {\n \"clash_mode\": \"Global\",\n \"outbound\": \"节点选择\"\n },\n {\n \"rule_set\": \"geosite-github\",\n \"outbound\": \"Github\"\n },\n {\n \"rule_set\": [\n \"geoip-google\",\n \"geosite-google\"\n ],\n \"outbound\": \"Google\"\n },\n {\n \"rule_set\": \"geosite-microsoft\",\n \"outbound\": \"Microsoft\"\n },\n {\n \"rule_set\": \"geosite-openai\",\n \"outbound\": \"OpenAI\"\n },\n {\n \"rule_set\": [\n \"geoip-telegram\",\n \"geosite-telegram\"\n ],\n \"outbound\": \"Telegram\"\n },\n {\n \"rule_set\": [\n \"geoip-twitter\",\n \"geosite-twitter\"\n ],\n \"outbound\": \"Twitter\"\n },\n {\n \"rule_set\": \"geosite-youtube\",\n \"outbound\": \"Youtube\"\n },\n {\n \"rule_set\": [\n \"geoip-cn\",\n \"geosite-cn\"\n ],\n \"outbound\": \"国内\"\n }\n ],\n \"rule_set\": [\n {\n \"tag\": \"anti-ad\",\n \"type\": \"remote\",\n \"format\": \"binary\",\n \"url\": \"https://anti-ad.net/anti-ad-sing-box.srs\",\n \"download_detour\": \"直连\"\n },\n {\n \"tag\": \"geosite-github\",\n \"type\": \"remote\",\n \"format\": \"binary\",\n \"url\": \"https://cdn.jsdmirror.com/gh/perfect-panel/rules/geo/geosite/github.srs\",\n \"download_detour\": \"直连\"\n },\n {\n \"tag\": \"geoip-google\",\n \"type\": \"remote\",\n \"format\": \"binary\",\n \"url\": \"https://cdn.jsdmirror.com/gh/perfect-panel/rules/geo/geoip/google.srs\",\n \"download_detour\": \"直连\"\n },\n {\n \"tag\": \"geosite-google\",\n \"type\": \"remote\",\n \"format\": \"binary\",\n \"url\": \"https://cdn.jsdmirror.com/gh/perfect-panel/rules/geo/geosite/google.srs\",\n \"download_detour\": \"直连\"\n },\n {\n \"tag\": \"geosite-microsoft\",\n \"type\": \"remote\",\n \"format\": \"binary\",\n \"url\": \"https://cdn.jsdmirror.com/gh/perfect-panel/rules/geo/geosite/microsoft.srs\",\n \"download_detour\": \"直连\"\n },\n {\n \"tag\": \"geosite-openai\",\n \"type\": \"remote\",\n \"format\": \"binary\",\n \"url\": \"https://cdn.jsdmirror.com/gh/perfect-panel/rules/geo/geosite/openai.srs\",\n \"download_detour\": \"直连\"\n },\n {\n \"tag\": \"geoip-telegram\",\n \"type\": \"remote\",\n \"format\": \"binary\",\n \"url\": \"https://cdn.jsdmirror.com/gh/perfect-panel/rules/geo/geoip/telegram.srs\",\n \"download_detour\": \"直连\"\n },\n {\n \"tag\": \"geosite-telegram\",\n \"type\": \"remote\",\n \"format\": \"binary\",\n \"url\": \"https://cdn.jsdmirror.com/gh/perfect-panel/rules/geo/geosite/telegram.srs\",\n \"download_detour\": \"直连\"\n },\n {\n \"tag\": \"geoip-twitter\",\n \"type\": \"remote\",\n \"format\": \"binary\",\n \"url\": \"https://cdn.jsdmirror.com/gh/perfect-panel/rules/geo/geoip/twitter.srs\",\n \"download_detour\": \"直连\"\n },\n {\n \"tag\": \"geosite-twitter\",\n \"type\": \"remote\",\n \"format\": \"binary\",\n \"url\": \"https://cdn.jsdmirror.com/gh/perfect-panel/rules/geo/geosite/twitter.srs\",\n \"download_detour\": \"直连\"\n },\n {\n \"tag\": \"geosite-youtube\",\n \"type\": \"remote\",\n \"format\": \"binary\",\n \"url\": \"https://cdn.jsdmirror.com/gh/perfect-panel/rules/geo/geosite/youtube.srs\",\n \"download_detour\": \"直连\"\n },\n {\n \"tag\": \"geosite-cn\",\n \"type\": \"remote\",\n \"format\": \"binary\",\n \"url\": \"https://cdn.jsdmirror.com/gh/perfect-panel/rules/geo/geosite/cn.srs\",\n \"download_detour\": \"直连\"\n },\n {\n \"tag\": \"geoip-cn\",\n \"type\": \"remote\",\n \"format\": \"binary\",\n \"url\": \"https://cdn.jsdmirror.com/gh/perfect-panel/rules/geo/geoip/cn.srs\",\n \"download_detour\": \"直连\"\n }\n ]\n }\n}', 'json', '{}', '2025-08-12 23:30:10.016', '2025-08-15 22:01:10.801');
INSERT INTO `subscribe_application` (`id`, `name`, `icon`, `description`, `scheme`, `user_agent`, `is_default`, `subscribe_template`, `output_format`, `download_link`, `created_at`, `updated_at`) VALUES (5, 'Surge', '', '', 'surge:///install-config?url=${encodeURIComponent(url)}', 'Surge', 0, '{{- $GiB := 1073741824.0 -}}\n{{- $used := printf \"%.2f\" (divf (add (.UserInfo.Download | default 0 | float64) (.UserInfo.Upload | default 0 | float64)) $GiB) -}}\n{{- $traffic := (.UserInfo.Traffic | default 0 | float64) -}}\n{{- $total := printf \"%.2f\" (divf $traffic $GiB) -}}\n\n{{- $ExpiredAt := \"\" -}}\n{{- $expStr := printf \"%v\" .UserInfo.ExpiredAt -}}\n{{- if regexMatch `^[0-9]+$` $expStr -}}\n {{- $ts := $expStr | float64 -}}\n {{- $sec := ternary (divf $ts 1000.0) $ts (ge (len $expStr) 13) -}}\n {{- $ExpiredAt = (date \"2006-01-02 15:04:05\" (unixEpoch ($sec | int64))) -}}\n{{- else -}}\n {{- $ExpiredAt = $expStr -}}\n{{- end -}}\n\n{{- $sortFields := list \"Sort\" \"Port\" \"Name\" -}}\n{{- $sortConfig := dict \"Sort\" \"asc\" \"Port\" \"asc\" \"Name\" \"asc\" -}}\n{{- $byKey := dict -}}\n{{- range $p := .Proxies -}}\n {{- $keyParts := list -}}\n {{- range $field := $sortFields -}}\n {{- $order := index $sortConfig $field -}}\n {{- $val := default \"\" (printf \"%v\" (index $p $field)) -}}\n {{- if or (eq $field \"Sort\") (eq $field \"Port\") -}}\n {{- $val = printf \"%08d\" (int (default 0 (index $p $field))) -}}\n {{- end -}}\n {{- if eq $order \"desc\" -}}\n {{- $val = printf \"~%s\" $val -}}\n {{- end -}}\n {{- $keyParts = append $keyParts $val -}}\n {{- end -}}\n {{- $_ := set $byKey (join \"|\" $keyParts) $p -}}\n{{- end -}}\n{{- $sorted := list -}}\n{{- range $k := sortAlpha (keys $byKey) -}}\n {{- $sorted = append $sorted (index $byKey $k) -}}\n{{- end -}}\n\n{{- $supportSet := dict \"shadowsocks\" true \"vmess\" true \"vless\" true \"trojan\" true \"hysteria2\" true \"hysteria\" true \"tuic\" true \"wireguard\" true -}}\n{{- $supportedProxies := list -}}\n{{- range $proxy := $sorted -}}\n {{- if hasKey $supportSet $proxy.Type -}}\n {{- $supportedProxies = append $supportedProxies $proxy -}}\n {{- end -}}\n{{- end -}}\n\n{{- $proxyNames := \"\" -}}\n{{- range $proxy := $supportedProxies -}}\n {{- if eq $proxyNames \"\" -}}\n {{- $proxyNames = $proxy.Name -}}\n {{- else -}}\n {{- $proxyNames = printf \"%s, %s\" $proxyNames $proxy.Name -}}\n {{- end -}}\n{{- end -}}\n\n# {{ .SiteName }}-{{ .SubscribeName }}\n# Traffic: {{ $used }} GiB/{{ $total }} GiB | Expires: {{ $ExpiredAt }}\n# Generated at: {{ now | date \"2006-01-02 15:04:05\" }}\n\n#!MANAGED-CONFIG {{ .UserInfo.SubscribeURL }} interval=86400 strict=true\n\n[General]\n# 日志级别\nloglevel = notify\n\n# 外部控制器访问\nexternal-controller-access = perlnk@0.0.0.0:6170\n\n# 网络设置\nexclude-simple-hostnames = true\nshow-error-page-for-reject = true\nudp-priority = true\nudp-policy-not-supported-behaviour = reject\nipv6 = true\nipv6-vif = auto\n\n# 连接测试\nproxy-test-url = http://www.gstatic.com/generate_204\ninternet-test-url = http://www.gstatic.com/generate_204\ntest-timeout = 5\n\n# DNS 设置\ndns-server = system, 119.29.29.29, 223.5.5.5\nencrypted-dns-server = https://dns.alidns.com/dns-query\nhijack-dns = 8.8.8.8:53, 8.8.4.4:53, 1.1.1.1:53, 1.0.0.1:53\n\n# 跳过代理\nskip-proxy = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, 127.0.0.0/8, localhost, *.local\n\n# 真实 IP\nalways-real-ip = *.lan, lens.l.google.com, *.srv.nintendo.net, *.stun.playstation.net, *.xboxlive.com, xbox.*.*.microsoft.com, *.msftncsi.com, *.msftconnecttest.com\n\n# Surge Mac 参数\nhttp-listen = 0.0.0.0:6088\nsocks5-listen = 0.0.0.0:6089\n\n# Surge iOS 参数(WiFi 共享)\nallow-wifi-access = true\nallow-hotspot-access = true\nwifi-access-http-port = 6088\nwifi-access-socks5-port = 6089\n\n[Panel]\nSubscribeInfo = title={{ .SiteName }} - {{ .SubscribeName }}, content=已用流量: {{ $used }} GiB/{{ $total }} GiB \\n到期时间: {{ $ExpiredAt}}, style=info\n\n[Proxy]\n{{- range $proxy := $supportedProxies }}\n {{- $common := \"udp-relay=true, tfo=true\" -}}\n\n {{- $server := $proxy.Server -}}\n {{- if and (contains $server \":\") (not (hasPrefix \"[\" $server)) -}}\n {{- $server = printf \"[%s]\" $server -}}\n {{- end -}}\n\n {{- $password := $.UserInfo.Password -}}\n {{- if and (eq $proxy.Type \"shadowsocks\") (ne (default \"\" $proxy.ServerKey) \"\") -}}\n {{- $method := $proxy.Method -}}\n {{- if or (hasPrefix \"2022-blake3-\" $method) (eq $method \"2022-blake3-aes-128-gcm\") (eq $method \"2022-blake3-aes-256-gcm\") -}}\n {{- $userKeyLen := ternary 16 32 (hasSuffix \"128-gcm\" $method) -}}\n {{- $pwdStr := printf \"%s\" $password -}}\n {{- $userKey := ternary $pwdStr (trunc $userKeyLen $pwdStr) (le (len $pwdStr) $userKeyLen) -}}\n {{- $serverB64 := b64enc $proxy.ServerKey -}}\n {{- $userB64 := b64enc $userKey -}}\n {{- $password = printf \"%s:%s\" $serverB64 $userB64 -}}\n {{- end -}}\n {{- end -}}\n\n {{- $SkipVerify := $proxy.AllowInsecure -}}\n\n {{- if eq $proxy.Type \"shadowsocks\" }}\n{{ $proxy.Name }} = ss, {{ $server }}, {{ $proxy.Port }}, encrypt-method={{ default \"aes-128-gcm\" $proxy.Method }}, password={{ $password }}{{- if ne (default \"\" $proxy.Obfs) \"\" }}, obfs={{ $proxy.Obfs }}{{- if ne (default \"\" $proxy.ObfsHost) \"\" }}, obfs-host={{ $proxy.ObfsHost }}{{- end }}{{- end }}, {{ $common }}\n {{- else if eq $proxy.Type \"vmess\" }}\n{{ $proxy.Name }} = vmess, {{ $server }}, {{ $proxy.Port }}, username={{ $password }}{{- if or (eq $proxy.Transport \"ws\") (eq $proxy.Transport \"websocket\") }}, ws=true{{- if ne (default \"\" $proxy.Path) \"\" }}, ws-path={{ $proxy.Path }}{{- end }}{{- if ne (default \"\" $proxy.Host) \"\" }}, ws-headers=\"Host:{{ $proxy.Host }}\"{{- end }}{{- else if eq $proxy.Transport \"grpc\" }}, grpc=true{{- if ne (default \"\" $proxy.ServiceName) \"\" }}, grpc-service-name={{ $proxy.ServiceName }}{{- end }}{{- end }}{{- if or (eq $proxy.Security \"tls\") (eq $proxy.Security \"reality\") }}, tls=true{{- end }}{{- if ne (default \"\" $proxy.SNI) \"\" }}, sni={{ $proxy.SNI }}{{- end }}{{- if $proxy.AllowInsecure }}, skip-cert-verify=true{{- end }}{{- if ne (default \"\" $proxy.Fingerprint) \"\" }}, fingerprint={{ $proxy.Fingerprint }}{{- end }}, {{ $common }}\n {{- else if eq $proxy.Type \"vless\" }}\n{{ $proxy.Name }} = vless, {{ $server }}, {{ $proxy.Port }}, username={{ $password }}{{- if or (eq $proxy.Transport \"ws\") (eq $proxy.Transport \"websocket\") }}, ws=true{{- if ne (default \"\" $proxy.Path) \"\" }}, ws-path={{ $proxy.Path }}{{- end }}{{- if ne (default \"\" $proxy.Host) \"\" }}, ws-headers=\"Host:{{ $proxy.Host }}\"{{- end }}{{- else if eq $proxy.Transport \"grpc\" }}, grpc=true{{- if ne (default \"\" $proxy.ServiceName) \"\" }}, grpc-service-name={{ $proxy.ServiceName }}{{- end }}{{- end }}{{- if ne (default \"\" $proxy.SNI) \"\" }}, sni={{ $proxy.SNI }}{{- end }}{{- if $proxy.AllowInsecure }}, skip-cert-verify=true{{- end }}{{- if ne (default \"\" $proxy.Flow) \"none\" }}, flow={{ $proxy.Flow }}{{- end }}, {{ $common }}\n {{- else if eq $proxy.Type \"trojan\" }}\n{{ $proxy.Name }} = trojan, {{ $server }}, {{ $proxy.Port }}, password={{ $password }}{{- if or (eq $proxy.Transport \"ws\") (eq $proxy.Transport \"websocket\") }}, ws=true{{- if ne (default \"\" $proxy.Path) \"\" }}, ws-path={{ $proxy.Path }}{{- end }}{{- if ne (default \"\" $proxy.Host) \"\" }}, ws-headers=\"Host:{{ $proxy.Host }}\"{{- end }}{{- else if eq $proxy.Transport \"grpc\" }}, grpc=true{{- if ne (default \"\" $proxy.ServiceName) \"\" }}, grpc-service-name={{ $proxy.ServiceName }}{{- end }}{{- end }}{{- if ne (default \"\" $proxy.SNI) \"\" }}, sni={{ $proxy.SNI }}{{- end }}{{- if $proxy.AllowInsecure }}, skip-cert-verify=true{{- end }}{{- if ne (default \"\" $proxy.Fingerprint) \"\" }}, fingerprint={{ $proxy.Fingerprint }}{{- end }}, {{ $common }}\n {{- else if or (eq $proxy.Type \"hysteria2\") (eq $proxy.Type \"hysteria\") }}\n{{ $proxy.Name }} = hysteria2, {{ $server }}, {{ $proxy.Port }}, password={{ $password }}{{- if ne (default \"\" $proxy.SNI) \"\" }}, sni={{ $proxy.SNI }}{{- end }}{{- if $proxy.AllowInsecure }}, skip-cert-verify=true{{- end }}{{- if ne (default \"\" $proxy.ObfsPassword) \"\" }}, obfs=salamander, obfs-password={{ $proxy.ObfsPassword }}{{- end }}{{- if ne (default \"\" $proxy.HopPorts) \"\" }}, ports={{ $proxy.HopPorts }}{{- end }}{{- if ne (default 0 $proxy.HopInterval) 0 }}, hop-interval={{ $proxy.HopInterval }}{{- end }}, {{ $common }}\n {{- else if eq $proxy.Type \"tuic\" }}\n{{ $proxy.Name }} = tuic, {{ $server }}, {{ $proxy.Port }}, uuid={{ default \"\" $proxy.ServerKey }}, password={{ $password }}{{- if ne (default \"\" $proxy.SNI) \"\" }}, sni={{ $proxy.SNI }}{{- end }}{{- if $proxy.AllowInsecure }}, skip-cert-verify=true{{- end }}{{- if $proxy.DisableSNI }}, disable-sni=true{{- end }}{{- if $proxy.ReduceRtt }}, reduce-rtt=true{{- end }}{{- if ne (default \"\" $proxy.UDPRelayMode) \"\" }}, udp-relay-mode={{ $proxy.UDPRelayMode }}{{- end }}{{- if ne (default \"\" $proxy.CongestionController) \"\" }}, congestion-controller={{ $proxy.CongestionController }}{{- end }}, {{ $common }}\n {{- else if eq $proxy.Type \"wireguard\" }}\n{{ $proxy.Name }} = wireguard, {{ $server }}, {{ $proxy.Port }}, private-key={{ default \"\" $proxy.ServerKey }}, public-key={{ default \"\" $proxy.RealityPublicKey }}{{- if ne (default \"\" $proxy.Path) \"\" }}, preshared-key={{ $proxy.Path }}{{- end }}{{- if ne (default \"\" $proxy.RealityServerAddr) \"\" }}, ip={{ $proxy.RealityServerAddr }}{{- end }}{{- if ne (default 0 $proxy.RealityServerPort) 0 }}, ipv6={{ $proxy.RealityServerPort }}{{- end }}, {{ $common }}\n {{- else if eq $proxy.Type \"anytls\" }}\n{{ $proxy.Name }} = anytls, {{ $server }}, {{ $proxy.Port }}, password={{ $password }}{{- if ne (default \"\" $proxy.SNI) \"\" }}, sni={{ $proxy.SNI }}{{- end }}{{- if $proxy.AllowInsecure }}, skip-cert-verify=true{{- end }}, {{ $common }}\n {{- else }}\n{{ $proxy.Name }} = {{ $proxy.Type }}, {{ $server }}, {{ $proxy.Port }}, {{ $common }}\n {{- end }}\n{{- end }}\n\n[Proxy Group]\n# 主要策略组\n🚀 Proxy = select, 🌏 Auto, 🎯 Direct, include-other-group=🇺🇳 Nodes\n🍎 Apple = select, 🚀 Proxy, 🎯 Direct, include-other-group=🇺🇳 Nodes\n🔍 Google = select, 🚀 Proxy, 🎯 Direct, include-other-group=🇺🇳 Nodes\n🪟 Microsoft = select, 🚀 Proxy, 🎯 Direct, include-other-group=🇺🇳 Nodes\n📺 GlobalMedia = select, 🚀 Proxy, 🎯 Direct, include-other-group=🇺🇳 Nodes\n🤖 AI = select, 🚀 Proxy, 🎯 Direct, include-other-group=🇺🇳 Nodes\n🪙 Crypto = select, 🚀 Proxy, 🎯 Direct, include-other-group=🇺🇳 Nodes\n🎮 Game = select, 🚀 Proxy, 🎯 Direct, include-other-group=🇺🇳 Nodes\n📟 Telegram = select, 🚀 Proxy, 🎯 Direct, include-other-group=🇺🇳 Nodes\n🇨🇳 China = select, 🎯 Direct, 🚀 Proxy, include-other-group=🇺🇳 Nodes\n🐠 Final = select, 🚀 Proxy, 🎯 Direct, include-other-group=🇺🇳 Nodes\n\n# 智能选择和节点组\n🌏 Auto = smart, include-other-group=🇺🇳 Nodes\n🎯 Direct = select, DIRECT, hidden=1\n🇺🇳 Nodes = select, {{ $proxyNames }}, hidden=1\n\n[Rule]\nRULE-SET, https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Surge/Apple/Apple_All.list, 🍎 Apple\nRULE-SET, https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Surge/Google/Google.list, 🔍 Google\nRULE-SET, https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Surge/GitHub/GitHub.list, 🪟 Microsoft\nRULE-SET, https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Surge/Microsoft/Microsoft.list, 🪟 Microsoft\nRULE-SET, https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Surge/HBO/HBO.list, 📺 GlobalMedia\nRULE-SET, https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Surge/Disney/Disney.list, 📺 GlobalMedia\nRULE-SET, https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Surge/TikTok/TikTok.list, 📺 GlobalMedia\nRULE-SET, https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Surge/Netflix/Netflix.list, 📺 GlobalMedia\nRULE-SET, https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Surge/GlobalMedia/GlobalMedia_All_No_Resolve.list, 📺 GlobalMedia\nRULE-SET, https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Surge/Telegram/Telegram.list, 📟 Telegram\nRULE-SET, https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Surge/OpenAI/OpenAI.list, 🤖 AI\nRULE-SET, https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Surge/Gemini/Gemini.list, 🤖 AI\nRULE-SET, https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Surge/Copilot/Copilot.list, 🤖 AI\nRULE-SET, https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Surge/Claude/Claude.list, 🤖 AI\nRULE-SET, https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Surge/Crypto/Crypto.list, 🪙 Crypto\nRULE-SET, https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Surge/Cryptocurrency/Cryptocurrency.list, 🪙 Crypto\nRULE-SET, https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Surge/Game/Game.list, 🎮 Game\nRULE-SET, https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Surge/Global/Global_All_No_Resolve.list, 🚀 Proxy\nRULE-SET, https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Surge/ChinaMax/ChinaMax_All_No_Resolve.list, 🇨🇳 China\nRULE-SET, https://cdn.jsdmirror.com/gh/perfect-panel/rules/rule/Surge/Lan/Lan.list, 🎯 Direct\n\nGEOIP, CN, 🇨🇳 China\nFINAL, 🐠 Final, dns-failed\n\n[URL Rewrite]\n^https?:\\/\\/(www.)?g\\.cn https://www.google.com 302\n^https?:\\/\\/(www.)?google\\.cn https://www.google.com 302\n', 'conf', '{}', '2025-08-13 00:12:37.809', '2025-08-15 22:00:50.528');
COMMIT;