This commit is contained in:
2026-07-04 20:24:20 -03:00
parent 4866f0cf10
commit ea15f1bfa1
10 changed files with 1059 additions and 190 deletions
+82
View File
@@ -2434,6 +2434,86 @@ function toggleUdpgwFields(on) {
el.style.pointerEvents = on ? "" : "none";
}
const XRAY_NATIVE_TUNING_DEFAULTS = {
safe: {
mux_max_sessions: 64,
mux_global_sessions: 8192,
mux_udp_idle_ms: 30000,
mux_udp_read_buffer: 131072,
mux_udp_write_buffer: 131072,
xhttp_max_sessions: 4096,
xhttp_buffered_posts: 32,
xhttp_queue_timeout_ms: 500,
xhttp_flush_ms: 2,
xhttp_flush_bytes: 32768,
h2_max_concurrent_streams: 256,
h2_upload_buffer_conn: 1048576,
h2_upload_buffer_stream: 262144,
trace_packets: false,
},
"2k": {
mux_max_sessions: 128,
mux_global_sessions: 32768,
mux_udp_idle_ms: 15000,
mux_udp_read_buffer: 262144,
mux_udp_write_buffer: 262144,
xhttp_max_sessions: 16384,
xhttp_buffered_posts: 64,
xhttp_queue_timeout_ms: 250,
xhttp_flush_ms: 5,
xhttp_flush_bytes: 131072,
h2_max_concurrent_streams: 1024,
h2_upload_buffer_conn: 1048576,
h2_upload_buffer_stream: 262144,
trace_packets: false,
},
};
const XRAY_NATIVE_TUNING_FIELDS = {
mux_max_sessions: "cfgXrayMuxMaxSessions",
mux_global_sessions: "cfgXrayMuxGlobalSessions",
mux_udp_idle_ms: "cfgXrayMuxUdpIdleMs",
mux_udp_read_buffer: "cfgXrayMuxUdpRbuf",
mux_udp_write_buffer: "cfgXrayMuxUdpWbuf",
xhttp_max_sessions: "cfgXrayXhttpMaxSessions",
xhttp_buffered_posts: "cfgXrayXhttpBufferedPosts",
xhttp_queue_timeout_ms: "cfgXrayXhttpQueueTimeoutMs",
xhttp_flush_ms: "cfgXrayXhttpFlushMs",
xhttp_flush_bytes: "cfgXrayXhttpFlushBytes",
h2_max_concurrent_streams: "cfgXrayH2MaxStreams",
h2_upload_buffer_conn: "cfgXrayH2UploadConn",
h2_upload_buffer_stream: "cfgXrayH2UploadStream",
};
function setXrayNativeTuningDefaults(profile = "2k") {
const t = XRAY_NATIVE_TUNING_DEFAULTS[profile] || XRAY_NATIVE_TUNING_DEFAULTS.safe;
writeXrayNativeTuning(t);
}
function writeXrayNativeTuning(t = {}) {
const defaults = XRAY_NATIVE_TUNING_DEFAULTS.safe;
Object.entries(XRAY_NATIVE_TUNING_FIELDS).forEach(([key, id]) => {
const el = document.getElementById(id);
if (el) el.value = Number(t[key] || defaults[key] || 0);
});
const trace = document.getElementById("cfgXrayTracePackets");
if (trace) trace.checked = !!t.trace_packets;
}
function readXrayNativeTuning() {
const out = {};
Object.entries(XRAY_NATIVE_TUNING_FIELDS).forEach(([key, id]) => {
const el = document.getElementById(id);
out[key] = parseInt(el?.value || "0", 10) || 0;
});
out.trace_packets = !!document.getElementById("cfgXrayTracePackets")?.checked;
return out;
}
// Inline onclick handlers in index.html need this on window when the bundled JS is served from admin/assets/app.js.
window.setXrayNativeTuningDefaults = setXrayNativeTuningDefaults;
async function loadServerConfig() {
const st = document.getElementById("srvCfgStatus");
st.textContent = "Loading…";
@@ -2503,6 +2583,7 @@ async function loadServerConfig() {
const x = c.xray || {};
document.getElementById("cfgXrayEnabled").checked = !!x.enabled;
document.getElementById("cfgXrayMode").value = xrayModeFromConfig(x);
writeXrayNativeTuning(x.native_tuning || XRAY_NATIVE_TUNING_DEFAULTS.safe);
st.textContent = "Config loaded.";
} catch (e) {
@@ -2576,6 +2657,7 @@ async function saveServerConfig() {
api_server: "127.0.0.1:10085",
online_window_seconds: 90,
stats_poll_seconds: 15,
native_tuning: readXrayNativeTuning(),
},
};
+25 -1
View File
@@ -1188,6 +1188,30 @@
</label>
<div class="field" style="margin-top:8px;"><label>Runtime mode</label><select id="cfgXrayMode"><option value="native">Internal native emulator</option><option value="external">External xray binary</option></select></div>
<div class="hint" style="margin-top:6px;color:var(--muted);">Native runs inside DragonCoreSSH. External uses /opt/sshpanel/xray with DB-backed /opt/sshpanel/xray_config.json and Stats API on 127.0.0.1:10085.</div>
<details style="margin-top:10px;" open>
<summary style="cursor:pointer;font-size:.76rem;font-weight:700;color:var(--text);">Native Xray scale tuning</summary>
<div class="grid2" style="margin-top:10px;gap:8px;">
<div class="field"><label>Mux sessions per connection</label><input type="number" min="1" id="cfgXrayMuxMaxSessions" placeholder="128"/></div>
<div class="field"><label>Global mux backend sessions</label><input type="number" min="1" id="cfgXrayMuxGlobalSessions" placeholder="32768"/></div>
<div class="field"><label>Mux UDP idle ms</label><input type="number" min="1000" id="cfgXrayMuxUdpIdleMs" placeholder="15000"/></div>
<div class="field"><label>Mux UDP read buffer bytes</label><input type="number" min="4096" id="cfgXrayMuxUdpRbuf" placeholder="262144"/></div>
<div class="field"><label>Mux UDP write buffer bytes</label><input type="number" min="4096" id="cfgXrayMuxUdpWbuf" placeholder="262144"/></div>
<div class="field"><label>XHTTP max active sessions</label><input type="number" min="1" id="cfgXrayXhttpMaxSessions" placeholder="16384"/></div>
<div class="field"><label>XHTTP buffered posts</label><input type="number" min="1" id="cfgXrayXhttpBufferedPosts" placeholder="64"/></div>
<div class="field"><label>XHTTP queue timeout ms</label><input type="number" min="10" id="cfgXrayXhttpQueueTimeoutMs" placeholder="250"/></div>
<div class="field"><label>XHTTP flush ms</label><input type="number" min="1" id="cfgXrayXhttpFlushMs" placeholder="5"/></div>
<div class="field"><label>XHTTP flush bytes</label><input type="number" min="1024" id="cfgXrayXhttpFlushBytes" placeholder="131072"/></div>
<div class="field"><label>HTTP/2 max streams</label><input type="number" min="1" id="cfgXrayH2MaxStreams" placeholder="1024"/></div>
<div class="field"><label>HTTP/2 upload buffer / conn</label><input type="number" min="65536" id="cfgXrayH2UploadConn" placeholder="1048576"/></div>
<div class="field"><label>HTTP/2 upload buffer / stream</label><input type="number" min="32768" id="cfgXrayH2UploadStream" placeholder="262144"/></div>
<label style="font-size:.73rem;display:flex;align-items:center;gap:5px;cursor:pointer;grid-column:1/-1"><input type="checkbox" id="cfgXrayTracePackets"/> Trace every XHTTP/mux packet <span class="hint">debug only, slows QUIC</span></label>
<div class="card-actions" style="grid-column:1/-1;">
<button class="btn btn-ghost btn-sm" type="button" onclick="setXrayNativeTuningDefaults('2k')">Apply 2K defaults</button>
<button class="btn btn-ghost btn-sm" type="button" onclick="setXrayNativeTuningDefaults('safe')">Apply safe defaults</button>
</div>
<div class="hint" style="grid-column:1/-1;margin-top:-4px;">These values are saved in the panel config and applied live on restart/reload. No systemd Environment lines are needed.</div>
</div>
</details>
</div>
</div><!-- /right -->
@@ -1211,6 +1235,6 @@
</div><!-- /shell -->
</div><!-- /app -->
<script defer src="assets/app.js?v=20260622dnsttfakednsfast"></script>
<script defer src="assets/app.js?v=20260704xrayadmintune2"></script>
</body>
</html>