[GH-ISSUE #6854] [Bug]: عدم امکان ویرایش اینباند JSON #4557

Closed
opened 2026-10-31 20:40:29 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @URT19 on GitHub (Oct 16, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6854

Describe the bug

درود
توی نسخه آخر وقتی میخوام اینباند رو بصورت دستی ویرایش کنم نمیشه
اینتر میزنم میره اول سطر و اصلا نمیتونم سطر جدید تعریف کنم، یه باگی توی تعریف
adress
هست
Inbound JSON sections
کانفیگ بصورت
CDN
نوشته شده ولی دامین پنل رو برمیگردونه

How to reproduce the problem

توی قسمت ساخت اینباند
وقتی قسمت انتهایی میرید
Inbound JSON sections
اینتر میزنم نمیره سطر بعد، نمایشگر کیبورد میره اول خط
JSON

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.10.2

Xray-core version

No response

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24

Which parts of the panel are affected?

No response

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

None

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @URT19 on GitHub (Oct 16, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6854 ### Describe the bug درود توی نسخه آخر وقتی میخوام اینباند رو بصورت دستی ویرایش کنم نمیشه اینتر میزنم میره اول سطر و اصلا نمیتونم سطر جدید تعریف کنم، یه باگی توی تعریف adress هست Inbound JSON sections کانفیگ بصورت CDN نوشته شده ولی دامین پنل رو برمیگردونه ### How to reproduce the problem توی قسمت ساخت اینباند وقتی قسمت انتهایی میرید Inbound JSON sections اینتر میزنم نمیره سطر بعد، نمایشگر کیبورد میره اول خط JSON ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.10.2 ### Xray-core version _No response_ ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24 ### Which parts of the panel are affected? _No response_ ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? None ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:40:29 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Oct 16, 2026):

مشکل Enter واقعی است و باگ ویرایشگر JSON در تب «All» است. با هر ویرایشی که JSON را معتبر نگه دارد و فقط فاصله یا سطر جدید اضافه کند (مثل زدن Enter)، ویرایشگر کل متن را با نسخهٔ فرمت‌شدهٔ خودش جایگزین می‌کند. برای همین سطر جدید پاک می‌شود و مکان‌نما به ابتدای متن می‌پرد.

راه موقت: تا اصلاح شدن باگ، به‌جای تب All از تب‌های جداگانهٔ همان بخش استفاده کنید:
Settings، Stream و Sniffing.
این تب‌ها از مسیر دیگری استفاده می‌کنند که این مشکل را ندارد (توضیح پایین). راه دیگر این است که JSON کامل را جای دیگری بنویسید و یک‌جا در ویرایشگر paste کنید.

علت

در frontend/src/pages/inbounds/form/advanced-editors.tsx، تابع AdvancedAllEditor بعد از هر تغییرِ قابل parse، متن خامِ کاربر را به‌عنوان «آخرین متنی که خودمان نوشتیم» ذخیره می‌کند (خط 191):

lastEmitRef.current = next;

اما effectی که فرم را دوباره همگام می‌کند (خطوط 144 تا 148)، این مقدار را با خروجی فرمت‌شدهٔ serialize() مقایسه می‌کند. این خروجی JSON.stringify(out, null, 2) است و pruneEmpty و normalizeClients هم روی آن اجرا شده‌اند:

const formStr = serialize();
if (formStr === lastEmitRef.current) return;
setText(formStr);

setValue('settings', parsed.settings) (خط 183) یک شیء جدید در فرم می‌گذارد، پس useWatch دوباره اجرا می‌شود. وقتی Enter می‌زنید، متن شما یک سطر خالی اضافه دارد و با formStr برابر نیست، پس setText(formStr) متن را بازنویسی می‌کند. بعد JsonEditor کل سند را جایگزین می‌کند (frontend/src/components/form/JsonEditor.tsx:161):

view.dispatch({ changes: { from: 0, to: current.length, insert: value } });

چون در این dispatch مقدار selection داده نشده، مکان‌نما به ابتدای متن جایگزین‌شده برمی‌گردد. این قسمت را از رفتار CodeMirror استنباط کرده‌ام، اجرا نکرده‌ام.

تب‌های Settings/Stream/Sniffing (یعنی AdvancedSliceEditor) این مشکل را ندارند. آنجا lastEmitRef با همان فرمت canonical پر می‌شود (خط 75)، پس با serialize(watched) برابر است و متن بازنویسی نمی‌شود.

دربارهٔ آدرس CDN

از توضیحات مشخص نیست آدرس CDN را در کدام فیلد نوشته‌اید. ویرایشگر All فقط این فیلدها را نشان می‌دهد و می‌خواند:
listen، port، protocol، tag، settings، sniffing و streamSettings
(خطوط 123 تا 133). آدرسی که در لینک‌های اشتراک قرار می‌گیرد را resolveShareHost در frontend/src/lib/xray/inbound-link.ts:1337 انتخاب می‌کند. با راهبرد پیش‌فرض node، اگر آدرس نود یا listen قابل اشتراکی نباشد، آدرس پنل استفاده می‌شود:

default:
  return nodeAddr || listenAddr || fallbackAddr;

برای اینکه آدرس CDN در لینک بیاید، در فرم اینباند گزینهٔ «راهبرد آدرس اشتراک‌گذاری» را روی «سفارشی» بگذارید و دامنهٔ CDN را در «آدرس اشتراک‌گذاری سفارشی» وارد کنید. اگر پورت یا SNI هم فرق دارد، از «پراکسی خارجی» (externalProxy) استفاده کنید. اگر با این کار باز هم دامنهٔ پنل برگشت، JSON اینباند و لینک تولیدشده را به‌صورت متن (با دامنه‌های مخفی‌شده) بفرستید.


Verdict:        Confirmed bug
Severity:       Medium
Confidence:     High
Root cause:     frontend/src/pages/inbounds/form/advanced-editors.tsx, AdvancedAllEditor:
                onChange stores the raw text (`lastEmitRef.current = next`, line 191),
                while the resync effect (lines 144-148) compares it to the pretty-printed,
                pruned serialize() output. Any edit that still parses but differs in
                formatting (Enter, extra spaces) fails the guard, so setText(formStr)
                overwrites the buffer. JsonEditor.tsx:161 then replaces the whole doc,
                which drops the newline and resets the caret.
                The raw-text guard was already in 3f787ae1 (Zod migration) and was
                carried through the RHF migration 61e12e4c.
Same class:     None found. AdvancedSliceEditor stores the canonical string (line 75),
                so its guard matches. The full-doc replace in JsonEditor.tsx:161 is
                shared, but it only fires when a parent pushes a different value.
Already fixed:  Still present on the default branch (608ef4e4, v3.10.2)
Duplicate of:   None
Evidence:       advanced-editors.tsx:144-148, 183, 191; JsonEditor.tsx:155-162
Not determined: Which field the reporter put the CDN address in (the "address" half
                of the report). The share host comes from resolveShareHost
                (inbound-link.ts:1337-1353), and the default `node` strategy falls back
                to the panel host.

Suggested fix: make the guard in AdvancedAllEditor compare like with like. For example, store serialize()'s canonical form of the parsed values in lastEmitRef (the way AdvancedSliceEditor does at line 75), not the raw buffer. Then a formatting-only edit never triggers a resync.

این پاسخ به‌صورت خودکار تولید شده است و ممکن است یکی از نگهدارندگان پروژه پیگیری کند.

<!-- gh-comment-id:6212539373 --> @github-actions[bot] commented on GitHub (Oct 16, 2026): مشکل Enter واقعی است و باگ ویرایشگر JSON در تب «All» است. با هر ویرایشی که JSON را معتبر نگه دارد و فقط فاصله یا سطر جدید اضافه کند (مثل زدن Enter)، ویرایشگر کل متن را با نسخهٔ فرمت‌شدهٔ خودش جایگزین می‌کند. برای همین سطر جدید پاک می‌شود و مکان‌نما به ابتدای متن می‌پرد. **راه موقت:** تا اصلاح شدن باگ، به‌جای تب `All` از تب‌های جداگانهٔ همان بخش استفاده کنید: `Settings`، `Stream` و `Sniffing`. این تب‌ها از مسیر دیگری استفاده می‌کنند که این مشکل را ندارد (توضیح پایین). راه دیگر این است که JSON کامل را جای دیگری بنویسید و یک‌جا در ویرایشگر paste کنید. ### علت در `frontend/src/pages/inbounds/form/advanced-editors.tsx`، تابع `AdvancedAllEditor` بعد از هر تغییرِ قابل parse، **متن خامِ کاربر** را به‌عنوان «آخرین متنی که خودمان نوشتیم» ذخیره می‌کند (خط 191): ```ts lastEmitRef.current = next; ``` اما effectی که فرم را دوباره همگام می‌کند (خطوط 144 تا 148)، این مقدار را با خروجی **فرمت‌شدهٔ** `serialize()` مقایسه می‌کند. این خروجی `JSON.stringify(out, null, 2)` است و `pruneEmpty` و `normalizeClients` هم روی آن اجرا شده‌اند: ```ts const formStr = serialize(); if (formStr === lastEmitRef.current) return; setText(formStr); ``` `setValue('settings', parsed.settings)` (خط 183) یک شیء جدید در فرم می‌گذارد، پس `useWatch` دوباره اجرا می‌شود. وقتی Enter می‌زنید، متن شما یک سطر خالی اضافه دارد و با `formStr` برابر نیست، پس `setText(formStr)` متن را بازنویسی می‌کند. بعد `JsonEditor` کل سند را جایگزین می‌کند (`frontend/src/components/form/JsonEditor.tsx:161`): ```ts view.dispatch({ changes: { from: 0, to: current.length, insert: value } }); ``` چون در این dispatch مقدار `selection` داده نشده، مکان‌نما به ابتدای متن جایگزین‌شده برمی‌گردد. این قسمت را از رفتار CodeMirror استنباط کرده‌ام، اجرا نکرده‌ام. تب‌های `Settings`/`Stream`/`Sniffing` (یعنی `AdvancedSliceEditor`) این مشکل را ندارند. آنجا `lastEmitRef` با همان فرمت canonical پر می‌شود (خط 75)، پس با `serialize(watched)` برابر است و متن بازنویسی نمی‌شود. ### دربارهٔ آدرس CDN از توضیحات مشخص نیست آدرس CDN را در کدام فیلد نوشته‌اید. ویرایشگر `All` فقط این فیلدها را نشان می‌دهد و می‌خواند: `listen`، `port`، `protocol`، `tag`، `settings`، `sniffing` و `streamSettings` (خطوط 123 تا 133). آدرسی که در لینک‌های اشتراک قرار می‌گیرد را `resolveShareHost` در `frontend/src/lib/xray/inbound-link.ts:1337` انتخاب می‌کند. با راهبرد پیش‌فرض `node`، اگر آدرس نود یا `listen` قابل اشتراکی نباشد، آدرس پنل استفاده می‌شود: ```ts default: return nodeAddr || listenAddr || fallbackAddr; ``` برای اینکه آدرس CDN در لینک بیاید، در فرم اینباند گزینهٔ «راهبرد آدرس اشتراک‌گذاری» را روی «سفارشی» بگذارید و دامنهٔ CDN را در «آدرس اشتراک‌گذاری سفارشی» وارد کنید. اگر پورت یا SNI هم فرق دارد، از «پراکسی خارجی» (`externalProxy`) استفاده کنید. اگر با این کار باز هم دامنهٔ پنل برگشت، JSON اینباند و لینک تولیدشده را به‌صورت متن (با دامنه‌های مخفی‌شده) بفرستید. --- ``` Verdict: Confirmed bug Severity: Medium Confidence: High Root cause: frontend/src/pages/inbounds/form/advanced-editors.tsx, AdvancedAllEditor: onChange stores the raw text (`lastEmitRef.current = next`, line 191), while the resync effect (lines 144-148) compares it to the pretty-printed, pruned serialize() output. Any edit that still parses but differs in formatting (Enter, extra spaces) fails the guard, so setText(formStr) overwrites the buffer. JsonEditor.tsx:161 then replaces the whole doc, which drops the newline and resets the caret. The raw-text guard was already in 3f787ae1 (Zod migration) and was carried through the RHF migration 61e12e4c. Same class: None found. AdvancedSliceEditor stores the canonical string (line 75), so its guard matches. The full-doc replace in JsonEditor.tsx:161 is shared, but it only fires when a parent pushes a different value. Already fixed: Still present on the default branch (608ef4e4, v3.10.2) Duplicate of: None Evidence: advanced-editors.tsx:144-148, 183, 191; JsonEditor.tsx:155-162 Not determined: Which field the reporter put the CDN address in (the "address" half of the report). The share host comes from resolveShareHost (inbound-link.ts:1337-1353), and the default `node` strategy falls back to the panel host. ``` Suggested fix: make the guard in `AdvancedAllEditor` compare like with like. For example, store `serialize()`'s canonical form of the parsed values in `lastEmitRef` (the way `AdvancedSliceEditor` does at line 75), not the raw buffer. Then a formatting-only edit never triggers a resync. *این پاسخ به‌صورت خودکار تولید شده است و ممکن است یکی از نگهدارندگان پروژه پیگیری کند.* <!-- claude-issue:analyst -->
Sign in to join this conversation.
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
MHSanaei/3x-ui#4557
No description provided.