Skip to content

Commit f63d0dd

Browse files
committed
fix(hosts): use proper data for status toggle
1 parent fb4b6d8 commit f63d0dd

File tree

1 file changed

+37
-23
lines changed

1 file changed

+37
-23
lines changed

dashboard/src/components/hosts/SortableHost.tsx

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -71,31 +71,45 @@ export default function SortableHost({ host, onEdit, onDuplicate, onDataChanged,
7171
if (!host.id) return
7272

7373
try {
74-
// Send full host data with only is_disabled toggled
74+
const { id, ...hostData } = host
75+
76+
let transformedMuxSettings = hostData.mux_settings
77+
if (hostData.mux_settings?.xray) {
78+
transformedMuxSettings = {
79+
...hostData.mux_settings,
80+
xray: {
81+
enabled: hostData.mux_settings.xray.enabled,
82+
concurrency: hostData.mux_settings.xray.concurrency,
83+
xudp_concurrency: hostData.mux_settings.xray.xudpConcurrency ?? undefined,
84+
xudp_proxy_udp_443: hostData.mux_settings.xray.xudpProxyUDP443 ?? undefined,
85+
} as any,
86+
}
87+
}
88+
89+
let transformedTransportSettings = hostData.transport_settings
90+
if (hostData.transport_settings?.xhttp_settings?.xmux) {
91+
transformedTransportSettings = {
92+
...hostData.transport_settings,
93+
xhttp_settings: {
94+
...hostData.transport_settings.xhttp_settings,
95+
xmux: {
96+
max_concurrency: hostData.transport_settings.xhttp_settings.xmux.maxConcurrency ?? undefined,
97+
max_connections: hostData.transport_settings.xhttp_settings.xmux.maxConnections ?? undefined,
98+
c_max_reuse_times: hostData.transport_settings.xhttp_settings.xmux.cMaxReuseTimes ?? undefined,
99+
h_max_reusable_secs: hostData.transport_settings.xhttp_settings.xmux.hMaxReusableSecs ?? undefined,
100+
h_max_request_times: hostData.transport_settings.xhttp_settings.xmux.hMaxRequestTimes ?? undefined,
101+
h_keep_alive_period: hostData.transport_settings.xhttp_settings.xmux.hKeepAlivePeriod ?? undefined,
102+
} as any,
103+
},
104+
}
105+
}
106+
75107
await modifyHost(host.id, {
76-
remark: host.remark || '',
77-
address: host.address || [],
78-
port: host.port,
79-
inbound_tag: host.inbound_tag || '',
80-
status: host.status || [],
81-
host: host.host || [],
82-
sni: host.sni || [],
83-
path: host.path || '',
84-
security: host.security || 'inbound_default',
85-
alpn: !host.alpn || host.alpn.length === 0 ? undefined : host.alpn,
86-
fingerprint: host.fingerprint === '' ? undefined : host.fingerprint,
87-
allowinsecure: host.allowinsecure || false,
108+
...hostData,
109+
mux_settings: transformedMuxSettings as any,
110+
transport_settings: transformedTransportSettings as any,
88111
is_disabled: !host.is_disabled,
89-
random_user_agent: host.random_user_agent || false,
90-
use_sni_as_host: host.use_sni_as_host || false,
91-
priority: host.priority || 0,
92-
ech_config_list: host.ech_config_list,
93-
fragment_settings: host.fragment_settings,
94-
noise_settings: host.noise_settings,
95-
mux_settings: host.mux_settings,
96-
transport_settings: host.transport_settings as any, // Type cast needed due to Output/Input mismatch
97-
http_headers: host.http_headers || {},
98-
})
112+
} as any)
99113

100114
toast.success(
101115
t(host.is_disabled ? 'host.enableSuccess' : 'host.disableSuccess', {

0 commit comments

Comments
 (0)