feat(settings): adopt externalEndpoints/denyExternalEndpoint* keys
- read externalEndpoints first, fall back to openConnections/LineTable - deny toggles mirror new canonical keys plus legacy aliases on save so both updated and legacy backends keep working
This commit is contained in:
+39
-13
@@ -96,11 +96,13 @@ interface ConnectionItem {
|
||||
function parseConnectionsFromConfig(config: KLALBControllerConfig | null): ConnectionItem[] {
|
||||
if (!config) return []
|
||||
const lineTable = (
|
||||
Array.isArray(config.openConnections)
|
||||
? config.openConnections
|
||||
: Array.isArray(config.LineTable)
|
||||
? config.LineTable
|
||||
: []
|
||||
Array.isArray(config.externalEndpoints)
|
||||
? config.externalEndpoints
|
||||
: Array.isArray(config.openConnections)
|
||||
? config.openConnections
|
||||
: Array.isArray(config.LineTable)
|
||||
? config.LineTable
|
||||
: []
|
||||
).map(toAddrString)
|
||||
const connectTable = (
|
||||
Array.isArray(config.autoConnections)
|
||||
@@ -191,19 +193,29 @@ function SettingsForm({
|
||||
e.preventDefault()
|
||||
|
||||
const cleanConnections = connections.filter((c) => c.address.trim() !== '')
|
||||
// 互斥分离:选中自动连接的进 autoConnections,未选中的进 openConnections
|
||||
const updatedOpenConnections = cleanConnections
|
||||
// 互斥分离:选中自动连接的进 autoConnections,未选中的进 externalEndpoints
|
||||
const updatedExternalEndpoints = cleanConnections
|
||||
.filter((c) => !c.autoConnect)
|
||||
.map((c) => c.address.trim())
|
||||
const updatedAutoConnections = cleanConnections
|
||||
.filter((c) => c.autoConnect)
|
||||
.map((c) => c.address.trim())
|
||||
|
||||
// 保存时同时携带新键名与历史别名,兼容新旧后端
|
||||
const denyQuery =
|
||||
form.denyExternalEndpointQuery ?? form.denyConnectionQuery ?? form.denyLineTableQuery ?? false
|
||||
const denyBroadcast =
|
||||
form.denyExternalEndpointBroadcast ??
|
||||
form.denyConnectionBroadcast ??
|
||||
form.denyLineTableBroadcast ??
|
||||
false
|
||||
|
||||
const updatedConfig: Record<string, unknown> = {
|
||||
...form,
|
||||
openConnections: updatedOpenConnections,
|
||||
externalEndpoints: updatedExternalEndpoints,
|
||||
openConnections: updatedExternalEndpoints,
|
||||
autoConnections: updatedAutoConnections,
|
||||
LineTable: updatedOpenConnections,
|
||||
LineTable: updatedExternalEndpoints,
|
||||
ConnectLineTable: updatedAutoConnections,
|
||||
ntpServers: ntpServers.filter((s) => s.trim() !== ''),
|
||||
ntpServerTable: ntpServers.filter((s) => s.trim() !== ''),
|
||||
@@ -212,8 +224,10 @@ function SettingsForm({
|
||||
NetworkInterfaceExcepts: interfaceExcepts.filter((s) => s.trim() !== ''),
|
||||
enableTUN: tunEnabled,
|
||||
TUNName: form.TUNName?.trim() || 'KLALB_SRv6',
|
||||
denyConnectionQuery: form.denyConnectionQuery ?? form.denyLineTableQuery ?? false,
|
||||
denyConnectionBroadcast: form.denyConnectionBroadcast ?? form.denyLineTableBroadcast ?? false,
|
||||
denyExternalEndpointQuery: denyQuery,
|
||||
denyExternalEndpointBroadcast: denyBroadcast,
|
||||
denyConnectionQuery: denyQuery,
|
||||
denyConnectionBroadcast: denyBroadcast,
|
||||
Type: 'KLALBController',
|
||||
}
|
||||
|
||||
@@ -981,10 +995,16 @@ function SettingsForm({
|
||||
</FieldContent>
|
||||
<Switch
|
||||
id="switch-deny-query"
|
||||
checked={form.denyConnectionQuery ?? form.denyLineTableQuery ?? false}
|
||||
checked={
|
||||
form.denyExternalEndpointQuery ??
|
||||
form.denyConnectionQuery ??
|
||||
form.denyLineTableQuery ??
|
||||
false
|
||||
}
|
||||
onCheckedChange={(checked) =>
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
denyExternalEndpointQuery: checked,
|
||||
denyConnectionQuery: checked,
|
||||
denyLineTableQuery: checked,
|
||||
}))
|
||||
@@ -1004,10 +1024,16 @@ function SettingsForm({
|
||||
</FieldContent>
|
||||
<Switch
|
||||
id="switch-deny-broadcast"
|
||||
checked={form.denyConnectionBroadcast ?? form.denyLineTableBroadcast ?? false}
|
||||
checked={
|
||||
form.denyExternalEndpointBroadcast ??
|
||||
form.denyConnectionBroadcast ??
|
||||
form.denyLineTableBroadcast ??
|
||||
false
|
||||
}
|
||||
onCheckedChange={(checked) =>
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
denyExternalEndpointBroadcast: checked,
|
||||
denyConnectionBroadcast: checked,
|
||||
denyLineTableBroadcast: checked,
|
||||
}))
|
||||
|
||||
@@ -114,6 +114,7 @@ export interface KLALBControllerConfig {
|
||||
TCPListen?: string
|
||||
UDPListen?: string
|
||||
VirtualSocketName?: string
|
||||
externalEndpoints?: string[]
|
||||
openConnections?: string[]
|
||||
autoConnections?: string[]
|
||||
ntpServers?: string[]
|
||||
@@ -123,6 +124,8 @@ export interface KLALBControllerConfig {
|
||||
DNS?: string[]
|
||||
ExtraRoutes?: string[]
|
||||
NetworkInterfaceExcepts?: string[]
|
||||
denyExternalEndpointQuery?: boolean
|
||||
denyExternalEndpointBroadcast?: boolean
|
||||
denyConnectionQuery?: boolean
|
||||
denyConnectionBroadcast?: boolean
|
||||
denyLineTableQuery?: boolean
|
||||
|
||||
Reference in New Issue
Block a user