feat: Support new xray X25519 output format - #1972
Open
wawan93 wants to merge 2 commits into
Open
Conversation
|
@wawan93 hey! |
… 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The xray x25519 command in newer versions (e.g. v25.3.6+) changed its output format.
Old Format:
New Format:
(where Password corresponds to the public key)
I updated
app/xray/core.pyto 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