github.com/v2fly/v2ray-core/v5@v5.16.2-0.20240507031116-8191faa6e095/app/subscription/entries/nonnative/definitions/shadowsocks2022.jsont (about) 1 {{if assertExists . "root_!kind" | not}} Unknown environment {{end}} 2 {{if assertIsOneOf . "root_!kind" "json" | not}} This template only works for json input. {{end}} 3 4 {{ $methodName := tryGet . "root_!json_method_!unquoted" "root_!json_protocol_!unquoted"}} 5 {{if assertValueIsOneOf $methodName "2022-blake3-aes-128-gcm" "2022-blake3-aes-256-gcm" | not}} 6 This template only works for ss2022. {{end}} 7 8 {{ $server_address := tryGet . "root_!json_server" "root_!json_address" "root_!json_endpoint"}} 9 {{ $server_port := tryGet . "root_!json_port" "root_!json_server_port" "root_!json_endpoint"}} 10 {{if $server_address | splitAndGetAfterNth ":" 0 | len | gt 1}} 11 {{ $server_addressport_unquoted := tryGet . "root_!json_endpoint_!unquoted"}} 12 {{ $server_port = $server_addressport_unquoted | splitAndGetAfterNth ":" -1}} 13 14 {{ $server_portWithSep := printf ":%v" $server_port}} 15 {{ $server_address = $server_addressport_unquoted | stringCutSuffix $server_portWithSep | jsonEncode}} 16 {{end}} 17 18 {{ $name_annotation := tryGet . "root_!json_name_!unquoted" "root_!json_id_!unquoted" "root_!json_tag_!unquoted" "root_!json_remarks_!unquoted" "<default>"}} 19 20 {{ $psk := tryGet . "root_!json_password_!unquoted" "root_!json_psk_!unquoted"}} 21 {{ $ipsk_encoded := "" }} 22 {{if $psk | splitAndGetAfterNth ":" 0 | len | ne 1}} 23 {{ $origpsk := $psk }} 24 {{ $psk = $psk | splitAndGetNth ":" -1 }} 25 {{ $pskWithSep := printf ":%v" $psk}} 26 {{ $ipsk_encoded = $origpsk | stringCutSuffix $pskWithSep | splitAndGetAfterNth ":" 0 | jsonEncode}} 27 {{else}} 28 {{$ipsk_encoded = tryGet . "root_!json_iPSKs" "<default>"}} 29 {{end}} 30 31 32 { 33 "protocol": "shadowsocks2022", 34 "settings": { 35 "address": {{$server_address}}, 36 "port": {{$server_port}}, 37 "method": {{$methodName | jsonEncode}}, 38 "psk": {{$psk | jsonEncode}} 39 {{if $ipsk_encoded|len|ne 0}} 40 , 41 "ipsk": {{$ipsk_encoded}} 42 {{end}} 43 }, 44 45 "metadata":{ 46 47 "TagName": {{print $name_annotation "_" $server_address | jsonEncode}} 48 49 } 50 51 }