[GH-ISSUE #1595] Sharing XRay native .json don't work at any app #665

Closed
opened 2026-10-13 20:26:08 +00:00 by bsakaguchi · 4 comments
Owner

Originally created by @vrzdrb on GitHub (May 18, 2025).
Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/1595

Describe the bug
Most Xray applications (v2rayN, v2rayNG, Streisand, V2rayTun) expect a key in the vless:// format and do not recognize the "native XRay format" in .json. It simply write "Error" when trying to add settings, or (V2Box) recognize and add, but the connection does not occur.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'Share'
  2. Click on 'XRay native format'
  3. Try to past it to 'v2rayN / v2rayNG / Streisand / V2rayTun / V2Box'
  4. See error

Expected behavior
Sharing in vless:// format, like all xray applications do

Log files

Screenshots

Desktop (please complete the following information):

  • OS: Ubuntu 24.04, Windows 11
  • AmneziaVPN 4.8.5.0

Smartphone (please complete the following information):

  • Device: Google Pixel 8a, iPhone 11
  • OS: Android 15, iOS 18
  • Version AmneziaVPN 4.8.5.0

Server (please complete the following information):

  • OS: Ubuntu 24.04

Additional context
On Linux version client even't don't create QR and just do nothing when trying to save settings as a file, only "copy" button works.

Originally created by @vrzdrb on GitHub (May 18, 2025). Original GitHub issue: https://github.com/amnezia-vpn/amnezia-client/issues/1595 **Describe the bug** Most Xray applications (v2rayN, v2rayNG, Streisand, V2rayTun) expect a key in the vless:// format and do not recognize the "native XRay format" in .json. It simply write "Error" when trying to add settings, or (V2Box) recognize and add, but the connection does not occur. **To Reproduce** Steps to reproduce the behavior: 1. Go to 'Share' 2. Click on 'XRay native format' 3. Try to past it to 'v2rayN / v2rayNG / Streisand / V2rayTun / V2Box' 4. See error **Expected behavior** Sharing in vless:// format, like all xray applications do **Log files** --- **Screenshots** --- **Desktop (please complete the following information):** - OS: Ubuntu 24.04, Windows 11 - AmneziaVPN 4.8.5.0 **Smartphone (please complete the following information):** - Device: Google Pixel 8a, iPhone 11 - OS: Android 15, iOS 18 - Version AmneziaVPN 4.8.5.0 **Server (please complete the following information):** - OS: Ubuntu 24.04 **Additional context** On Linux version client even't don't create QR and just do nothing when trying to save settings as a file, only "copy" button works.
Author
Owner

@ShidlaSGC commented on GitHub (May 19, 2025):

Tested with v2rayNG on Android:

vless://<id>@<address>:<port>?security=reality&encryption=none&pbk=<publicKey>&host=<serverName>&headerType=none&fp=chrome&type=tcp&flow=xtls-rprx-vision&sid=<shortId>#<AnyConvenientConnectionName>

Works fine

<!-- gh-comment-id:2889891474 --> @ShidlaSGC commented on GitHub (May 19, 2025): Tested with v2rayNG on Android: `vless://<id>@<address>:<port>?security=reality&encryption=none&pbk=<publicKey>&host=<serverName>&headerType=none&fp=chrome&type=tcp&flow=xtls-rprx-vision&sid=<shortId>#<AnyConvenientConnectionName>` Works fine
Author
Owner

@xdx505 commented on GitHub (Jun 11, 2025):

Same problem

<!-- gh-comment-id:2961307109 --> @xdx505 commented on GitHub (Jun 11, 2025): Same problem
Author
Owner

@ngaer commented on GitHub (Jun 17, 2025):

You can use this bash script to convert amnezia JSON file to VLESS URI

#!/bin/bash
# Filename: vless_json_to_uri.sh

# Usage:
#   ./vless_json_to_uri.sh config.json
#   cat config.json | ./vless_json_to_uri.sh

json=$(cat "$@")

id=$(echo "$json" | jq -r '.outbounds[0].settings.vnext[0].users[0].id')
address=$(echo "$json" | jq -r '.outbounds[0].settings.vnext[0].address')
port=$(echo "$json" | jq -r '.outbounds[0].settings.vnext[0].port')
encryption=$(echo "$json" | jq -r '.outbounds[0].settings.vnext[0].users[0].encryption // "none"')
flow=$(echo "$json" | jq -r '.outbounds[0].settings.vnext[0].users[0].flow // empty')
network=$(echo "$json" | jq -r '.outbounds[0].streamSettings.network // empty')
security=$(echo "$json" | jq -r '.outbounds[0].streamSettings.security // empty')
fp=$(echo "$json" | jq -r '.outbounds[0].streamSettings.realitySettings.fingerprint // empty')
pbk=$(echo "$json" | jq -r '.outbounds[0].streamSettings.realitySettings.publicKey // empty')
sni=$(echo "$json" | jq -r '.outbounds[0].streamSettings.realitySettings.serverName // empty')
sid=$(echo "$json" | jq -r '.outbounds[0].streamSettings.realitySettings.shortId // empty')
spx=$(echo "$json" | jq -r '.outbounds[0].streamSettings.realitySettings.spiderX // empty')

# Build query string
query="encryption=$encryption"
[ -n "$flow" ] && query="$query&flow=$flow"
[ -n "$network" ] && query="$query&type=$network"
[ -n "$security" ] && query="$query&security=$security"
[ -n "$fp" ] && query="$query&fp=$fp"
[ -n "$pbk" ] && query="$query&pbk=$pbk"
[ -n "$sni" ] && query="$query&sni=$sni"
[ -n "$sid" ] && query="$query&sid=$sid"
[ -n "$spx" ] && query="$query&spx=$spx"

echo "vless://$id@$address:$port?$query"

<!-- gh-comment-id:2981363347 --> @ngaer commented on GitHub (Jun 17, 2025): You can use this bash script to convert amnezia JSON file to VLESS URI ```bash #!/bin/bash # Filename: vless_json_to_uri.sh # Usage: # ./vless_json_to_uri.sh config.json # cat config.json | ./vless_json_to_uri.sh json=$(cat "$@") id=$(echo "$json" | jq -r '.outbounds[0].settings.vnext[0].users[0].id') address=$(echo "$json" | jq -r '.outbounds[0].settings.vnext[0].address') port=$(echo "$json" | jq -r '.outbounds[0].settings.vnext[0].port') encryption=$(echo "$json" | jq -r '.outbounds[0].settings.vnext[0].users[0].encryption // "none"') flow=$(echo "$json" | jq -r '.outbounds[0].settings.vnext[0].users[0].flow // empty') network=$(echo "$json" | jq -r '.outbounds[0].streamSettings.network // empty') security=$(echo "$json" | jq -r '.outbounds[0].streamSettings.security // empty') fp=$(echo "$json" | jq -r '.outbounds[0].streamSettings.realitySettings.fingerprint // empty') pbk=$(echo "$json" | jq -r '.outbounds[0].streamSettings.realitySettings.publicKey // empty') sni=$(echo "$json" | jq -r '.outbounds[0].streamSettings.realitySettings.serverName // empty') sid=$(echo "$json" | jq -r '.outbounds[0].streamSettings.realitySettings.shortId // empty') spx=$(echo "$json" | jq -r '.outbounds[0].streamSettings.realitySettings.spiderX // empty') # Build query string query="encryption=$encryption" [ -n "$flow" ] && query="$query&flow=$flow" [ -n "$network" ] && query="$query&type=$network" [ -n "$security" ] && query="$query&security=$security" [ -n "$fp" ] && query="$query&fp=$fp" [ -n "$pbk" ] && query="$query&pbk=$pbk" [ -n "$sni" ] && query="$query&sni=$sni" [ -n "$sid" ] && query="$query&sid=$sid" [ -n "$spx" ] && query="$query&spx=$spx" echo "vless://$id@$address:$port?$query" ```
Author
Owner

@vrzdrb commented on GitHub (Jun 18, 2025):

Today we made a python script with Grok to convert the config to vless://. The problem is solved

import json
import urllib.parse
import os

def convert_json_to_vless(json_file, custom_name):
    # Читаем JSON-файл
    with open(json_file, 'r') as f:
        config = json.load(f)
    
    # Извлекаем необходимые данные
    outbound = config['outbounds'][0]
    vnext = outbound['settings']['vnext'][0]
    user = vnext['users'][0]
    reality = outbound['streamSettings']['realitySettings']
    
    # Собираем параметры
    vless_params = {
        'id': user['id'],
        'address': vnext['address'],
        'port': vnext['port'],
        'security': outbound['streamSettings']['security'],
        'sni': reality['serverName'],
        'fp': reality['fingerprint'],
        'pbk': reality['publicKey'],
        'sid': reality['shortId'],
        'type': outbound['streamSettings']['network'],
        'flow': user['flow'],
        'encryption': user['encryption']
    }
    
    # Формируем URL
    vless_url = (f"vless://{vless_params['id']}@{vless_params['address']}:{vless_params['port']}"
                 f"?security={vless_params['security']}"
                 f"&sni={urllib.parse.quote(vless_params['sni'])}"
                 f"&fp={vless_params['fp']}"
                 f"&pbk={urllib.parse.quote(vless_params['pbk'])}"
                 f"&sid={vless_params['sid']}"
                 f"&type={vless_params['type']}"
                 f"&flow={vless_params['flow']}"
                 f"&encryption={vless_params['encryption']}"
                 f"#{urllib.parse.quote(custom_name)}")
    
    return vless_url

def save_to_file(vless_url, custom_name):
    # Формируем имя файла на основе custom_name
    output_file = f"{custom_name}.txt"
    # Заменяем недопустимые символы в имени файла
    safe_name = "".join(c for c in custom_name if c.isalnum() or c in ('-', '_')).rstrip()
    if not safe_name:
        safe_name = "Amnezia-VLESS"  # Имя по умолчанию, если после очистки имя пустое
    output_file = f"{safe_name}.txt"
    
    # Сохраняем результат в текстовый файл
    with open(output_file, 'w') as f:
        f.write(vless_url)
    print(f"Ключ сохранен в файл: {output_file}")

# Использование скрипта
if __name__ == "__main__":
    json_file = "amnezia_for_xray.json"
    
    # Запрашиваем у пользователя имя для ключа
    custom_name = input("Введите имя для ключа VLESS (например, My-VLESS): ").strip()
    if not custom_name:
        custom_name = "Amnezia-VLESS"  # Имя по умолчанию, если пользователь ничего не ввел
    
    # Конвертируем JSON в ключ VLESS
    vless_key = convert_json_to_vless(json_file, custom_name)
    
    # Выводим ключ в консоль
    print("Сгенерированный ключ VLESS:")
    print(vless_key)
    
    # Сохраняем ключ в файл с именем, основанным на custom_name
    save_to_file(vless_key, custom_name)
<!-- gh-comment-id:2983446097 --> @vrzdrb commented on GitHub (Jun 18, 2025): Today we made a python script with Grok to convert the config to vless://. The problem is solved ``` import json import urllib.parse import os def convert_json_to_vless(json_file, custom_name): # Читаем JSON-файл with open(json_file, 'r') as f: config = json.load(f) # Извлекаем необходимые данные outbound = config['outbounds'][0] vnext = outbound['settings']['vnext'][0] user = vnext['users'][0] reality = outbound['streamSettings']['realitySettings'] # Собираем параметры vless_params = { 'id': user['id'], 'address': vnext['address'], 'port': vnext['port'], 'security': outbound['streamSettings']['security'], 'sni': reality['serverName'], 'fp': reality['fingerprint'], 'pbk': reality['publicKey'], 'sid': reality['shortId'], 'type': outbound['streamSettings']['network'], 'flow': user['flow'], 'encryption': user['encryption'] } # Формируем URL vless_url = (f"vless://{vless_params['id']}@{vless_params['address']}:{vless_params['port']}" f"?security={vless_params['security']}" f"&sni={urllib.parse.quote(vless_params['sni'])}" f"&fp={vless_params['fp']}" f"&pbk={urllib.parse.quote(vless_params['pbk'])}" f"&sid={vless_params['sid']}" f"&type={vless_params['type']}" f"&flow={vless_params['flow']}" f"&encryption={vless_params['encryption']}" f"#{urllib.parse.quote(custom_name)}") return vless_url def save_to_file(vless_url, custom_name): # Формируем имя файла на основе custom_name output_file = f"{custom_name}.txt" # Заменяем недопустимые символы в имени файла safe_name = "".join(c for c in custom_name if c.isalnum() or c in ('-', '_')).rstrip() if not safe_name: safe_name = "Amnezia-VLESS" # Имя по умолчанию, если после очистки имя пустое output_file = f"{safe_name}.txt" # Сохраняем результат в текстовый файл with open(output_file, 'w') as f: f.write(vless_url) print(f"Ключ сохранен в файл: {output_file}") # Использование скрипта if __name__ == "__main__": json_file = "amnezia_for_xray.json" # Запрашиваем у пользователя имя для ключа custom_name = input("Введите имя для ключа VLESS (например, My-VLESS): ").strip() if not custom_name: custom_name = "Amnezia-VLESS" # Имя по умолчанию, если пользователь ничего не ввел # Конвертируем JSON в ключ VLESS vless_key = convert_json_to_vless(json_file, custom_name) # Выводим ключ в консоль print("Сгенерированный ключ VLESS:") print(vless_key) # Сохраняем ключ в файл с именем, основанным на custom_name save_to_file(vless_key, custom_name) ```
Sign in to join this conversation.
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
amnezia-vpn/amnezia-client#665
No description provided.