Feature(Go): four local MCP read tools and a shared audit query package
Implement milestone M2 of the minimal MCP plan: the tools that answer from the server's own state instead of opening a device channel. - Extract the audit-log scanner from web into package auditquery so the admin page and get_audit_log share one implementation. The web handler keeps its 500-row cap, the MCP tool uses the protocol's 1000-row cap. Query gains json tags for the web snake_case wire format (device_id, warn_only) and reports TotalAll before filters. - Add package buildinfo and inject Version/Commit with -X from build.ps1 and the Makefile; go-winres refreshes Windows resources from the git tag when available. An unversioned build reports "", and only initialize substitutes "dev". - list_hosts: online/offline pools, include_offline merge, every documented filter, limit/offset paging with total/totalAll/hasMore, and schema-named host fields (authStatus/tls/remark are never fabricated). - get_host_detail: single id or a batch of up to 50, online lookup then the last history record, capabilities from protocol.SupportsCap plus the Windows/registry/virtual-desktop rules; v2 is not listed. - get_server_status: version, uptime, online/offline counts, port and bind. sessions stays absent until the MCP session table lands in M3. - get_audit_log: case-insensitive event substring, keyword, paging; hasMore turns false at the MaxOffset clamp so paging cannot loop. Wire hub, history, audit path and listen address through mcp.Config from cmd/main.go. Tests cover pools/filters/paging, capability bits, batch failures, audit paging and the unversioned build. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
3f1957a9c9
commit
774c0d2545
16 files changed
+1952
-449
No files matched your search
@@ -74,8 +74,28 @@ function Build-GoServer {
|
||||
} else {
|
||||
Join-Path $binDir "YamaGo_x64.exe"
|
||||
}
|
||||
|
||||
# Version/commit metadata injected into serverInfo and get_server_status.
|
||||
# Empty when git is unavailable (source tarball, IDE build) — the server
|
||||
# then reports no version rather than a fabricated one.
|
||||
$gitVersion = ""
|
||||
$gitCommit = ""
|
||||
if (Get-Command git -ErrorAction SilentlyContinue) {
|
||||
$gitVersion = (& git -C $rootDir describe --tags --always --dirty 2>$null | Select-Object -First 1)
|
||||
if ($LASTEXITCODE -ne 0 -or -not $gitVersion) { $gitVersion = "" } else { $gitVersion = "$gitVersion".Trim() }
|
||||
$gitCommit = (& git -C $rootDir rev-parse --short HEAD 2>$null | Select-Object -First 1)
|
||||
if ($LASTEXITCODE -ne 0 -or -not $gitCommit) { $gitCommit = "" } else { $gitCommit = "$gitCommit".Trim() }
|
||||
}
|
||||
$buildinfoPkg = "github.com/yuanyuanxiang/SimpleRemoter/server/go/buildinfo"
|
||||
$ldflagParts = @()
|
||||
# Release strips debug info for smaller binary; Debug keeps symbols.
|
||||
$ldflags = if ($Configuration -eq "Debug") { "" } else { "-s -w" }
|
||||
if ($Configuration -ne "Debug") { $ldflagParts += @("-s", "-w") }
|
||||
if ($gitVersion) { $ldflagParts += @("-X", "$buildinfoPkg.Version=$gitVersion") }
|
||||
if ($gitCommit) { $ldflagParts += @("-X", "$buildinfoPkg.Commit=$gitCommit") }
|
||||
$ldflags = $ldflagParts -join " "
|
||||
if ($gitVersion) {
|
||||
Write-Host "Version: $gitVersion ($gitCommit)" -ForegroundColor DarkGray
|
||||
}
|
||||
|
||||
# Save the caller's Go env so a direct .\build.ps1 invocation does not
|
||||
# leave GOOS=linux behind for later builds in the same shell.
|
||||
@@ -90,6 +110,21 @@ function Build-GoServer {
|
||||
# Cross-compiling for Linux requires a pure-Go build; the server has
|
||||
# no cgo dependencies, so this is the normal configuration.
|
||||
if ($TargetOS -eq "linux") { $env:CGO_ENABLED = "0" }
|
||||
# Refresh the Windows resources before linking: go-winres rewrites the
|
||||
# manifest identity, FileVersion and ProductVersion from the git tag so
|
||||
# Explorer's file properties match the tag while the runtime version
|
||||
# string stays the full `git describe` output. Missing go-winres or a
|
||||
# non-git tree keeps the checked-in .syso files unchanged.
|
||||
if ($TargetOS -eq "windows" -and $gitVersion) {
|
||||
if (Get-Command go-winres -ErrorAction SilentlyContinue) {
|
||||
& go-winres make --in cmd/winres/winres.json --out cmd/rsrc --product-version git-tag --file-version git-tag
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
Write-Host "WARNING: go-winres failed; keeping existing cmd/rsrc_*.syso" -ForegroundColor Yellow
|
||||
}
|
||||
} else {
|
||||
Write-Host "WARNING: go-winres not found; version resources not refreshed (go install github.com/tc-hib/go-winres@latest)" -ForegroundColor Yellow
|
||||
}
|
||||
}
|
||||
if ($ldflags) {
|
||||
& go build -ldflags $ldflags -o $outFile ./cmd
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user