github.com/v2fly/v2ray-core/v5@v5.16.2-0.20240507031116-8191faa6e095/app/subscription/entries/nonnative/definitions/vmess.jsont (about) 1 {{if assertExists . "root_!kind" | not}} Unknown environment {{end}} 2 {{ $protocol_name := tryGet . "root_!link_protocol" "root_!json_type_!unquoted"}} 3 {{if assertValueIsOneOf $protocol_name "vmess" | not}} This template will only handle vmess link {{end}} 4 5 {{ $server_address := tryGet . "root_!link_host_!base64_!json_add" "root_!json_server"}} 6 {{ $server_uuid := tryGet . "root_!link_host_!base64_!json_id" "root_!json_uuid"}} 7 {{ $server_port := tryGet . "root_!link_host_!base64_!json_port_!unquoted" "root_!link_host_!base64_!json_port" "root_!json_port_!unquoted" "root_!json_port"}} 8 9 {{ $transport_type := tryGet . "root_!link_host_!base64_!json_net_!unquoted" "root_!json_network_!unquoted" "<default>"}} 10 {{ $transport_type = $transport_type | unalias "tcp" ""}} 11 12 {{ $name_annotation := tryGet . "root_!link_host_!base64_!json_ps_!unquoted" "root_!json_name_!unquoted" "<default>"}} 13 14 {{if assertValueIsOneOf $transport_type "tcp" "kcp" "ws" "h2" "quic" "grpc"| not }} 15 unknown transport type {{end}} 16 17 {{$transport_grpc_service_name := ""}} 18 {{ if $transport_type | eq "grpc"}} 19 {{ $transport_grpc_service_name = tryGet . "root_!link_host_!base64_!json_path" "<default>"}} 20 {{end}} 21 22 {{$transport_ws_path := ""}} 23 {{ if $transport_type | eq "ws"}} 24 {{ $transport_ws_path = tryGet . "root_!link_host_!base64_!json_path" "root_!json_ws-opts_!json_path" "<default>"}} 25 {{end}} 26 27 {{ $security_type := tryGet . "root_!link_host_!base64_!json_tls_!unquoted" "root_!json_tls" "<default>"}} 28 {{ $security_type = $security_type | unalias "none" "" "false" "0"}} 29 30 {{if assertValueIsOneOf $security_type "tls" "utls" "none"| not }} 31 unknown security type {{end}} 32 33 {{ $security_tlsmmon_sni := tryGet . "root_!link_host_!base64_!json_sni" "<default>"}} 34 {{ $security_tlsmmon_sni = $security_tlsmmon_sni | unalias $server_address ""}} 35 36 { 37 "protocol": "vmess", 38 "settings":{ 39 "address":{{$server_address}}, 40 "port":{{$server_port}}, 41 "uuid":{{$server_uuid}} 42 }, 43 "streamSettings":{ 44 "transport":{{$transport_type|jsonEncode}}, 45 "security":{{$security_type|jsonEncode}}, 46 "transportSettings":{ 47 {{ if $transport_type | eq "grpc"}} 48 "serviceName":{{$transport_grpc_service_name}} 49 {{end}} 50 {{ if $transport_type | eq "ws"}} 51 "path":{{$transport_ws_path}} 52 {{end}} 53 }, 54 55 "securitySettings":{ 56 {{ if $security_type | eq "tls"}} 57 "serverName":{{$security_tlsmmon_sni}} 58 {{end}} 59 } 60 }, 61 "metadata":{ 62 63 "TagName": {{print $name_annotation "_" $server_address | jsonEncode}} 64 65 } 66 }