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
112 lines
3.4 KiB
Makefile
112 lines
3.4 KiB
Makefile
# Makefile for SimpleRemoter Go Server
|
|
# Compatible with GnuWin32 make on Windows cmd
|
|
|
|
# Binary name
|
|
BINARY_NAME=server
|
|
|
|
# Build directory
|
|
BUILD_DIR=build
|
|
|
|
# Main package path
|
|
MAIN_PACKAGE=./cmd
|
|
|
|
# Version metadata injected at link time (see buildinfo package). Both are
|
|
# empty outside a git checkout; the server then reports no version rather than
|
|
# a fabricated one.
|
|
VERSION := $(shell git describe --tags --always --dirty 2>nul)
|
|
COMMIT := $(shell git rev-parse --short HEAD 2>nul)
|
|
BUILDINFO_PKG = github.com/yuanyuanxiang/SimpleRemoter/server/go/buildinfo
|
|
|
|
# Go build flags (strip debug info for smaller binary; version always injected)
|
|
LDFLAGS=-ldflags "-s -w -X $(BUILDINFO_PKG).Version=$(VERSION) -X $(BUILDINFO_PKG).Commit=$(COMMIT)"
|
|
|
|
# Windows commands
|
|
MKDIR=if not exist $(BUILD_DIR) mkdir $(BUILD_DIR)
|
|
RMDIR=if exist $(BUILD_DIR) rmdir /s /q $(BUILD_DIR)
|
|
|
|
.PHONY: all clean windows linux build help windows-386 linux-arm64 all-platforms test fmt deps sync
|
|
|
|
# Default target
|
|
all: clean windows linux
|
|
|
|
# Sync web assets from server/web/ into web/assets/ for //go:embed.
|
|
# Single source of truth is server/web/index.html; this just keeps a vendored copy.
|
|
sync:
|
|
@echo Syncing web assets from ../web/...
|
|
@if not exist web\assets mkdir web\assets
|
|
@copy /Y ..\web\index.html web\assets\index.html >nul
|
|
@echo Done
|
|
|
|
# Build for current platform
|
|
build: sync
|
|
@echo Building for current platform...
|
|
@$(MKDIR)
|
|
go build $(LDFLAGS) -o $(BUILD_DIR)\$(BINARY_NAME).exe $(MAIN_PACKAGE)
|
|
@echo Done
|
|
|
|
# Build for Windows (amd64)
|
|
windows: sync
|
|
@echo Building for Windows amd64...
|
|
@$(MKDIR)
|
|
set GOOS=windows&& set GOARCH=amd64&& go build $(LDFLAGS) -o $(BUILD_DIR)\$(BINARY_NAME)_windows_amd64.exe $(MAIN_PACKAGE)
|
|
@echo Done: $(BUILD_DIR)\$(BINARY_NAME)_windows_amd64.exe
|
|
|
|
# Build for Windows (386)
|
|
windows-386: sync
|
|
@echo Building for Windows 386...
|
|
@$(MKDIR)
|
|
set GOOS=windows&& set GOARCH=386&& go build $(LDFLAGS) -o $(BUILD_DIR)\$(BINARY_NAME)_windows_386.exe $(MAIN_PACKAGE)
|
|
@echo Done: $(BUILD_DIR)\$(BINARY_NAME)_windows_386.exe
|
|
|
|
# Build for Linux (amd64)
|
|
linux: sync
|
|
@echo Building for Linux amd64...
|
|
@$(MKDIR)
|
|
set GOOS=linux&& set GOARCH=amd64&& go build $(LDFLAGS) -o $(BUILD_DIR)\$(BINARY_NAME)_linux_amd64 $(MAIN_PACKAGE)
|
|
@echo Done: $(BUILD_DIR)\$(BINARY_NAME)_linux_amd64
|
|
|
|
# Build for Linux (arm64)
|
|
linux-arm64: sync
|
|
@echo Building for Linux arm64...
|
|
@$(MKDIR)
|
|
set GOOS=linux&& set GOARCH=arm64&& go build $(LDFLAGS) -o $(BUILD_DIR)\$(BINARY_NAME)_linux_arm64 $(MAIN_PACKAGE)
|
|
@echo Done: $(BUILD_DIR)\$(BINARY_NAME)_linux_arm64
|
|
|
|
# Build all platforms
|
|
all-platforms: windows windows-386 linux linux-arm64
|
|
|
|
# Clean build artifacts
|
|
clean:
|
|
@echo Cleaning...
|
|
@$(RMDIR)
|
|
@echo Done
|
|
|
|
# Run tests
|
|
test:
|
|
go test -v ./...
|
|
|
|
# Format code
|
|
fmt:
|
|
go fmt ./...
|
|
|
|
# Download dependencies
|
|
deps:
|
|
go mod download
|
|
go mod tidy
|
|
|
|
# Show help
|
|
help:
|
|
@echo Available targets:
|
|
@echo all - Build for Windows and Linux amd64
|
|
@echo build - Build for current platform
|
|
@echo windows - Build for Windows amd64
|
|
@echo windows-386 - Build for Windows 386
|
|
@echo linux - Build for Linux amd64
|
|
@echo linux-arm64 - Build for Linux arm64
|
|
@echo all-platforms - Build for all platforms
|
|
@echo sync - Sync web assets from ../web/ for //go:embed
|
|
@echo clean - Clean build directory
|
|
@echo test - Run tests
|
|
@echo fmt - Format code
|
|
@echo deps - Download dependencies
|