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

Open
opened 2026-05-05 14:56:26 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/fatedier/frp/pull/5227
Author: @donmor
Created: 3/9/2026
Status: 🔄 Open

Base: devHead: patch-4


📝 Commits (10+)

  • 939f849 add basic supports to run as a windows service
  • 8a9a61a add support for changing parameters on service start
  • db9a3ca add support for windows eventlog
  • 46adf64 fix broken compilation on non-windows platforms
  • db1470c implements wait-for-startup and frpc pause/continue/reload
  • 0b31fdf fix broken isWinSvc()
  • f52035c fix broken dummy eventlog.go
  • 6521f5e fix broken dummy system.go and system_android.go
  • 7b30d9f fix broken dummy eventlog.go
  • ce4f961 now checks existence of event source using powershell;event source added automatically if run as privileged user

📊 Changes

19 files changed (+1061 additions, -16 deletions)

View changed files

📝 cmd/frpc/main.go (+1 -1)
cmd/frpc/sub/install_windows.go (+263 -0)
📝 cmd/frpc/sub/root.go (+21 -1)
cmd/frps/install_windows.go (+227 -0)
📝 cmd/frps/main.go (+1 -1)
📝 cmd/frps/root.go (+8 -0)
📝 go.mod (+1 -1)
📝 pkg/config/flags.go (+1 -1)
📝 pkg/config/v1/common.go (+4 -3)
pkg/config/v1/svc.go (+24 -0)
pkg/config/v1/svc_windows.go (+24 -0)
pkg/util/log/eventlog.go (+50 -0)
pkg/util/log/eventlog_windows.go (+111 -0)
pkg/util/log/events/api_windows.go (+117 -0)
pkg/util/log/events/events.go (+36 -0)
📝 pkg/util/log/log.go (+18 -7)
📝 pkg/util/system/system.go (+13 -1)
📝 pkg/util/system/system_android.go (+12 -0)
pkg/util/system/system_windows.go (+129 -0)

📄 Description

重新提交#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)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/fatedier/frp/pull/5227 **Author:** [@donmor](https://github.com/donmor) **Created:** 3/9/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `patch-4` --- ### 📝 Commits (10+) - [`939f849`](https://github.com/fatedier/frp/commit/939f84966da87c57d3787de663b0c544c1ca6fc7) add basic supports to run as a windows service - [`8a9a61a`](https://github.com/fatedier/frp/commit/8a9a61ae68694f0285942afaaf277cec33b4dd0d) add support for changing parameters on service start - [`db9a3ca`](https://github.com/fatedier/frp/commit/db9a3ca78fa56b1cb0448d41da2aef49899b68f8) add support for windows eventlog - [`46adf64`](https://github.com/fatedier/frp/commit/46adf64b22870a427d0e1099bf918ebc85986c81) fix broken compilation on non-windows platforms - [`db1470c`](https://github.com/fatedier/frp/commit/db1470c0295b0bc430923358ff86d0cd30d4bec1) implements wait-for-startup and frpc pause/continue/reload - [`0b31fdf`](https://github.com/fatedier/frp/commit/0b31fdf72c496c07acea1c9a8d335a7e22f5e502) fix broken isWinSvc() - [`f52035c`](https://github.com/fatedier/frp/commit/f52035cecf93088c827b6b513b45f1eb26d11e59) fix broken dummy eventlog.go - [`6521f5e`](https://github.com/fatedier/frp/commit/6521f5e50510c36a20da42336d108d5b0e5bc188) fix broken dummy system.go and system_android.go - [`7b30d9f`](https://github.com/fatedier/frp/commit/7b30d9f884bca564e564148184f77a47c1896697) fix broken dummy eventlog.go - [`ce4f961`](https://github.com/fatedier/frp/commit/ce4f9612ae85a9b9ad87fec6236ec2beb30a0edd) now checks existence of event source using powershell;event source added automatically if run as privileged user ### 📊 Changes **19 files changed** (+1061 additions, -16 deletions) <details> <summary>View changed files</summary> 📝 `cmd/frpc/main.go` (+1 -1) ➕ `cmd/frpc/sub/install_windows.go` (+263 -0) 📝 `cmd/frpc/sub/root.go` (+21 -1) ➕ `cmd/frps/install_windows.go` (+227 -0) 📝 `cmd/frps/main.go` (+1 -1) 📝 `cmd/frps/root.go` (+8 -0) 📝 `go.mod` (+1 -1) 📝 `pkg/config/flags.go` (+1 -1) 📝 `pkg/config/v1/common.go` (+4 -3) ➕ `pkg/config/v1/svc.go` (+24 -0) ➕ `pkg/config/v1/svc_windows.go` (+24 -0) ➕ `pkg/util/log/eventlog.go` (+50 -0) ➕ `pkg/util/log/eventlog_windows.go` (+111 -0) ➕ `pkg/util/log/events/api_windows.go` (+117 -0) ➕ `pkg/util/log/events/events.go` (+36 -0) 📝 `pkg/util/log/log.go` (+18 -7) 📝 `pkg/util/system/system.go` (+13 -1) 📝 `pkg/util/system/system_android.go` (+12 -0) ➕ `pkg/util/system/system_windows.go` (+129 -0) </details> ### 📄 Description 重新提交#5004 实现 #2468 ,可直接使用`sc.exe`(cmd)/`New-Service`(powershell)/注册表将frps或frpc注册为服务(可使用LocalService、服务账户等提高安全性) 已实现: - [x] 加入`golang.org/x/sys/windows/svc`包,使frps和frpc符合Windows服务程序规范 - [x] 加入`golang.org/x/sys/windows/svc/eventlog`包,为Logger添加Windows事件日志后端(可使用Windows事件查看器查看) - [x] 为frpc添加pause/continue支持(并同时reload代理配置) - [x] 日志事件源存在检测和自动安装(使用powershell命令,自动添加需要UAC提权) - [x] 服务安装/卸载命令(在启动参数前插入install以安装,非`-c`的参数和install命令间需插入`--`;使用uninstall命令以卸载;会同时注册/移除事件源;需在管理员cmd/powershell中执行;默认使用LocalSystem身份,restricted模式使用`NT AUTHORITY\LocalService`和受限SID) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror added the
pull-request
label 2026-05-05 14:56:26 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/frp#5191
No description provided.