diff --git a/src/App.tsx b/src/App.tsx index 7f0edd8..6132625 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -53,7 +53,7 @@ function getFirstAvailableId(ids: number[]) : number { } function generateNodeData(nodes : NodeData[]) : NodeData | null { - const hostId = getFirstAvailableId(nodes.map(n => n.hostId)) + const hostId = getFirstAvailableId(nodes.filter(n => n.groupId == 0).map(n => n.hostId)) if(hostId > 255) return null const privateKey = generateWireGuardPrivateKey(); diff --git a/src/components/NodeEditor.tsx b/src/components/NodeEditor.tsx index 494a3ca..16278e5 100644 --- a/src/components/NodeEditor.tsx +++ b/src/components/NodeEditor.tsx @@ -1,5 +1,6 @@ import { useState, ReactNode } from 'react'; import { NodeData, Settings } from '../types/graph'; +import { generateWireGuardPrivateKey } from '../utils/wireguardConfig' import './NodeEditor.css'; @@ -39,6 +40,10 @@ export default function NodeEditor({ // onClose(); }; + const handleGenerateKey = (): void => { + handleInputChange('privateKey', generateWireGuardPrivateKey()) + } + return (
@@ -70,12 +75,20 @@ export default function NodeEditor({
handleInputChange('privateKey', e.target.value)} readOnly /> - +
+
+
+ + handleInputChange('hostId', e.target.value)} + placeholder="将用作为虚拟地址的最后一位。同一子网下主机ID不能重复,不得超过255" + />