windows probe-only agent + agent version display unification + reality sni from sing-box fragment
Scope B (Windows agent): - probe.go split into shared core + probe_linux.go (verbatim Linux sampler, build-tagged) + probe_windows.go (Win32 sampler: GetSystemTimes CPU diff, GlobalMemoryStatusEx, fixed-drive df totals, GetIfTable2 counted set, MachineGuid boot identity, registry facts; load and TCP/UDP counts stay zero - x/sys v0.47.0 exports no wrapper) - update intents are acknowledged and skipped on Windows (the release assets are Linux binaries; Windows nodes update via install-agent.ps1) - cmd/xui-agent-windows: SCM service host (svc.Run + mgr install/ uninstall/start/stop) mirroring main.go's agent lifecycle wiring - install-agent.ps1: downloads the exe, writes probeOnly agent.json, registers and starts the service, rerun-safe Scope C (version display): - config.GetAgentDisplayVersion (and the master getter) compose from the bare number so a V-form injection no longer doubles the letter (AV2.1.0 -> A2.1.0) - node list view repairs stored AV-prefixed reports at assembly so deployed agents read uniformly without an update Scope D (production fix): - share-link reality sni: when the inbound has a sing-box fragment, sni is the fragment's tls.server_name - the only name the sing-box REALITY server serves. The previous rule picked a uniformly random serverNames entry per generation, which xray tolerated but sing-box refuses as an invalid connection. sid keeps its random pick: the converter carries the whole shortIds list into the fragment, so every listed sid is served.
This commit is contained in:
@@ -7,6 +7,28 @@ import (
|
||||
"github.com/mhsanaei/3x-ui/v3/internal/database/model"
|
||||
)
|
||||
|
||||
// The panel-version cell must read as the bare A-form across the
|
||||
// fleet: pre-fix agents report the doubled "AV2.1.0" and are repaired
|
||||
// at view assembly; legacy build versions keep their "agent " prefix.
|
||||
func TestAgentVersionCell(t *testing.T) {
|
||||
cases := map[string]string{
|
||||
"A2.1.0": "A2.1.0",
|
||||
"A1.0.0": "A1.0.0",
|
||||
"AV2.1.0": "A2.1.0",
|
||||
"AV2.0.1": "A2.0.1",
|
||||
"agent AV2.0.3": "A2.0.3",
|
||||
"3.7.0-agent.1": "agent 3.7.0-agent.1",
|
||||
"agent A2.1.0": "A2.1.0",
|
||||
" A2.1.0 ": "A2.1.0",
|
||||
"some-dev-build": "agent some-dev-build",
|
||||
}
|
||||
for in, want := range cases {
|
||||
if got := agentVersionCell(in); got != want {
|
||||
t.Errorf("agentVersionCell(%q) = %q, want %q", in, got, want)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// P13: annotateAgentTelemetry overlays the agent-reported heartbeat
|
||||
// telemetry onto agent node views only — panel version becomes
|
||||
// "agent <version>", xray version/uptime/latency/CPU/mem/IPs take the
|
||||
|
||||
@@ -190,6 +190,30 @@ func annotateNodeTypes(views []*NodeView) {
|
||||
}
|
||||
}
|
||||
|
||||
// agentVersionCell renders one agent's reported version for the
|
||||
// node list's panel-version cell, uniformly across the fleet:
|
||||
// - current agents report the A-series display version and are
|
||||
// shown bare ("A2.1.0");
|
||||
// - agents built while releases injected the V-form number report
|
||||
// the doubled "AV2.1.0" (see config.GetAgentDisplayVersion) and
|
||||
// are repaired to the bare A-form here, so those nodes read
|
||||
// correctly without waiting for their next agent update;
|
||||
// - pre-display-version agents report the internal build version
|
||||
// and keep the historical "agent " prefix.
|
||||
func agentVersionCell(reported string) string {
|
||||
s := strings.TrimSpace(reported)
|
||||
s = strings.TrimPrefix(s, "agent ")
|
||||
if len(s) > 2 && (s[0] == 'A' || s[0] == 'a') && (s[1] == 'V' || s[1] == 'v') {
|
||||
if _, ok := config.ParseDisplayVersion(s[1:]); ok {
|
||||
return "A" + s[2:]
|
||||
}
|
||||
}
|
||||
if _, ok := config.ParseDisplayVersion(s); ok && strings.HasPrefix(s, "A") {
|
||||
return s
|
||||
}
|
||||
return "agent " + s
|
||||
}
|
||||
|
||||
// annotateAgentTelemetry overlays the latest heartbeat telemetry reported
|
||||
// by each node's bound agent onto its view (P13): xray version, the
|
||||
// "agent <version>" panel-version label, host uptime, node->master latency,
|
||||
@@ -244,14 +268,7 @@ func annotateAgentTelemetry(views []*NodeView) {
|
||||
v.SingboxVersion = ag.SingboxVersion
|
||||
}
|
||||
if ag.AgentVersion != "" {
|
||||
// New agents report the A-series display version, shown
|
||||
// verbatim; older agents report the internal build version
|
||||
// and keep the historical "agent " prefix.
|
||||
if _, ok := config.ParseDisplayVersion(ag.AgentVersion); ok && strings.HasPrefix(ag.AgentVersion, "A") {
|
||||
v.PanelVersion = ag.AgentVersion
|
||||
} else {
|
||||
v.PanelVersion = "agent " + ag.AgentVersion
|
||||
}
|
||||
v.PanelVersion = agentVersionCell(ag.AgentVersion)
|
||||
v.AgentUpdateState = ag.UpdateState
|
||||
v.AgentUpdateError = ag.UpdateError
|
||||
v.AgentUpdateTarget = ag.UpdateTarget
|
||||
|
||||
Reference in New Issue
Block a user