feat: detect an agent's public IPv4 and IPv6 addresses automatically, manual values still win [CI]
ci/woodpecker/push/main-amd64-build Pipeline was successful
ci/woodpecker/push/main-amd64-build Pipeline was successful
This commit is contained in:
1 parent
9966ea5d63
commit
f03988d68b
26 files changed
+517
-33
No files matched your search
@@ -15,6 +15,8 @@ function EditDialog({ agent, onClose, onSaved }: { agent: AgentDto; onClose: ()
|
||||
const [labels, setLabels] = useState(agent.labels.join(', '))
|
||||
const [host, setHost] = useState(agent.public_host)
|
||||
const [ipv6Host, setIpv6Host] = useState(agent.ipv6_host ?? '')
|
||||
const [hostAuto, setHostAuto] = useState(agent.public_host_auto)
|
||||
const [ipv6Auto, setIpv6Auto] = useState(agent.ipv6_host_auto)
|
||||
const [visible, setVisible] = useState(agent.public_visible)
|
||||
return (
|
||||
<Dialog
|
||||
@@ -31,7 +33,15 @@ function EditDialog({ agent, onClose, onSaved }: { agent: AgentDto; onClose: ()
|
||||
disabled={busy}
|
||||
onClick={async () => {
|
||||
const ok = await run(
|
||||
() => api.patch(`/api/admin/agents/${agent.id}`, { name, labels: labels.split(',').map((x) => x.trim()).filter(Boolean), public_host: host.trim(), ipv6_host: ipv6Host.trim(), public_visible: visible }),
|
||||
() =>
|
||||
api.patch(`/api/admin/agents/${agent.id}`, {
|
||||
name,
|
||||
labels: labels.split(',').map((x) => x.trim()).filter(Boolean),
|
||||
// 自动识别的地址不提交:提交就会变成手动;从手动改回自动用 *_auto
|
||||
...(hostAuto ? (agent.public_host_auto ? {} : { public_host_auto: true }) : { public_host: host.trim() }),
|
||||
...(ipv6Auto ? (agent.ipv6_host_auto ? {} : { ipv6_host_auto: true }) : { ipv6_host: ipv6Host.trim() }),
|
||||
public_visible: visible,
|
||||
}),
|
||||
'已保存',
|
||||
)
|
||||
if (ok) {
|
||||
@@ -52,13 +62,21 @@ function EditDialog({ agent, onClose, onSaved }: { agent: AgentDto; onClose: ()
|
||||
</Field>
|
||||
</div>
|
||||
<div className="wide">
|
||||
<Field label="IPv4 地址" hint="Probe 用它测 IPv4:IPv4 地址或域名(A 记录)">
|
||||
<input className="input" value={host} onChange={(e) => setHost(e.target.value)} />
|
||||
<Field label="IPv4 地址" hint="Probe 用它测 IPv4:IPv4 地址或域名(A 记录)。默认由 Agent 上报自动识别">
|
||||
<input className="input" value={host} disabled={hostAuto} onChange={(e) => setHost(e.target.value)} />
|
||||
<label className="switch">
|
||||
<input type="checkbox" checked={hostAuto} onChange={(e) => setHostAuto(e.target.checked)} />
|
||||
自动识别
|
||||
</label>
|
||||
</Field>
|
||||
</div>
|
||||
<div className="wide">
|
||||
<Field label="IPv6 地址" hint="IPv6 地址或域名(AAAA 记录);留空只采集 IPv4">
|
||||
<input className="input" value={ipv6Host} onChange={(e) => setIpv6Host(e.target.value)} placeholder="例如 2001:db8::1 或 agent.example.com" />
|
||||
<Field label="IPv6 地址" hint="IPv6 地址或域名(AAAA 记录)。默认由 Agent 上报自动识别;手动时留空表示只采集 IPv4">
|
||||
<input className="input" value={ipv6Host} disabled={ipv6Auto} onChange={(e) => setIpv6Host(e.target.value)} placeholder="例如 2001:db8::1 或 agent.example.com" />
|
||||
<label className="switch">
|
||||
<input type="checkbox" checked={ipv6Auto} onChange={(e) => setIpv6Auto(e.target.checked)} />
|
||||
自动识别
|
||||
</label>
|
||||
</Field>
|
||||
</div>
|
||||
<div className="wide">
|
||||
@@ -217,9 +235,13 @@ export function AgentDetail() {
|
||||
<dt>ID</dt>
|
||||
<dd className="mono">{a.id}</dd>
|
||||
<dt>IPv4 地址</dt>
|
||||
<dd className="mono">{a.public_host || '—'}</dd>
|
||||
<dd className="mono">
|
||||
{a.public_host || '—'} <Chip>{a.public_host_auto ? '自动' : '手动'}</Chip>
|
||||
</dd>
|
||||
<dt>IPv6 地址</dt>
|
||||
<dd className="mono">{a.ipv6_host || '未配置'}</dd>
|
||||
<dd className="mono">
|
||||
{a.ipv6_host || (a.ipv6_host_auto ? '未识别到公网 IPv6 地址' : '已手动关闭')} <Chip>{a.ipv6_host_auto ? '自动' : '手动'}</Chip>
|
||||
</dd>
|
||||
<dt>IPv6 监听</dt>
|
||||
<dd>{a.ipv6_supported ? '已启用' : '未启用,请升级 Agent 并配置双栈监听'}</dd>
|
||||
<dt>IPv6 诊断</dt>
|
||||
|
||||
Reference in new issue
Block a user