Skip to content

添加Windows服务管理和事件日志集成#5227

Open
donmor wants to merge 19 commits intofatedier:devfrom
donmor:patch-4
Open

添加Windows服务管理和事件日志集成#5227
donmor wants to merge 19 commits intofatedier:devfrom
donmor:patch-4

Conversation

@donmor
Copy link
Copy Markdown

@donmor donmor commented Mar 9, 2026

重新提交#5004

实现 #2468 ,可直接使用sc.exe(cmd)/New-Service(powershell)/注册表将frps或frpc注册为服务(可使用LocalService、服务账户等提高安全性)

已实现:

  • 加入golang.org/x/sys/windows/svc包,使frps和frpc符合Windows服务程序规范
  • 加入golang.org/x/sys/windows/svc/eventlog包,为Logger添加Windows事件日志后端(可使用Windows事件查看器查看)
  • 为frpc添加pause/continue支持(并同时reload代理配置)
  • 日志事件源存在检测和自动安装(使用powershell命令,自动添加需要UAC提权)
  • 服务安装/卸载命令(在启动参数前插入install以安装,非-c的参数和install命令间需插入--;使用uninstall命令以卸载;会同时注册/移除事件源;需在管理员cmd/powershell中执行;默认使用LocalSystem身份,restricted模式使用NT AUTHORITY\LocalService和受限SID)

@kilo-code-bot
Copy link
Copy Markdown

kilo-code-bot bot commented Mar 9, 2026

Code Review Summary

Status: 1 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
cmd/frpc/sub/install_windows.go 220 Service updates ignore the display name passed to system.Run, so installing the service under a custom wrapper name can no longer create matching Event Log sources and startup will fail. Fix these issues in Kilo Cloud
Other Observations (not in diff)

No additional issues found outside the diff.

Files Reviewed (7 files)
  • cmd/frpc/main.go - 0 issues
  • cmd/frpc/sub/install_windows.go - 1 issue
  • cmd/frpc/sub/root.go - 0 issues
  • cmd/frps/root.go - 0 issues
  • pkg/util/log/log.go - 0 issues
  • pkg/util/log/events/api_windows.go - 0 issues
  • pkg/util/system/system_windows.go - 0 issues

if err != nil {
return nil
}
if len(keyNames) == 1 && keyNames[0] == "Frp" {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: The cleanup condition can never be true, so the Frp event log key is never removed after uninstall. registry.OpenKey() opens ...\EventLog\Frp, so ReadSubKeyNames() returns child source names like the service name, not Frp itself. With the current len(keyNames) == 1 && keyNames[0] == "Frp" check, the parent key is leaked every time the last service source is deleted.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 4, 2026

PRs go stale after 14d of inactivity. Stale PRs rot after an additional 3d of inactivity and eventually close.

@donmor
Copy link
Copy Markdown
Author

donmor commented Apr 4, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant