| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- {{if assertExists . "root_!kind" | not}} Unknown environment {{end}}
- {{if assertIsOneOf . "root_!kind" "json" "link" | not}} This template only works for json input. {{end}}
- {{ $type := tryGet . "root_!kind"}}
- {{ $methodName := tryGet . "root_!json_method_!unquoted" "root_!json_protocol_!unquoted" "root_!json_cipher_!unquoted" "root_!link_userinfo_!value_!rawContent"}}
- {{ if eq $type "link" }}
- {{ $methodName = splitAndGetNth ":" 0 $methodName}}
- {{end}}
- {{if assertValueIsOneOf $methodName "chacha20-ietf-poly1305" "chacha20-poly1305" "aes-128-gcm" "aes-256-gcm" | not}}
- This template only works for ss. {{end}}
- {{ $server_address := tryGet . "root_!json_server" "root_!json_address" "root_!json_endpoint" "root_!link_host"}}
- {{ $server_port := tryGet . "root_!json_port" "root_!json_server_port" "root_!json_endpoint" "root_!link_host"}}
- {{if $server_address | splitAndGetAfterNth ":" 0 | len | lt 1}}
- {{ $server_addressport_unquoted := tryGet . "root_!json_endpoint_!unquoted" "root_!link_host"}}
- {{ $server_port = $server_addressport_unquoted | splitAndGetNth ":" -1}}
- {{ $server_portWithSep := printf ":%v" $server_port}}
- {{ $server_address = $server_addressport_unquoted | stringCutSuffix $server_portWithSep | jsonEncode}}
- {{end}}
- {{ $name_annotation := tryGet . "root_!json_name_!unquoted" "root_!json_id_!unquoted" "root_!json_tag_!unquoted" "root_!json_remarks_!unquoted" "root_!link_fragment" "<default>"}}
- {{$password := tryGet . "root_!json_password" "root_!json_psk" "root_!link_userinfo_!value_!rawContent"}}
- {{ if eq $type "link" }}
- {{ $password = splitAndGetNth ":" 1 $password | jsonEncode}}
- {{end}}
- {
- "protocol": "shadowsocks",
- "settings": {
- "address": {{$server_address}},
- "port": {{$server_port}},
- "method": {{$methodName | jsonEncode}},
- "password": {{$password}}
- },
- "metadata":{
- "TagName": {{print $name_annotation "_" $server_address | jsonEncode}},
- "DisplayName": {{print $name_annotation | jsonEncode}}
- }
- }
|