mirror of
https://github.com/Sagit-chu/flvx.git
synced 2026-10-03 09:06:36 +08:00
修复出口协议无法选择,加入自定义转发端口,增加arm支持
This commit is contained in:
@@ -4,7 +4,7 @@ export type SiteConfig = typeof siteConfig;
|
||||
|
||||
// 缓存相关常量
|
||||
const CACHE_PREFIX = 'vite_config_';
|
||||
const VERSION = "2.0.1-beta";
|
||||
const VERSION = "2.0.2-beta";
|
||||
const APP_VERSION = "1.0.3";
|
||||
|
||||
const getInitialConfig = () => {
|
||||
|
||||
@@ -406,6 +406,14 @@ export default function ForwardPage() {
|
||||
newErrors.tunnelId = '请选择关联隧道';
|
||||
}
|
||||
|
||||
// 验证入口端口(可选,如果填写则验证)
|
||||
if (form.inPort !== null && form.inPort !== undefined) {
|
||||
const port = Number(form.inPort);
|
||||
if (isNaN(port) || port < 1 || port > 65535) {
|
||||
newErrors.inPort = '端口必须在 1-65535 之间';
|
||||
}
|
||||
}
|
||||
|
||||
if (!form.remoteAddr.trim()) {
|
||||
newErrors.remoteAddr = '请输入远程地址';
|
||||
} else {
|
||||
@@ -526,6 +534,7 @@ export default function ForwardPage() {
|
||||
userId: form.userId,
|
||||
name: form.name,
|
||||
tunnelId: form.tunnelId,
|
||||
inPort: form.inPort,
|
||||
remoteAddr: processedRemoteAddr,
|
||||
strategy: addressCount > 1 ? form.strategy : 'fifo'
|
||||
};
|
||||
@@ -535,6 +544,7 @@ export default function ForwardPage() {
|
||||
const createData = {
|
||||
name: form.name,
|
||||
tunnelId: form.tunnelId,
|
||||
inPort: form.inPort,
|
||||
remoteAddr: processedRemoteAddr,
|
||||
strategy: addressCount > 1 ? form.strategy : 'fifo'
|
||||
};
|
||||
@@ -1605,6 +1615,24 @@ export default function ForwardPage() {
|
||||
</SelectItem>
|
||||
))}
|
||||
</Select>
|
||||
|
||||
<Input
|
||||
label="入口端口"
|
||||
placeholder="留空则自动分配可用端口"
|
||||
type="number"
|
||||
value={form.inPort !== null ? form.inPort.toString() : ''}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value;
|
||||
setForm(prev => ({
|
||||
...prev,
|
||||
inPort: value ? parseInt(value) : null
|
||||
}));
|
||||
}}
|
||||
isInvalid={!!errors.inPort}
|
||||
errorMessage={errors.inPort}
|
||||
variant="bordered"
|
||||
description="指定入口端口,留空则从节点可用端口中自动分配"
|
||||
/>
|
||||
|
||||
<Textarea
|
||||
label="远程地址"
|
||||
|
||||
@@ -357,6 +357,9 @@ export default function TunnelPage() {
|
||||
.map(group => group.filter(node => node.nodeId !== -1))
|
||||
.filter(group => group.length > 0); // 移除空组
|
||||
|
||||
// 过滤掉出口节点中的占位节点
|
||||
const cleanedOutNodeId = (form.outNodeId || []).filter(node => node.nodeId !== -1);
|
||||
|
||||
// 将换行符分隔的IP转换为逗号分隔
|
||||
const inIpString = form.inIp
|
||||
.split('\n')
|
||||
@@ -367,6 +370,7 @@ export default function TunnelPage() {
|
||||
const data = {
|
||||
...form,
|
||||
inIp: inIpString,
|
||||
outNodeId: cleanedOutNodeId,
|
||||
chainNodes: cleanedChainNodes
|
||||
};
|
||||
|
||||
@@ -1052,7 +1056,7 @@ export default function TunnelPage() {
|
||||
label="节点"
|
||||
placeholder="请选择出口节点(可多选)"
|
||||
selectionMode="multiple"
|
||||
selectedKeys={form.outNodeId ? form.outNodeId.map(ct => ct.nodeId.toString()) : []}
|
||||
selectedKeys={form.outNodeId ? form.outNodeId.filter(ct => ct.nodeId !== -1).map(ct => ct.nodeId.toString()) : []}
|
||||
disabledKeys={[
|
||||
...nodes.filter(node => node.status !== 1).map(node => node.id.toString()),
|
||||
...form.inNodeId.map(ct => ct.nodeId.toString()),
|
||||
@@ -1061,12 +1065,17 @@ export default function TunnelPage() {
|
||||
onSelectionChange={(keys) => {
|
||||
const selectedIds = Array.from(keys).map(key => parseInt(key as string));
|
||||
const currentOutNodes = form.outNodeId || [];
|
||||
const protocol = currentOutNodes.length > 0 ? currentOutNodes[0].protocol || 'tls' : 'tls';
|
||||
const strategy = currentOutNodes.length > 0 ? currentOutNodes[0].strategy || 'round' : 'round';
|
||||
|
||||
let protocol = 'tls';
|
||||
let strategy = 'round';
|
||||
if (currentOutNodes.length > 0) {
|
||||
protocol = currentOutNodes[0].protocol || 'tls';
|
||||
strategy = currentOutNodes[0].strategy || 'round';
|
||||
}
|
||||
|
||||
const realNodes = currentOutNodes.filter(ct => ct.nodeId !== -1);
|
||||
const newOutNodeId: ChainTunnel[] = selectedIds.map(nodeId => {
|
||||
// 保留已有的配置或使用默认值
|
||||
const existing = currentOutNodes.find(ct => ct.nodeId === nodeId);
|
||||
const existing = realNodes.find(ct => ct.nodeId === nodeId);
|
||||
return existing || { nodeId, chainType: 3, protocol, strategy };
|
||||
});
|
||||
setForm(prev => ({ ...prev, outNodeId: newOutNodeId }));
|
||||
@@ -1116,14 +1125,30 @@ export default function TunnelPage() {
|
||||
<Select
|
||||
label="协议"
|
||||
placeholder="选择协议"
|
||||
selectedKeys={[form.outNodeId && form.outNodeId.length > 0 ? form.outNodeId[0].protocol || 'tls' : 'tls']}
|
||||
selectedKeys={[(() => {
|
||||
if (!form.outNodeId || form.outNodeId.length === 0) return 'tls';
|
||||
return form.outNodeId[0].protocol || 'tls';
|
||||
})()]}
|
||||
onSelectionChange={(keys) => {
|
||||
const selectedKey = Array.from(keys)[0] as string;
|
||||
if (selectedKey && form.outNodeId) {
|
||||
setForm(prev => ({
|
||||
...prev,
|
||||
outNodeId: (prev.outNodeId || []).map(ct => ({ ...ct, protocol: selectedKey }))
|
||||
}));
|
||||
if (selectedKey) {
|
||||
setForm(prev => {
|
||||
const currentOutNodes = prev.outNodeId || [];
|
||||
const currentStrategy = currentOutNodes.length > 0 ? currentOutNodes[0].strategy || 'round' : 'round';
|
||||
|
||||
if (currentOutNodes.length === 0) {
|
||||
// 如果还没有出口节点,创建一个占位节点保存设置
|
||||
return {
|
||||
...prev,
|
||||
outNodeId: [{ nodeId: -1, chainType: 3, protocol: selectedKey, strategy: currentStrategy }]
|
||||
};
|
||||
}
|
||||
// 更新所有出口节点的协议
|
||||
return {
|
||||
...prev,
|
||||
outNodeId: currentOutNodes.map(ct => ({ ...ct, protocol: selectedKey }))
|
||||
};
|
||||
});
|
||||
}
|
||||
}}
|
||||
isInvalid={!!errors.protocol}
|
||||
@@ -1147,14 +1172,28 @@ export default function TunnelPage() {
|
||||
<Select
|
||||
label="负载策略"
|
||||
placeholder="选择策略"
|
||||
selectedKeys={[form.outNodeId && form.outNodeId.length > 0 ? form.outNodeId[0].strategy || 'round' : 'round']}
|
||||
selectedKeys={[(() => {
|
||||
if (!form.outNodeId || form.outNodeId.length === 0) return 'round';
|
||||
return form.outNodeId[0].strategy || 'round';
|
||||
})()]}
|
||||
onSelectionChange={(keys) => {
|
||||
const selectedKey = Array.from(keys)[0] as string;
|
||||
if (selectedKey && form.outNodeId) {
|
||||
setForm(prev => ({
|
||||
...prev,
|
||||
outNodeId: (prev.outNodeId || []).map(ct => ({ ...ct, strategy: selectedKey }))
|
||||
}));
|
||||
if (selectedKey) {
|
||||
setForm(prev => {
|
||||
const currentOutNodes = prev.outNodeId || [];
|
||||
const currentProtocol = currentOutNodes.length > 0 ? currentOutNodes[0].protocol || 'tls' : 'tls';
|
||||
|
||||
if (currentOutNodes.length === 0) {
|
||||
return {
|
||||
...prev,
|
||||
outNodeId: [{ nodeId: -1, chainType: 3, protocol: currentProtocol, strategy: selectedKey }]
|
||||
};
|
||||
}
|
||||
return {
|
||||
...prev,
|
||||
outNodeId: currentOutNodes.map(ct => ({ ...ct, strategy: selectedKey }))
|
||||
};
|
||||
});
|
||||
}
|
||||
}}
|
||||
variant="bordered"
|
||||
|
||||
Reference in New Issue
Block a user