Skip to content

feat: Support new xray X25519 output format - #1972

Open
wawan93 wants to merge 2 commits into
Gozargah:masterfrom
PlusOneVPN:master
Open

feat: Support new xray X25519 output format#1972
wawan93 wants to merge 2 commits into
Gozargah:masterfrom
PlusOneVPN:master

Conversation

@wawan93

@wawan93 wawan93 commented Dec 17, 2025

Copy link
Copy Markdown

The xray x25519 command in newer versions (e.g. v25.3.6+) changed its output format.

Old Format:

Private key: ...
Public key: ...

New Format:

PrivateKey: ...
Password: ...
Hash32: ...

(where Password corresponds to the public key)

I updated app/xray/core.py to robustly parse the output by converting lines into a key-value dictionary. This avoids potential regex issues and correctly detects which format is present by checking for the specific keys (Private key/Public key vs PrivateKey/Password).

Closes #1938

@vovausername

vovausername commented Dec 26, 2025

Copy link
Copy Markdown

@wawan93 hey!
As I know needs to add some code to generate subscription with VLESS Encryption

… and adding explicit error handling for generation failures.
r4r1ty-tech pushed a commit to r4r1ty-tech/iziproxy that referenced this pull request Jun 17, 2026
Из FutureTest.md: парсинг вывода 'xray x25519' зашит внутрь Generate(),
нельзя покрыть unit-тестами. Извлёк в public static, добавил 12 тестов.

КРИТИЧЕСКИЙ БАГ НАЙДЕН ПРИ ГУГЛЕНИИ:
Xray-core v25.3.6+ ИЗМЕНИЛ формат вывода 'xray x25519':
  - Старый: 'PrivateKey:' + 'Password (PublicKey):'
  - Новый:  'PrivateKey:' + 'Password:' + 'Hash32:'
  (XTLS/Xray-core#5159,
   Gozargah/Marzban#1972, декабрь 2025)

Текущий код IziProxy поддерживал ТОЛЬКО старые форматы — при xray
v25.3.6+ поле Password оставалось пустым, deploy ломался.
ParseX25519Output теперь принимает все три формата.

Что сделано:
- IziProxy.Core/XrayConfigParams.cs: добавлен public static
  ParseX25519Output(string raw) -> (string PrivateKey, string PublicKey).
  Бросает ArgumentException на null/empty, FormatException с подсказкой
  ожидаемых префиксов если ни PrivateKey ни PublicKey не найдены.
  - Generate() теперь вызывает ParseX25519Output, 30 строк
    inline-парсинга удалены.

- tests/IziProxy.Tests/XrayX25519ParserTests.cs: 12 unit-тестов:
  - OldFormat_WithPasswordPublicKey — старый основной формат
  - OldFormat_WithPrivateKeyPublicKey — альтернативный старый
  - NewFormat_WithPasswordAndHash32 — НОВЫЙ формат xray v25.3.6+,
    закрывает реальный баг
  - MixedFormatOrder_PrefersExplicitPublicKey — 'последний wins'
  - EmptyOrWhitespace_ThrowsArgumentException
  - NullOrMissing_Throws (ArgumentException, не ArgumentNullException —
    string.IsNullOrWhiteSpace не различает)
  - NoKeysPresent_ThrowsFormatException — сообщение содержит
    'PrivateKey' и 'PublicKey'
  - OnlyPrivateKey_ThrowsFormatException
  - OnlyPublicKey_ThrowsFormatException
  - HandlesCrlfLineEndings — SSH на Windows-серверах шлёт \r\n
  - PreservesBase64SpecialCharsInKey — + / = в base64
  - NewFormat_IgnoresHash32 — третья строка (Hash32) игнорируется

Все 12 проходят. Полный прогон: 50 + 12 = 62/62.
Sulaiman3352 added a commit to Sulaiman3352/Marzban that referenced this pull request Jul 22, 2026
…Key)'

More recent Xray-core versions have changed the output labels for `xray x25519` again:
The public key line is now printed as "Password (PublicKey): ..." rather than "Public key: ..." or "Password: ...".

The current parser does exact key lookups, so this format returns None, which crashes config validation in _resolve_inbounds with:
TypeError: 'NoneType' object is not subscriptable (settings['pbk'])

Instead of matching output keys by exact name, this change matches by prefix, so all three known formats parse correctly:
  - Private key: / Public key: (old)
  - "PrivateKey: / Password:" (v25.3.6+, fixed by Gozargah#1972)
  - "PrivateKey: / Password (PublicKey):" (exists)

No change in behavior for users who use the bundled xray version.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CORE ERROR v25.8.31

2 participants