feat(settings): use webListen URI format for Web API address
- rename webPort field/label to webListen (Web API 监听地址) - seed initial form state from webListen with legacy webPort fallback - save webListen URI string while deriving legacy webPort integer for backend compatibility
This commit is contained in:
+20
-9
@@ -151,6 +151,9 @@ function SettingsForm({
|
|||||||
...initialConfig,
|
...initialConfig,
|
||||||
TCPListen: toAddrString(initialConfig.TCPListen),
|
TCPListen: toAddrString(initialConfig.TCPListen),
|
||||||
UDPListen: toAddrString(initialConfig.UDPListen),
|
UDPListen: toAddrString(initialConfig.UDPListen),
|
||||||
|
webListen:
|
||||||
|
initialConfig.webListen ??
|
||||||
|
(initialConfig.webPort ? `http://0.0.0.0:${initialConfig.webPort}` : 'http://0.0.0.0:4665'),
|
||||||
}))
|
}))
|
||||||
const [tunEnabled, setTunEnabled] = useState<boolean>(() =>
|
const [tunEnabled, setTunEnabled] = useState<boolean>(() =>
|
||||||
initialConfig.enableTUN ??
|
initialConfig.enableTUN ??
|
||||||
@@ -209,9 +212,19 @@ function SettingsForm({
|
|||||||
form.denyConnectionBroadcast ??
|
form.denyConnectionBroadcast ??
|
||||||
form.denyLineTableBroadcast ??
|
form.denyLineTableBroadcast ??
|
||||||
false
|
false
|
||||||
|
const webListen = form.webListen?.trim() || 'http://0.0.0.0:4665'
|
||||||
|
let webPort = 4665
|
||||||
|
try {
|
||||||
|
const parsedPort = new URL(webListen).port
|
||||||
|
if (parsedPort) webPort = parseInt(parsedPort, 10)
|
||||||
|
} catch {
|
||||||
|
// Java backend validates the canonical listen address.
|
||||||
|
}
|
||||||
|
|
||||||
const updatedConfig: Record<string, unknown> = {
|
const updatedConfig: Record<string, unknown> = {
|
||||||
...form,
|
...form,
|
||||||
|
webListen,
|
||||||
|
webPort,
|
||||||
externalEndpoints: updatedExternalEndpoints,
|
externalEndpoints: updatedExternalEndpoints,
|
||||||
openConnections: updatedExternalEndpoints,
|
openConnections: updatedExternalEndpoints,
|
||||||
autoConnections: updatedAutoConnections,
|
autoConnections: updatedAutoConnections,
|
||||||
@@ -485,23 +498,21 @@ function SettingsForm({
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<Field>
|
<Field>
|
||||||
<FieldLabel htmlFor="webPort">Web 控制台端口</FieldLabel>
|
<FieldLabel htmlFor="webListen">Web API 监听地址</FieldLabel>
|
||||||
<Input
|
<Input
|
||||||
id="webPort"
|
id="webListen"
|
||||||
type="number"
|
type="text"
|
||||||
min={1}
|
placeholder="http://0.0.0.0:4665"
|
||||||
max={65535}
|
value={form.webListen ?? 'http://0.0.0.0:4665'}
|
||||||
placeholder="4665"
|
|
||||||
value={form.webPort ?? 4665}
|
|
||||||
onChange={(e) =>
|
onChange={(e) =>
|
||||||
setForm((prev) => ({
|
setForm((prev) => ({
|
||||||
...prev,
|
...prev,
|
||||||
webPort: parseInt(e.target.value) || 4665,
|
webListen: e.target.value,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<FieldDescription>
|
<FieldDescription>
|
||||||
Web API 与前端仪表盘托管监听端口(默认 4665)
|
Web API 与前端仪表盘托管监听地址(默认 http://0.0.0.0:4665)
|
||||||
</FieldDescription>
|
</FieldDescription>
|
||||||
</Field>
|
</Field>
|
||||||
|
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ export interface KLALBControllerConfig {
|
|||||||
enableTUN?: boolean
|
enableTUN?: boolean
|
||||||
TUNName?: string | null
|
TUNName?: string | null
|
||||||
webUI?: boolean
|
webUI?: boolean
|
||||||
|
webListen?: string
|
||||||
webPort?: number
|
webPort?: number
|
||||||
nogui?: boolean
|
nogui?: boolean
|
||||||
TCPListen?: string
|
TCPListen?: string
|
||||||
|
|||||||
Reference in New Issue
Block a user