Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
181150b7a1 | ||
|
|
8619afe531 | ||
|
|
9c2a57b576 | ||
|
|
d9eb9acd9b | ||
|
|
5cdb1a3980 |
@@ -0,0 +1,11 @@
|
|||||||
|
# common
|
||||||
|
|
||||||
|
通用小工具(自 remote-backend-server internal/libs/common 裁剪)。
|
||||||
|
|
||||||
|
## 用法
|
||||||
|
|
||||||
|
```go
|
||||||
|
import "git.zeroonesoft.cn/golib/remote-core/common"
|
||||||
|
|
||||||
|
exists, err := common.PathExists("C:\\data") // 文件/目录是否存在
|
||||||
|
```
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# file
|
||||||
|
|
||||||
|
被控端文件管理 HTTP 能力(自 remote-backend-server internal/handlers/file 移植,
|
||||||
|
去 DB 依赖):目录浏览、改名、删除、上传、下载(断点支持)、目录创建。
|
||||||
|
|
||||||
|
## 路由
|
||||||
|
|
||||||
|
```go
|
||||||
|
import "git.zeroonesoft.cn/golib/remote-core/file"
|
||||||
|
|
||||||
|
file.RegisterRoutersGatewayFile(r *gin.RouterGroup)
|
||||||
|
```
|
||||||
|
|
||||||
|
| 方法 | 路径 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| GET/POST | `/file/list` | 目录列表(POST 收 JSON `{path}`,避免路径含 `#` 等字符被 query 截断) |
|
||||||
|
| PUT | `/file/name` | 重命名 |
|
||||||
|
| DELETE | `/file` | 删除文件/目录 |
|
||||||
|
| GET/HEAD | `/file/download` | 下载(HEAD 取大小,GET 支持 Range 续传) |
|
||||||
|
| POST | `/file/upload` | 上传 |
|
||||||
|
| POST | `/file/dir` | 创建目录 |
|
||||||
|
|
||||||
|
## 注意
|
||||||
|
|
||||||
|
- 与 shell/process 同为被控 HTTP 能力,经 zonat 隧道 + web-gateway 反代出网。
|
||||||
|
- 路径参数来自控制端,接入公网前务必在网关侧做鉴权与路径白名单校验。
|
||||||
@@ -1,52 +1,61 @@
|
|||||||
module git.zeroonesoft.cn/golib/remote-core
|
module git.zeroonesoft.cn/golib/remote-core
|
||||||
|
|
||||||
go 1.24.0
|
go 1.26.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gin-gonic/gin v1.10.0
|
github.com/KarpelesLab/vncpasswd v1.0.1
|
||||||
|
github.com/gin-gonic/gin v1.12.0
|
||||||
github.com/gorilla/websocket v1.5.3
|
github.com/gorilla/websocket v1.5.3
|
||||||
github.com/jaypipes/ghw v0.13.0
|
github.com/jaypipes/ghw v0.13.0
|
||||||
|
github.com/kardianos/service v1.2.2
|
||||||
github.com/runletapp/go-console v0.0.0-20211204140000-27323a28410a
|
github.com/runletapp/go-console v0.0.0-20211204140000-27323a28410a
|
||||||
github.com/shirou/gopsutil/v3 v3.24.5
|
github.com/shirou/gopsutil/v3 v3.24.5
|
||||||
github.com/sirupsen/logrus v1.9.3
|
github.com/sirupsen/logrus v1.10.2
|
||||||
github.com/yusufpapurcu/wmi v1.2.4
|
github.com/yusufpapurcu/wmi v1.2.4
|
||||||
|
golang.org/x/sys v0.48.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/StackExchange/wmi v1.2.1 // indirect
|
github.com/StackExchange/wmi v1.2.1 // indirect
|
||||||
github.com/bytedance/sonic v1.11.6 // indirect
|
github.com/bytedance/gopkg v0.1.3 // indirect
|
||||||
github.com/bytedance/sonic/loader v0.1.1 // indirect
|
github.com/bytedance/sonic v1.15.0 // indirect
|
||||||
github.com/cloudwego/base64x v0.1.4 // indirect
|
github.com/bytedance/sonic/loader v0.5.0 // indirect
|
||||||
github.com/cloudwego/iasm v0.2.0 // indirect
|
github.com/cloudwego/base64x v0.1.6 // indirect
|
||||||
github.com/creack/pty v1.1.17 // indirect
|
github.com/creack/pty v1.1.17 // indirect
|
||||||
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
github.com/gabriel-vasile/mimetype v1.4.15 // indirect
|
||||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
github.com/gin-contrib/sse v1.1.0 // indirect
|
||||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||||
github.com/go-playground/locales v0.14.1 // indirect
|
github.com/go-playground/locales v0.14.1 // indirect
|
||||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||||
github.com/go-playground/validator/v10 v10.20.0 // indirect
|
github.com/go-playground/validator/v10 v10.30.4 // indirect
|
||||||
github.com/goccy/go-json v0.10.2 // indirect
|
github.com/goccy/go-json v0.10.5 // indirect
|
||||||
|
github.com/goccy/go-yaml v1.19.2 // indirect
|
||||||
github.com/iamacarpet/go-winpty v1.0.2 // indirect
|
github.com/iamacarpet/go-winpty v1.0.2 // indirect
|
||||||
github.com/jaypipes/pcidb v1.0.1 // indirect
|
github.com/jaypipes/pcidb v1.0.1 // indirect
|
||||||
github.com/json-iterator/go v1.1.12 // indirect
|
github.com/json-iterator/go v1.1.12 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
|
github.com/klauspost/cpuid/v2 v2.3.0 // indirect
|
||||||
github.com/kr/text v0.2.0 // indirect
|
github.com/leodido/go-urn v1.5.0 // indirect
|
||||||
github.com/leodido/go-urn v1.4.0 // indirect
|
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
github.com/pelletier/go-toml/v2 v2.2.4 // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
|
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
|
||||||
|
github.com/quic-go/qpack v0.6.0 // indirect
|
||||||
|
github.com/quic-go/quic-go v0.59.0 // indirect
|
||||||
|
github.com/shoenig/go-m1cpu v0.1.6 // indirect
|
||||||
|
github.com/tklauser/go-sysconf v0.3.12 // indirect
|
||||||
|
github.com/tklauser/numcpus v0.6.1 // indirect
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
github.com/ugorji/go/codec v1.2.12 // indirect
|
github.com/ugorji/go/codec v1.3.1 // indirect
|
||||||
golang.org/x/arch v0.8.0 // indirect
|
go.mongodb.org/mongo-driver/v2 v2.5.0 // indirect
|
||||||
golang.org/x/crypto v0.23.0 // indirect
|
golang.org/x/arch v0.22.0 // indirect
|
||||||
golang.org/x/net v0.25.0 // indirect
|
golang.org/x/crypto v0.57.0 // indirect
|
||||||
golang.org/x/sys v0.20.0 // indirect
|
golang.org/x/net v0.58.0 // indirect
|
||||||
golang.org/x/text v0.15.0 // indirect
|
golang.org/x/text v0.42.0 // indirect
|
||||||
google.golang.org/protobuf v1.34.1 // indirect
|
google.golang.org/protobuf v1.36.10 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
howett.net/plist v1.0.0 // indirect
|
howett.net/plist v1.0.0 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,25 +1,26 @@
|
|||||||
|
github.com/KarpelesLab/vncpasswd v1.0.1 h1:w0dhjSXfo59bm9/LLKhO7hV+GUGEn4WjAZTLXTNSciU=
|
||||||
|
github.com/KarpelesLab/vncpasswd v1.0.1/go.mod h1:gh6AFDSUqRZwcdjAm/p8V81P9ePtOI65ajs7KT7D+Fc=
|
||||||
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
|
github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA=
|
||||||
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
|
github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8=
|
||||||
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
|
github.com/bytedance/gopkg v0.1.3 h1:TPBSwH8RsouGCBcMBktLt1AymVo2TVsBVCY4b6TnZ/M=
|
||||||
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
|
github.com/bytedance/gopkg v0.1.3/go.mod h1:576VvJ+eJgyCzdjS+c4+77QF3p7ubbtiKARP3TxducM=
|
||||||
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
|
github.com/bytedance/sonic v1.15.0 h1:/PXeWFaR5ElNcVE84U0dOHjiMHQOwNIx3K4ymzh/uSE=
|
||||||
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
github.com/bytedance/sonic v1.15.0/go.mod h1:tFkWrPz0/CUCLEF4ri4UkHekCIcdnkqXw9VduqpJh0k=
|
||||||
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
|
github.com/bytedance/sonic/loader v0.5.0 h1:gXH3KVnatgY7loH5/TkeVyXPfESoqSBSBEiDd5VjlgE=
|
||||||
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
github.com/bytedance/sonic/loader v0.5.0/go.mod h1:AR4NYCk5DdzZizZ5djGqQ92eEhCCcdf5x77udYiSJRo=
|
||||||
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
|
github.com/cloudwego/base64x v0.1.6 h1:t11wG9AECkCDk5fMSoxmufanudBtJ+/HemLstXDLI2M=
|
||||||
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
github.com/cloudwego/base64x v0.1.6/go.mod h1:OFcloc187FXDaYHvrNIjxSe8ncn0OOM8gEHfghB2IPU=
|
||||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
|
||||||
github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
|
github.com/creack/pty v1.1.17 h1:QeVUsEDNrLBW4tMgZHvxy18sKtr6VI492kBhUfhDJNI=
|
||||||
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
|
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
|
github.com/gabriel-vasile/mimetype v1.4.15 h1:05iP/CYtZ/w455R/KZM6rZ5ieAdh99UPtd+d3YzLmaI=
|
||||||
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
|
github.com/gabriel-vasile/mimetype v1.4.15/go.mod h1:azpTcoLcDZRNgFou5j+APrqQx9HqVPWa6ijYQIIVswQ=
|
||||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
github.com/gin-contrib/sse v1.1.0 h1:n0w2GMuUpWDVp7qSpvze6fAu9iRxJY4Hmj6AmBOU05w=
|
||||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
github.com/gin-contrib/sse v1.1.0/go.mod h1:hxRZ5gVpWMT7Z0B0gSNYqqsSCNIJMjzvm6fqCz9vjwM=
|
||||||
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
github.com/gin-gonic/gin v1.12.0 h1:b3YAbrZtnf8N//yjKeU2+MQsh2mY5htkZidOM7O0wG8=
|
||||||
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
github.com/gin-gonic/gin v1.12.0/go.mod h1:VxccKfsSllpKshkBWgVgRniFFAzFb9csfngsqANjnLc=
|
||||||
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||||
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
|
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
|
||||||
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||||
@@ -29,12 +30,15 @@ github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/o
|
|||||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||||
github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8=
|
github.com/go-playground/validator/v10 v10.30.4 h1:9Rcod2ZPO6mOEG6b4GqyoHE/H6//Ze0RuhOo1hT1x0w=
|
||||||
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
|
github.com/go-playground/validator/v10 v10.30.4/go.mod h1:numpT+RPLE91R9oYWMY/R9zRgJBewr3IXHko4OISPpk=
|
||||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
|
||||||
|
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
|
||||||
|
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
|
||||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||||
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
|
||||||
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||||
@@ -47,16 +51,18 @@ github.com/jaypipes/pcidb v1.0.1/go.mod h1:6xYUz/yYEyOkIkUt2t2J2folIuZ4Yg6uByCGF
|
|||||||
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
|
||||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
github.com/kardianos/service v1.2.2 h1:ZvePhAHfvo0A7Mftk/tEzqEZ7Q4lgnR8sGz4xu1YX60=
|
||||||
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
|
github.com/kardianos/service v1.2.2/go.mod h1:CIMRFEJVL+0DS1a3Nx06NaMn4Dz63Ng6O7dl0qH0zVM=
|
||||||
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
github.com/klauspost/cpuid/v2 v2.3.0 h1:S4CRMLnYUhGeDFDqkGriYKdfoFlDnMtqTiI/sFzhA9Y=
|
||||||
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
github.com/klauspost/cpuid/v2 v2.3.0/go.mod h1:hqwkgyIinND0mEev00jJYCxPNVRVXFQeu1XKlok6oO0=
|
||||||
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
github.com/leodido/go-urn v1.5.0 h1:pLqT2kq1zpHW/1D18QMjMpdtX7cekxqtJJjg5ANyWw0=
|
||||||
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
github.com/leodido/go-urn v1.5.0/go.mod h1:9BORnCDhdPBJNDEX+w1bJisa8yOKYi116VeO96s4ifE=
|
||||||
|
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
|
||||||
|
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||||
@@ -66,20 +72,29 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
|
|||||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0t5Ec4=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
|
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
|
||||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||||
|
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
|
||||||
|
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
|
||||||
|
github.com/quic-go/quic-go v0.59.0 h1:OLJkp1Mlm/aS7dpKgTc6cnpynnD2Xg7C1pwL6vy/SAw=
|
||||||
|
github.com/quic-go/quic-go v0.59.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=
|
||||||
|
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||||
|
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
||||||
github.com/runletapp/go-console v0.0.0-20211204140000-27323a28410a h1:1hh8CSomjZSJPk7AgHV8o33Su13bZby81PrC6pIvJqQ=
|
github.com/runletapp/go-console v0.0.0-20211204140000-27323a28410a h1:1hh8CSomjZSJPk7AgHV8o33Su13bZby81PrC6pIvJqQ=
|
||||||
github.com/runletapp/go-console v0.0.0-20211204140000-27323a28410a/go.mod h1:9Y3jw1valnPKqsYSsBWxQNAuxqNSBuwd2ZEeElxgNUI=
|
github.com/runletapp/go-console v0.0.0-20211204140000-27323a28410a/go.mod h1:9Y3jw1valnPKqsYSsBWxQNAuxqNSBuwd2ZEeElxgNUI=
|
||||||
github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI=
|
github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI=
|
||||||
github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk=
|
github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk=
|
||||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
|
||||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
|
||||||
|
github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
|
||||||
|
github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=
|
||||||
|
github.com/sirupsen/logrus v1.10.2 h1:G2SED73/qrAu6YwbdxOD6peLkCBI3z7L+ykJFTXJBBo=
|
||||||
|
github.com/sirupsen/logrus v1.10.2/go.mod h1:SLEg8TqYulVKKfIGHldVp2K2aYz2DKSVBq4g/H5bR7Q=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
@@ -88,42 +103,51 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
|
|||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.12.1 h1:EuwCh5fleGS7H32xRwO3wRGT7DxrDhLAT6FF8MpWDWE=
|
||||||
|
github.com/stretchr/testify v1.12.1/go.mod h1:MDEgiDPPsNp5cuIrHPPCyornHKgEVbtFUmoNlxoYthg=
|
||||||
|
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
|
||||||
|
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
|
||||||
|
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
|
||||||
|
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||||
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
github.com/ugorji/go/codec v1.3.1 h1:waO7eEiFDwidsBN6agj1vJQ4AG7lh2yqXyOXqhgQuyY=
|
||||||
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
github.com/ugorji/go/codec v1.3.1/go.mod h1:pRBVtBSKl77K30Bv8R2P+cLSGaTtex6fsA2Wjqmfxj4=
|
||||||
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
|
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
|
||||||
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
go.mongodb.org/mongo-driver/v2 v2.5.0 h1:yXUhImUjjAInNcpTcAlPHiT7bIXhshCTL3jVBkF3xaE=
|
||||||
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
|
go.mongodb.org/mongo-driver/v2 v2.5.0/go.mod h1:yOI9kBsufol30iFsl1slpdq1I0eHPzybRWdyYUs8K/0=
|
||||||
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
|
||||||
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
|
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
|
||||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
go.yaml.in/yaml/v3 v3.0.5 h1:N6y/pJk8buWs9NY5ERU2HSMfm+IuD/OtfdAnq6kESPw=
|
||||||
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
go.yaml.in/yaml/v3 v3.0.5/go.mod h1:HVTZu1O7/Vkt2N+BFy8Zza+lnLsABggaTM2ZpNIGuKg=
|
||||||
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
golang.org/x/arch v0.22.0 h1:c/Zle32i5ttqRXjdLyyHZESLD/bB90DCU1g9l/0YBDI=
|
||||||
|
golang.org/x/arch v0.22.0/go.mod h1:dNHoOeKiyja7GTvF9NJS1l3Z2yntpQNzgrjh1cU103A=
|
||||||
|
golang.org/x/crypto v0.57.0 h1:3ZVCjf8Ggz7zneR/EHRVx68Ctf+2pmIMP2UFhh9cC6M=
|
||||||
|
golang.org/x/crypto v0.57.0/go.mod h1:Fdz0i5U6CoizGwLda9DttjSk6qlZo25zYNtR+ycvuZA=
|
||||||
|
golang.org/x/net v0.58.0 h1:ynWG7rqYi4ccpTEuPZ2QGWHktVEM9DMCj9yzDE0Q7To=
|
||||||
|
golang.org/x/net v0.58.0/go.mod h1:YwCddHnFlT7eLQqVprV19OnhLGtc5xOKgE0RyqgfWAU=
|
||||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20201015000850-e3ed0017c211/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
|
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
|
golang.org/x/sys v0.48.0 h1:bbX/i/6MgT9BVLM9RT1thmxL04yeTAhbEz4SyadbXoo=
|
||||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/sys v0.48.0/go.mod h1:hNLxWAXmnKAxqDtdwIYC4bM9oQPEecfsnNMuSxOs3og=
|
||||||
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
|
golang.org/x/text v0.42.0 h1:JbOZXgfeCPU9gacVtYliJqOhD+zhrEqK4LfdpmlUZqI=
|
||||||
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
golang.org/x/text v0.42.0/go.mod h1:ojzP1Z+2QtioaF8DTtO8K5q7JWVVYwZKenzujK0Zd0E=
|
||||||
|
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
google.golang.org/protobuf v1.36.10 h1:AYd7cD/uASjIL6Q9LiTjz8JLcrh/88q5UObnmY3aOOE=
|
||||||
|
google.golang.org/protobuf v1.36.10/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=
|
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM=
|
howett.net/plist v1.0.0 h1:7CrbWYbPPO/PyNy38b2EB/+gYbjCe2DXBxgtOOZbSQM=
|
||||||
howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g=
|
howett.net/plist v1.0.0/go.mod h1:lqaXoTrLY4hg8tnEzNru53gicrbv7rrk+2xJA/7hw9g=
|
||||||
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
|
||||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# process
|
||||||
|
|
||||||
|
远程进程管理(被控 HTTP 能力):进程列表 / 结束进程。gopsutil 跨平台实现,
|
||||||
|
与 file/shell 同为被控 HTTP 能力——BS 与客户机被控端共用,经 zonat 隧道 +
|
||||||
|
web-gateway 反代出网(typ=process,页面 www/process.html)。
|
||||||
|
|
||||||
|
## 路由
|
||||||
|
|
||||||
|
```go
|
||||||
|
import "git.zeroonesoft.cn/golib/remote-core/process"
|
||||||
|
|
||||||
|
process.RegisterRoutersProcess(r *gin.RouterGroup)
|
||||||
|
```
|
||||||
|
|
||||||
|
| 方法 | 路径 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| GET | `/process/list` | 全量进程列表(`ProcItem`:pid/名称/用户/CPU/内存/启动时间/可执行路径/命令行),按内存占用降序 |
|
||||||
|
| POST | `/process/kill` | 结束进程,入参 `{pid, name?}` |
|
||||||
|
|
||||||
|
## 注意
|
||||||
|
|
||||||
|
- `kill` 带 `name` 时做防误杀校验:实际进程名与传入不符则拒绝(防 pid 复用)。
|
||||||
|
- Windows 上 gopsutil 权限不足时自动回退 `taskkill /F /T`(连子进程树强杀)。
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
// 远程进程管理:进程列表 / 结束进程。
|
||||||
|
// gopsutil 跨平台实现,与 file/shell 同为被控 HTTP 能力——BS 与客户机被控端共用,
|
||||||
|
// 经 zonat 隧道 + web-gateway 反代出网(typ=process,页面 www/process.html)。
|
||||||
|
|
||||||
|
package process
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"os/exec"
|
||||||
|
"runtime"
|
||||||
|
"sort"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"github.com/shirou/gopsutil/v3/process"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProcItem 进程列表行。
|
||||||
|
type ProcItem struct {
|
||||||
|
Pid int32 `json:"pid"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
User string `json:"user"`
|
||||||
|
CPUPercent float64 `json:"cpuPercent"` // 进程存活期累计 CPU 占用率(gopsutil 口径)
|
||||||
|
MemRSS uint64 `json:"memBytes"` // 物理内存占用(字节)
|
||||||
|
MemPercent float32 `json:"memPercent"`
|
||||||
|
CreateTime int64 `json:"createTime"` // 启动时间(Unix 毫秒)
|
||||||
|
Exe string `json:"exe"`
|
||||||
|
Cmdline string `json:"cmdline"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// RegisterRoutersProcess 装配进程管理路由: GET /process/list, POST /process/kill。
|
||||||
|
func RegisterRoutersProcess(r *gin.RouterGroup) {
|
||||||
|
r.GET("/process/list", listProcesses())
|
||||||
|
r.POST("/process/kill", killProcess())
|
||||||
|
}
|
||||||
|
|
||||||
|
// listProcesses 全量进程列表(按内存占用降序)。
|
||||||
|
func listProcesses() gin.HandlerFunc {
|
||||||
|
return func(c *gin.Context) {
|
||||||
|
procs, err := process.Processes()
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"code": 1, "msg": "枚举进程失败: " + err.Error(), "data": nil})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
items := make([]ProcItem, 0, len(procs))
|
||||||
|
for _, p := range procs {
|
||||||
|
item := ProcItem{Pid: p.Pid}
|
||||||
|
if name, e := p.Name(); e == nil {
|
||||||
|
item.Name = name
|
||||||
|
}
|
||||||
|
if st, e := p.Status(); e == nil && len(st) > 0 {
|
||||||
|
item.Status = st[0]
|
||||||
|
}
|
||||||
|
if u, e := p.Username(); e == nil {
|
||||||
|
item.User = u
|
||||||
|
}
|
||||||
|
if cpu, e := p.CPUPercent(); e == nil {
|
||||||
|
item.CPUPercent = cpu
|
||||||
|
}
|
||||||
|
if mem, e := p.MemoryInfo(); e == nil {
|
||||||
|
item.MemRSS = mem.RSS
|
||||||
|
}
|
||||||
|
if mp, e := p.MemoryPercent(); e == nil {
|
||||||
|
item.MemPercent = mp
|
||||||
|
}
|
||||||
|
if ct, e := p.CreateTime(); e == nil {
|
||||||
|
item.CreateTime = ct
|
||||||
|
}
|
||||||
|
if exe, e := p.Exe(); e == nil {
|
||||||
|
item.Exe = exe
|
||||||
|
}
|
||||||
|
if cmd, e := p.Cmdline(); e == nil {
|
||||||
|
item.Cmdline = cmd
|
||||||
|
}
|
||||||
|
items = append(items, item)
|
||||||
|
}
|
||||||
|
sort.Slice(items, func(i, j int) bool { return items[i].MemPercent > items[j].MemPercent })
|
||||||
|
c.JSON(http.StatusOK, gin.H{"code": 0, "msg": "OK", "data": gin.H{"list": items}})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// killProcess 结束进程: {pid: 必填, name: 可选校验(防 pid 复用误杀)}。
|
||||||
|
// Windows 上 gopsutil 权限不足时回退 taskkill /F /T(连子进程树强杀)。
|
||||||
|
func killProcess() gin.HandlerFunc {
|
||||||
|
return func(c *gin.Context) {
|
||||||
|
var req struct {
|
||||||
|
Pid int32 `json:"pid"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
if err := c.ShouldBindJSON(&req); err != nil || req.Pid <= 0 {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"code": 1, "msg": "参数错误: pid 必填且为正整数", "data": nil})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
p, err := process.NewProcess(req.Pid)
|
||||||
|
if err != nil {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"code": 1, "msg": "进程不存在: " + err.Error(), "data": nil})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if req.Name != "" {
|
||||||
|
if name, e := p.Name(); e == nil && name != "" && name != req.Name {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"code": 1, "msg": "进程名不匹配(实际 " + name + "), 已拒绝结束", "data": nil})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if err := p.Kill(); err != nil {
|
||||||
|
if runtime.GOOS != "windows" {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"code": 1, "msg": "结束进程失败: " + err.Error(), "data": nil})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if out, e := exec.Command("taskkill", "/F", "/T", "/PID", strconv.Itoa(int(req.Pid))).CombinedOutput(); e != nil {
|
||||||
|
c.JSON(http.StatusOK, gin.H{"code": 1, "msg": "结束进程失败: " + err.Error() + "; taskkill: " + string(out), "data": nil})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.JSON(http.StatusOK, gin.H{"code": 0, "msg": "OK", "data": gin.H{"pid": req.Pid}})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
# remote
|
||||||
|
|
||||||
|
远程控制服务管理(被控端能力):RDP / VNC(TightVNC) / Radmin 的服务状态查询、
|
||||||
|
启停与重置,VNC 服务端安装/配置读写,VNC 密码加解密,远程信息汇总。
|
||||||
|
|
||||||
|
> 自 go-hua/remote 平移并入(包名保持 `remote`),与本库 file/shell/process
|
||||||
|
> 同属被控端远程运维能力。
|
||||||
|
|
||||||
|
## 用法
|
||||||
|
|
||||||
|
```go
|
||||||
|
import "git.zeroonesoft.cn/golib/remote-core/remote"
|
||||||
|
|
||||||
|
// 汇总信息(主机名/IP/MAC/远程端口/VNC 密码等)
|
||||||
|
info := remote.GetRemoteInfo()
|
||||||
|
|
||||||
|
// 远程服务状态与控制
|
||||||
|
_ = remote.GetRdpServiceStatus() // kardianos/service Status
|
||||||
|
_ = remote.GetVncServiceStatus() // 同上
|
||||||
|
_ = remote.GetRadminServiceStatus() // (int, error):1 运行 / 0 停止 / -1 未安装
|
||||||
|
_ = remote.GetServiceStatus("SessionEnv") // 通用按服务名查询
|
||||||
|
err := remote.ServiceStart(name) // 启动 / ServiceStop 停止
|
||||||
|
_ = remote.GetServiceReset(name) // 重置类服务状态
|
||||||
|
|
||||||
|
// RDP / VNC 端口与 VNC 密码读取
|
||||||
|
port, err := remote.GetRdpPort()
|
||||||
|
vncPort, err := remote.GetVncPort()
|
||||||
|
pass, err := remote.GetVncPassword()
|
||||||
|
|
||||||
|
// VNC(TightVNC) 服务端管理(Windows)
|
||||||
|
cfg := remote.VncServerDefaultConfig(true /* 随机密码 */) // VncServerConfig
|
||||||
|
err = remote.WriteVncServerConfig(cfg)
|
||||||
|
cfg, err = remote.ReadVncServerConfig()
|
||||||
|
_, msg, err := remote.InstallVncServer() // 安装服务(需管理员权限)
|
||||||
|
err = remote.VncInit() // 初始化/修复配置
|
||||||
|
err = remote.VncStart() // VncStop / VncRestart
|
||||||
|
err = remote.VncInstall() // VncUninstall
|
||||||
|
err = remote.RunVncService() // 以服务方式运行
|
||||||
|
|
||||||
|
// VNC 密码加解密(TightVNC 注册表存储格式)
|
||||||
|
enc := remote.VncPasswordCrypt("plainpass") // []byte
|
||||||
|
plain := remote.VncPasswordDecrypt(enc) // string
|
||||||
|
|
||||||
|
// CAD/SAS 相关注册表开关(Windows)
|
||||||
|
err = remote.EnableSoftwareSASGeneration()
|
||||||
|
```
|
||||||
|
|
||||||
|
## 平台支持
|
||||||
|
|
||||||
|
- `remote.go` / `type.go`:跨平台(依赖 `kardianos/service`)。
|
||||||
|
- `windows.go` / `vnc.go`:`//go:build windows`(注册表、TightVNC 配置)。
|
||||||
|
- `unix.go`:`//go:build linux`(精简实现)。
|
||||||
|
|
||||||
|
## 注意
|
||||||
|
|
||||||
|
- `GetServiceStatus` 系列对未安装服务返回 -1 而非错误;`GetRdpServiceStatus` /
|
||||||
|
`GetVncServiceStatus` 走 `kardianos/service`,未安装返回 error。
|
||||||
|
- `InstallVncServer` / `VncInit` / CAD 开关需要管理员权限,失败信息见返回 msg 或 error。
|
||||||
|
- VNC 密码格式与 TightVNC 兼容(`KarpelesLab/vncpasswd` 实现),加解密为确定性
|
||||||
|
变换,注意密文落盘位置的访问控制。
|
||||||
@@ -0,0 +1,191 @@
|
|||||||
|
package remote
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/kardianos/service"
|
||||||
|
"net"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Info 远程控制信息汇总(主机、IP、MAC 与 RDP/VNC 状态端口)
|
||||||
|
type Info struct {
|
||||||
|
Hostname string `json:"hostname"`
|
||||||
|
IpAddr []string `json:"ipAddr"`
|
||||||
|
MacAddr []string `json:"macAddr"`
|
||||||
|
RdpState int `json:"rdpState"`
|
||||||
|
RdpPort int `json:"rdpPort"`
|
||||||
|
VncState int `json:"vncState"`
|
||||||
|
VncPort int `json:"vncPort"`
|
||||||
|
VncPassword string `json:"vncPassword"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRadminServiceStatus 获取服务状态 0.无效 1.运行 2.停止
|
||||||
|
func GetRadminServiceStatus() (int, error) {
|
||||||
|
svcConfig := &service.Config{
|
||||||
|
Name: "RServer3",
|
||||||
|
}
|
||||||
|
s, err := service.New(nil, svcConfig)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
var status service.Status
|
||||||
|
status, err = s.Status()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(status), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetVncServiceStatus 获取服务状态 0.无效 1.运行 2.停止
|
||||||
|
func GetVncServiceStatus() (service.Status, error) {
|
||||||
|
svcConfig := &service.Config{
|
||||||
|
Name: "tvnserver",
|
||||||
|
}
|
||||||
|
s, err := service.New(nil, svcConfig)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
var status service.Status
|
||||||
|
status, err = s.Status()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return status, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRdpServiceStatus 获取服务状态 0.无效 1.运行 2.停止
|
||||||
|
func GetRdpServiceStatus() (service.Status, error) {
|
||||||
|
svcConfig := &service.Config{
|
||||||
|
Name: "TermService",
|
||||||
|
}
|
||||||
|
s, err := service.New(nil, svcConfig)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
var status service.Status
|
||||||
|
status, err = s.Status()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return status, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// getMacAddrs 获取本机所有非空 MAC 地址
|
||||||
|
func getMacAddrs() (macAddrs []string) {
|
||||||
|
netInterfaces, err := net.Interfaces()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("fail to get net interfaces: %v", err)
|
||||||
|
return macAddrs
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, netInterface := range netInterfaces {
|
||||||
|
macAddr := netInterface.HardwareAddr.String()
|
||||||
|
if len(macAddr) == 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
macAddrs = append(macAddrs, macAddr)
|
||||||
|
}
|
||||||
|
return macAddrs
|
||||||
|
}
|
||||||
|
|
||||||
|
// getIPs 获取本机所有 IPv4 地址(不含回环)
|
||||||
|
func getIPs() (ips []string) {
|
||||||
|
|
||||||
|
interfaceAddr, err := net.InterfaceAddrs()
|
||||||
|
if err != nil {
|
||||||
|
fmt.Printf("fail to get net interface addrs: %v", err)
|
||||||
|
return ips
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, address := range interfaceAddr {
|
||||||
|
ipNet, isValidIpNet := address.(*net.IPNet)
|
||||||
|
if isValidIpNet && !ipNet.IP.IsLoopback() {
|
||||||
|
if ipNet.IP.To4() != nil {
|
||||||
|
ips = append(ips, ipNet.IP.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ips
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetServiceStatus 获取服务状态 0.无效 1.运行 2.停止
|
||||||
|
func GetServiceStatus(name string) (int, error) {
|
||||||
|
svcConfig := &service.Config{
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
s, err := service.New(nil, svcConfig)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
var status service.Status
|
||||||
|
status, err = s.Status()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(status), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServiceStart 启动服务
|
||||||
|
func ServiceStart(name string) error {
|
||||||
|
svcConfig := &service.Config{
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
s, err := service.New(nil, svcConfig)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = s.Start()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServiceStop 停止服务
|
||||||
|
func ServiceStop(name string) (i error) {
|
||||||
|
svcConfig := &service.Config{
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
s, err := service.New(nil, svcConfig)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = s.Stop()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetServiceReset 重启服务
|
||||||
|
func GetServiceReset(name string) (int, error) {
|
||||||
|
svcConfig := &service.Config{
|
||||||
|
Name: name,
|
||||||
|
}
|
||||||
|
s, err := service.New(nil, svcConfig)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
var status service.Status
|
||||||
|
status, err = s.Status()
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return int(status), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// RunVncService 启动 TightVNC 服务
|
||||||
|
func RunVncService() error {
|
||||||
|
svcConfig := &service.Config{
|
||||||
|
Name: "tvnserver",
|
||||||
|
}
|
||||||
|
s, err := service.New(nil, svcConfig)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = s.Start()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package remote
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestGetServiceStatusNonExist(t *testing.T) {
|
||||||
|
// 不存在的服务应返回错误(Radmin 服务普通机器上不会安装)
|
||||||
|
_, err := GetRadminServiceStatus()
|
||||||
|
if err == nil {
|
||||||
|
t.Log("本机安装了 Radmin 服务,跳过该断言")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestGetRemoteInfo(t *testing.T) {
|
||||||
|
info := GetRemoteInfo()
|
||||||
|
if info.Hostname == "" {
|
||||||
|
t.Error("Hostname 不应为空")
|
||||||
|
}
|
||||||
|
if len(info.IpAddr) == 0 {
|
||||||
|
t.Log("本机无 IPv4 地址(CI 环境可能出现)")
|
||||||
|
}
|
||||||
|
// 只读查询,不应 panic
|
||||||
|
_ = info.RdpState
|
||||||
|
_ = info.VncState
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestVncPasswordCryptDecrypt(t *testing.T) {
|
||||||
|
password := "tvncpass"
|
||||||
|
encrypted := VncPasswordCrypt(password)
|
||||||
|
if len(encrypted) == 0 {
|
||||||
|
t.Fatal("加密结果不应为空")
|
||||||
|
}
|
||||||
|
if string(encrypted) == password {
|
||||||
|
t.Error("加密结果不应等于明文")
|
||||||
|
}
|
||||||
|
decrypted := VncPasswordDecrypt(encrypted)
|
||||||
|
if decrypted != password {
|
||||||
|
t.Errorf("解密 = %q, want %q", decrypted, password)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestVncServerDefaultConfig(t *testing.T) {
|
||||||
|
cfg := VncServerDefaultConfig(false)
|
||||||
|
if cfg.RfbPort == 0 {
|
||||||
|
t.Error("RfbPort 不应为 0")
|
||||||
|
}
|
||||||
|
if cfg.HttpPort == 0 {
|
||||||
|
t.Error("HttpPort 不应为 0")
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
// Package remote 提供 RDP/VNC 等远程控制的服务状态查询、配置读写与启停控制。
|
||||||
|
package remote
|
||||||
|
|
||||||
|
// VncServerConfig TightVNC 服务端配置(对应注册表 SOFTWARE\TightVNC\Server 下的键值)
|
||||||
|
type VncServerConfig struct {
|
||||||
|
ExtraPorts string `json:"extraPorts"` // 额外端口
|
||||||
|
QueryTimeout uint32 `json:"queryTimeout"` // 查询超时
|
||||||
|
QueryAcceptOnTimeout uint32 `json:"queryAcceptOnTimeout"` // 查询接受超时
|
||||||
|
LocalInputPriorityTimeout uint32 `json:"localInputPriorityTimeout"` // 本地输入优先级超时
|
||||||
|
LocalInputPriority uint32 `json:"localInputPriority"` // 本地输入优先
|
||||||
|
BlockRemoteInput uint32 `json:"blockRemoteInput"` // 阻止远程输入
|
||||||
|
BlockLocalInput uint32 `json:"blockLocalInput"` // 阻止本地输入
|
||||||
|
IpAccessControl string `json:"ipAccessControl"` // IP访问控制
|
||||||
|
RfbPort uint32 `json:"rfbPort"` // 主端口
|
||||||
|
HttpPort uint32 `json:"httpPort"` // WEB端口
|
||||||
|
DisconnectAction uint32 `json:"disconnectAction"` // 断开动作
|
||||||
|
AcceptRfbConnections uint32 `json:"acceptRfbConnections"` // 接受RFB连接
|
||||||
|
UseVncAuthentication uint32 `json:"useVncAuthentication"` // 使用VNC认证
|
||||||
|
UseControlAuthentication uint32 `json:"useControlAuthentication"` // 使用控制认证
|
||||||
|
RepeatControlAuthentication uint32 `json:"repeatControlAuthentication"` // 重复控制认证
|
||||||
|
LoopbackOnly uint32 `json:"loopbackOnly"` // 只允许环回
|
||||||
|
AcceptHttpConnections uint32 `json:"acceptHttpConnections"` // HTTP请求连接
|
||||||
|
LogLevel uint32 `json:"logLevel"` // 日志等级
|
||||||
|
EnableFileTransfers uint32 `json:"enableFileTransfers"` // 使文件传输
|
||||||
|
RemoveWallpaper uint32 `json:"removeWallpaper"` // 移除墙纸
|
||||||
|
UseD3D uint32 `json:"useD3D"` // 使用D3D驱动
|
||||||
|
UseMirrorDriver uint32 `json:"useMirrorDriver"` // 使用镜像驱动
|
||||||
|
EnableUrlParams uint32 `json:"enableUrlParams"` // 用URL参数
|
||||||
|
Password []byte `json:"password"` // 密码(需要加密)
|
||||||
|
AlwaysShared uint32 `json:"alwaysShared"` // 总是共享
|
||||||
|
NeverShared uint32 `json:"neverShared"` // 从不共享
|
||||||
|
DisconnectClients uint32 `json:"disconnectClients"` // 断开客户端后操作
|
||||||
|
PollingInterval uint32 `json:"pollingInterval"` // 轮询间隔
|
||||||
|
AllowLoopback uint32 `json:"allowLoopback"` // 允许环回
|
||||||
|
VideoRecognitionInterval uint32 `json:"videoRecognitionInterval"` // 视频轮询间隔
|
||||||
|
GrabTransparentWindows uint32 `json:"grabTransparentWindows"` // 抓取透明窗口
|
||||||
|
SaveLogToAllUsersPath uint32 `json:"saveLogToAllUsersPath"` // 保存日志所有用户路径
|
||||||
|
RunControlInterface uint32 `json:"runControlInterface"` // 运行控制台接口
|
||||||
|
IdleTimeout uint32 `json:"idleTimeout"` // 空闲超时
|
||||||
|
VideoClasses string `json:"videoClasses"` // 视频窗口类名
|
||||||
|
VideoRects string `json:"videoRects"` // 视频窗口区域
|
||||||
|
ConnectToRdp uint32 `json:"connectToRdp"` // 连接到RDP会话
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
//go:build linux
|
||||||
|
|
||||||
|
package remote
|
||||||
|
|
||||||
|
import "os"
|
||||||
|
|
||||||
|
// GetRemoteInfo 获取远程控制相关信息(Linux 平台仅主机名/IP/MAC)
|
||||||
|
func GetRemoteInfo() Info {
|
||||||
|
info := Info{}
|
||||||
|
|
||||||
|
/*var status int
|
||||||
|
status, _ = GetRadminServiceStatus()
|
||||||
|
info.RadminState = status
|
||||||
|
|
||||||
|
status, _ = GetVncServiceStatus()
|
||||||
|
info.VncState = status
|
||||||
|
|
||||||
|
status, _ = GetRdpServiceStatus()
|
||||||
|
info.RdpState = status*/
|
||||||
|
|
||||||
|
/* var port int
|
||||||
|
port, _ = GetRadminPort()
|
||||||
|
info.RadminPort = port
|
||||||
|
|
||||||
|
port, _ = GetRdpPort()
|
||||||
|
info.RdpPort = port
|
||||||
|
|
||||||
|
port, _ = GetVncPort()
|
||||||
|
info.VncPort = port*/
|
||||||
|
|
||||||
|
hostname, _ := os.Hostname()
|
||||||
|
info.Hostname = hostname
|
||||||
|
info.IpAddr = getIPs()
|
||||||
|
info.MacAddr = getMacAddrs()
|
||||||
|
|
||||||
|
return info
|
||||||
|
}
|
||||||
|
|
||||||
|
// VncServerDefaultConfig 生成 TightVNC 服务端默认配置(Linux 未实现,返回空配置)
|
||||||
|
func VncServerDefaultConfig(randPass bool) VncServerConfig {
|
||||||
|
config := VncServerConfig{}
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
|
||||||
|
// VncClientDefaultConfig 生成 TightVNC 客户端默认配置(Linux 未实现,返回空配置)
|
||||||
|
func VncClientDefaultConfig(randPass bool) VncServerConfig {
|
||||||
|
config := VncServerConfig{}
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteVncServerConfig 写入 TightVNC 服务端配置(Linux 未实现,直接返回 nil)
|
||||||
|
func WriteVncServerConfig(config VncServerConfig) error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EnableSoftwareSASGeneration 启用软件SAS模拟输入
|
||||||
|
func EnableSoftwareSASGeneration() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EnableWinlogonDisableCAD 关闭 Ctrl + Alt + Del 组合键来登录
|
||||||
|
func EnableWinlogonDisableCAD() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EnableSystemDisableCAD 关闭 Ctrl + Alt + Del 组合键来登录
|
||||||
|
func EnableSystemDisableCAD() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
+192
@@ -0,0 +1,192 @@
|
|||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package remote
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/KarpelesLab/vncpasswd"
|
||||||
|
"github.com/kardianos/service"
|
||||||
|
"golang.org/x/sys/windows/registry"
|
||||||
|
)
|
||||||
|
|
||||||
|
var VncService service.Service
|
||||||
|
|
||||||
|
// ReadVncServerConfig 从注册表读取 TightVNC 服务端配置
|
||||||
|
func ReadVncServerConfig() (VncServerConfig, error) {
|
||||||
|
config := VncServerConfig{
|
||||||
|
ExtraPorts: "",
|
||||||
|
QueryTimeout: 0,
|
||||||
|
QueryAcceptOnTimeout: 0,
|
||||||
|
LocalInputPriorityTimeout: 0,
|
||||||
|
LocalInputPriority: 0,
|
||||||
|
BlockRemoteInput: 0,
|
||||||
|
BlockLocalInput: 0,
|
||||||
|
IpAccessControl: "",
|
||||||
|
RfbPort: 0,
|
||||||
|
HttpPort: 0,
|
||||||
|
DisconnectAction: 0,
|
||||||
|
AcceptRfbConnections: 0,
|
||||||
|
UseVncAuthentication: 0,
|
||||||
|
UseControlAuthentication: 0,
|
||||||
|
RepeatControlAuthentication: 0,
|
||||||
|
LoopbackOnly: 0,
|
||||||
|
AcceptHttpConnections: 0,
|
||||||
|
LogLevel: 0,
|
||||||
|
EnableFileTransfers: 0,
|
||||||
|
RemoveWallpaper: 0,
|
||||||
|
UseD3D: 0,
|
||||||
|
UseMirrorDriver: 0,
|
||||||
|
EnableUrlParams: 0,
|
||||||
|
Password: []byte{},
|
||||||
|
AlwaysShared: 0,
|
||||||
|
NeverShared: 0,
|
||||||
|
DisconnectClients: 0,
|
||||||
|
PollingInterval: 0,
|
||||||
|
AllowLoopback: 0,
|
||||||
|
VideoRecognitionInterval: 0,
|
||||||
|
GrabTransparentWindows: 0,
|
||||||
|
SaveLogToAllUsersPath: 0,
|
||||||
|
RunControlInterface: 0,
|
||||||
|
IdleTimeout: 0,
|
||||||
|
VideoClasses: "",
|
||||||
|
VideoRects: "",
|
||||||
|
ConnectToRdp: 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
key, err := registry.OpenKey(registry.LOCAL_MACHINE, "SOFTWARE\\TightVNC\\Server", registry.ALL_ACCESS)
|
||||||
|
if err != nil {
|
||||||
|
return config, err
|
||||||
|
}
|
||||||
|
defer key.Close()
|
||||||
|
|
||||||
|
config.ExtraPorts, _, _ = key.GetStringValue("ExtraPorts")
|
||||||
|
config.QueryTimeout, _, _ = GetDwordValue(key, "QueryTimeout")
|
||||||
|
config.QueryAcceptOnTimeout, _, _ = GetDwordValue(key, "QueryAcceptOnTimeout")
|
||||||
|
config.LocalInputPriorityTimeout, _, _ = GetDwordValue(key, "LocalInputPriorityTimeout")
|
||||||
|
config.LocalInputPriority, _, _ = GetDwordValue(key, "LocalInputPriority")
|
||||||
|
config.BlockRemoteInput, _, _ = GetDwordValue(key, "BlockRemoteInput")
|
||||||
|
config.BlockLocalInput, _, _ = GetDwordValue(key, "BlockLocalInput")
|
||||||
|
config.IpAccessControl, _, _ = key.GetStringValue("IpAccessControl")
|
||||||
|
config.RfbPort, _, _ = GetDwordValue(key, "RfbPort")
|
||||||
|
config.HttpPort, _, _ = GetDwordValue(key, "HttpPort")
|
||||||
|
config.DisconnectAction, _, _ = GetDwordValue(key, "DisconnectAction")
|
||||||
|
config.AcceptRfbConnections, _, _ = GetDwordValue(key, "AcceptRfbConnections")
|
||||||
|
config.UseVncAuthentication, _, _ = GetDwordValue(key, "UseVncAuthentication")
|
||||||
|
config.UseControlAuthentication, _, _ = GetDwordValue(key, "UseControlAuthentication")
|
||||||
|
config.RepeatControlAuthentication, _, _ = GetDwordValue(key, "RepeatControlAuthentication")
|
||||||
|
config.LoopbackOnly, _, _ = GetDwordValue(key, "LoopbackOnly")
|
||||||
|
config.AcceptHttpConnections, _, _ = GetDwordValue(key, "AcceptHttpConnections")
|
||||||
|
config.EnableFileTransfers, _, _ = GetDwordValue(key, "EnableFileTransfers")
|
||||||
|
config.RemoveWallpaper, _, _ = GetDwordValue(key, "RemoveWallpaper")
|
||||||
|
config.UseD3D, _, _ = GetDwordValue(key, "UseD3D")
|
||||||
|
config.UseMirrorDriver, _, _ = GetDwordValue(key, "UseMirrorDriver")
|
||||||
|
config.EnableUrlParams, _, _ = GetDwordValue(key, "EnableUrlParams")
|
||||||
|
config.Password, _, _ = key.GetBinaryValue("Password")
|
||||||
|
config.AlwaysShared, _, _ = GetDwordValue(key, "AlwaysShared")
|
||||||
|
config.NeverShared, _, _ = GetDwordValue(key, "NeverShared")
|
||||||
|
config.DisconnectClients, _, _ = GetDwordValue(key, "DisconnectClients")
|
||||||
|
config.PollingInterval, _, _ = GetDwordValue(key, "PollingInterval")
|
||||||
|
config.AllowLoopback, _, _ = GetDwordValue(key, "AllowLoopback")
|
||||||
|
config.VideoRecognitionInterval, _, _ = GetDwordValue(key, "VideoRecognitionInterval")
|
||||||
|
config.GrabTransparentWindows, _, _ = GetDwordValue(key, "GrabTransparentWindows")
|
||||||
|
config.SaveLogToAllUsersPath, _, _ = GetDwordValue(key, "SaveLogToAllUsersPath")
|
||||||
|
config.RunControlInterface, _, _ = GetDwordValue(key, "RunControlInterface")
|
||||||
|
config.IdleTimeout, _, _ = GetDwordValue(key, "IdleTimeout")
|
||||||
|
config.VideoClasses, _, _ = key.GetStringValue("VideoClasses")
|
||||||
|
config.VideoRects, _, _ = key.GetStringValue("VideoRects")
|
||||||
|
config.ConnectToRdp, _, _ = GetDwordValue(key, "ExtraPorts")
|
||||||
|
|
||||||
|
return config, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetDwordValue 读取 REG_DWORD 类型注册表值
|
||||||
|
func GetDwordValue(k registry.Key, name string) (val uint32, valtype uint32, err error) {
|
||||||
|
val64 := uint64(0)
|
||||||
|
val64, valtype, err = k.GetIntegerValue(name)
|
||||||
|
val = uint32(val64)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var vncSvcConfig = &service.Config{
|
||||||
|
Name: "tvnserver",
|
||||||
|
DisplayName: "TightVNC Server",
|
||||||
|
Description: "",
|
||||||
|
Arguments: []string{"-service"},
|
||||||
|
}
|
||||||
|
|
||||||
|
// InstallVncServer 安装VNC服务端 返回:结果,密码,错误
|
||||||
|
func InstallVncServer() (bool, string, error) {
|
||||||
|
//安装服务
|
||||||
|
//导入注册表
|
||||||
|
//生成随机密码
|
||||||
|
return true, "12345678", nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// VncInit 初始化 VNC 服务对象,VncInstall/VncStart 等操作前必须调用
|
||||||
|
func VncInit() error {
|
||||||
|
var err error
|
||||||
|
VncService, err = service.New(nil, vncSvcConfig)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// VncInstall 安装 TightVNC 服务
|
||||||
|
func VncInstall() error {
|
||||||
|
err := VncService.Install()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// VncUninstall 停止并卸载 TightVNC 服务
|
||||||
|
func VncUninstall() error {
|
||||||
|
_ = VncService.Stop()
|
||||||
|
err := VncService.Uninstall()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// VncStart 启动 TightVNC 服务
|
||||||
|
func VncStart() error {
|
||||||
|
err := VncService.Start()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// VncStop 停止 TightVNC 服务
|
||||||
|
func VncStop() error {
|
||||||
|
err := VncService.Stop()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// VncRestart 重启 TightVNC 服务
|
||||||
|
func VncRestart() error {
|
||||||
|
err := VncService.Stop()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = VncService.Start()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// VncPasswordCrypt 加密 VNC 密码(TightVNC 注册表存储格式)
|
||||||
|
func VncPasswordCrypt(password string) []byte {
|
||||||
|
return vncpasswd.Crypt(password)
|
||||||
|
}
|
||||||
|
|
||||||
|
// VncPasswordDecrypt 解密 VNC 密码
|
||||||
|
func VncPasswordDecrypt(data []byte) string {
|
||||||
|
return vncpasswd.Decrypt(data)
|
||||||
|
}
|
||||||
@@ -0,0 +1,451 @@
|
|||||||
|
//go:build windows
|
||||||
|
|
||||||
|
package remote
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"crypto/rand"
|
||||||
|
"golang.org/x/sys/windows/registry"
|
||||||
|
"math/big"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GetRemoteInfo 一次性获取远程控制相关信息(服务状态/端口/密码/主机信息)
|
||||||
|
func GetRemoteInfo() Info {
|
||||||
|
info := Info{}
|
||||||
|
|
||||||
|
status, _ := GetVncServiceStatus()
|
||||||
|
info.VncState = int(status)
|
||||||
|
|
||||||
|
status, _ = GetRdpServiceStatus()
|
||||||
|
info.RdpState = int(status)
|
||||||
|
|
||||||
|
port, _ := GetRdpPort()
|
||||||
|
info.RdpPort = port
|
||||||
|
|
||||||
|
port, _ = GetVncPort()
|
||||||
|
info.VncPort = port
|
||||||
|
|
||||||
|
password, _ := GetVncPassword()
|
||||||
|
info.VncPassword = password
|
||||||
|
|
||||||
|
hostname, _ := os.Hostname()
|
||||||
|
info.Hostname = hostname
|
||||||
|
info.IpAddr = getIPs()
|
||||||
|
info.MacAddr = getMacAddrs()
|
||||||
|
|
||||||
|
return info
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetVncPort 从注册表读取 TightVNC 主端口
|
||||||
|
func GetVncPort() (int, error) {
|
||||||
|
var key registry.Key
|
||||||
|
var err error
|
||||||
|
key, err = registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\TightVNC\Server`, registry.ALL_ACCESS)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
var val uint64
|
||||||
|
val, _, err = key.GetIntegerValue("RfbPort")
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
var port int = int(val)
|
||||||
|
return port, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRdpPort 从注册表读取远程桌面端口
|
||||||
|
func GetRdpPort() (int, error) {
|
||||||
|
var key registry.Key
|
||||||
|
var err error
|
||||||
|
key, err = registry.OpenKey(registry.LOCAL_MACHINE, `SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp`, registry.ALL_ACCESS)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
var val uint64
|
||||||
|
val, _, err = key.GetIntegerValue("PortNumber")
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
var port int = int(val)
|
||||||
|
return port, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetVncPassword 读取并解密 TightVNC 连接密码
|
||||||
|
func GetVncPassword() (string, error) {
|
||||||
|
var key registry.Key
|
||||||
|
var err error
|
||||||
|
key, err = registry.OpenKey(registry.LOCAL_MACHINE, `SOFTWARE\TightVNC\Server`, registry.ALL_ACCESS)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
val, _, err := key.GetBinaryValue("Password")
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
if len(val) == 0 {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
password := VncPasswordDecrypt(val)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return password, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// VncServerDefaultConfig 生成 TightVNC 服务端默认配置(连接 RDP 会话)
|
||||||
|
// randPass 为 true 时生成 8 位随机密码,否则使用固定密码
|
||||||
|
func VncServerDefaultConfig(randPass bool) VncServerConfig {
|
||||||
|
password := "tvncpass"
|
||||||
|
if randPass {
|
||||||
|
password = createRandomString(8)
|
||||||
|
}
|
||||||
|
config := VncServerConfig{
|
||||||
|
ExtraPorts: "",
|
||||||
|
QueryTimeout: 30,
|
||||||
|
QueryAcceptOnTimeout: 0,
|
||||||
|
LocalInputPriorityTimeout: 3,
|
||||||
|
LocalInputPriority: 1,
|
||||||
|
BlockRemoteInput: 0,
|
||||||
|
BlockLocalInput: 0,
|
||||||
|
IpAccessControl: "",
|
||||||
|
RfbPort: 5900,
|
||||||
|
HttpPort: 5800,
|
||||||
|
DisconnectAction: 0,
|
||||||
|
AcceptRfbConnections: 1,
|
||||||
|
UseVncAuthentication: 1,
|
||||||
|
UseControlAuthentication: 0,
|
||||||
|
RepeatControlAuthentication: 0,
|
||||||
|
LoopbackOnly: 0,
|
||||||
|
AcceptHttpConnections: 0,
|
||||||
|
LogLevel: 0,
|
||||||
|
EnableFileTransfers: 1,
|
||||||
|
RemoveWallpaper: 1,
|
||||||
|
UseD3D: 1,
|
||||||
|
UseMirrorDriver: 1,
|
||||||
|
EnableUrlParams: 1,
|
||||||
|
Password: VncPasswordCrypt(password),
|
||||||
|
AlwaysShared: 0,
|
||||||
|
NeverShared: 0,
|
||||||
|
DisconnectClients: 1,
|
||||||
|
PollingInterval: 1000,
|
||||||
|
AllowLoopback: 1,
|
||||||
|
VideoRecognitionInterval: 3000,
|
||||||
|
GrabTransparentWindows: 1,
|
||||||
|
SaveLogToAllUsersPath: 0,
|
||||||
|
RunControlInterface: 0,
|
||||||
|
IdleTimeout: 0,
|
||||||
|
VideoClasses: "",
|
||||||
|
VideoRects: "",
|
||||||
|
ConnectToRdp: 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
|
||||||
|
// VncClientDefaultConfig 生成 TightVNC 客户端默认配置(不连接 RDP 会话)
|
||||||
|
// randPass 为 true 时生成 8 位随机密码,否则使用固定密码
|
||||||
|
func VncClientDefaultConfig(randPass bool) VncServerConfig {
|
||||||
|
password := "tvncpass"
|
||||||
|
if randPass {
|
||||||
|
password = createRandomString(8)
|
||||||
|
}
|
||||||
|
config := VncServerConfig{
|
||||||
|
ExtraPorts: "",
|
||||||
|
QueryTimeout: 30,
|
||||||
|
QueryAcceptOnTimeout: 0,
|
||||||
|
LocalInputPriorityTimeout: 3,
|
||||||
|
LocalInputPriority: 1,
|
||||||
|
BlockRemoteInput: 0,
|
||||||
|
BlockLocalInput: 0,
|
||||||
|
IpAccessControl: "",
|
||||||
|
RfbPort: 5900,
|
||||||
|
HttpPort: 5800,
|
||||||
|
DisconnectAction: 0,
|
||||||
|
AcceptRfbConnections: 1,
|
||||||
|
UseVncAuthentication: 1,
|
||||||
|
UseControlAuthentication: 0,
|
||||||
|
RepeatControlAuthentication: 0,
|
||||||
|
LoopbackOnly: 0,
|
||||||
|
AcceptHttpConnections: 0,
|
||||||
|
LogLevel: 0,
|
||||||
|
EnableFileTransfers: 1,
|
||||||
|
RemoveWallpaper: 0,
|
||||||
|
UseD3D: 1,
|
||||||
|
UseMirrorDriver: 1,
|
||||||
|
EnableUrlParams: 1,
|
||||||
|
Password: VncPasswordCrypt(password),
|
||||||
|
AlwaysShared: 0,
|
||||||
|
NeverShared: 0,
|
||||||
|
DisconnectClients: 1,
|
||||||
|
PollingInterval: 1000,
|
||||||
|
AllowLoopback: 1,
|
||||||
|
VideoRecognitionInterval: 3000,
|
||||||
|
GrabTransparentWindows: 1,
|
||||||
|
SaveLogToAllUsersPath: 0,
|
||||||
|
RunControlInterface: 0,
|
||||||
|
IdleTimeout: 0,
|
||||||
|
VideoClasses: "",
|
||||||
|
VideoRects: "",
|
||||||
|
ConnectToRdp: 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
return config
|
||||||
|
}
|
||||||
|
|
||||||
|
// WriteVncServerConfig 将 TightVNC 服务端配置写入注册表(项不存在时自动创建)
|
||||||
|
func WriteVncServerConfig(config VncServerConfig) error {
|
||||||
|
|
||||||
|
key, err := registry.OpenKey(registry.LOCAL_MACHINE, "SOFTWARE\\TightVNC\\Server", registry.ALL_ACCESS)
|
||||||
|
if err != nil {
|
||||||
|
if err == registry.ErrNotExist {
|
||||||
|
// 项不存在 创建它
|
||||||
|
key, _, err = registry.CreateKey(registry.LOCAL_MACHINE, "SOFTWARE\\TightVNC\\Server", registry.ALL_ACCESS)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defer key.Close()
|
||||||
|
|
||||||
|
err = key.SetStringValue("ExtraPorts", config.ExtraPorts)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("QueryTimeout", config.QueryTimeout)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("QueryAcceptOnTimeout", config.QueryAcceptOnTimeout)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("LocalInputPriorityTimeout", config.LocalInputPriorityTimeout)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("LocalInputPriority", config.LocalInputPriority)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("BlockRemoteInput", config.BlockRemoteInput)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("BlockLocalInput", config.BlockLocalInput)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetStringValue("IpAccessControl", config.IpAccessControl)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("RfbPort", config.RfbPort)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("HttpPort", config.HttpPort)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("DisconnectAction", config.DisconnectAction)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("AcceptRfbConnections", config.AcceptRfbConnections)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("UseVncAuthentication", config.UseVncAuthentication)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("UseControlAuthentication", config.UseControlAuthentication)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("RepeatControlAuthentication", config.RepeatControlAuthentication)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("LoopbackOnly", config.LoopbackOnly)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("AcceptHttpConnections", config.AcceptHttpConnections)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("EnableFileTransfers", config.EnableFileTransfers)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("RemoveWallpaper", config.RemoveWallpaper)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("UseD3D", config.UseD3D)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("UseMirrorDriver", config.UseMirrorDriver)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("EnableUrlParams", config.EnableUrlParams)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetBinaryValue("Password", config.Password)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("AlwaysShared", config.AlwaysShared)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("NeverShared", config.NeverShared)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("DisconnectClients", config.DisconnectClients)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("PollingInterval", config.PollingInterval)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("AllowLoopback", config.AllowLoopback)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("VideoRecognitionInterval", config.VideoRecognitionInterval)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("GrabTransparentWindows", config.GrabTransparentWindows)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("SaveLogToAllUsersPath", config.SaveLogToAllUsersPath)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("RunControlInterface", config.RunControlInterface)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("IdleTimeout", config.IdleTimeout)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetStringValue("VideoClasses", config.VideoClasses)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetStringValue("VideoRects", config.VideoRects)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
err = key.SetDWordValue("ConnectToRdp", config.ConnectToRdp)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EnableSoftwareSASGeneration 启用软件SAS模拟输入
|
||||||
|
func EnableSoftwareSASGeneration() error {
|
||||||
|
// SAS模拟输入
|
||||||
|
key, err := registry.OpenKey(registry.LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", registry.ALL_ACCESS)
|
||||||
|
if err != nil {
|
||||||
|
if err == registry.ErrNotExist {
|
||||||
|
// 项不存在 创建它
|
||||||
|
key, _, err = registry.CreateKey(registry.LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", registry.ALL_ACCESS)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defer key.Close()
|
||||||
|
|
||||||
|
err = key.SetDWordValue("SoftwareSASGeneration", 1)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EnableWinlogonDisableCAD 关闭 Ctrl + Alt + Del 组合键来登录
|
||||||
|
func EnableWinlogonDisableCAD() error {
|
||||||
|
key, err := registry.OpenKey(registry.LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", registry.ALL_ACCESS)
|
||||||
|
if err != nil {
|
||||||
|
if err == registry.ErrNotExist {
|
||||||
|
// 项不存在 创建它
|
||||||
|
key, _, err = registry.CreateKey(registry.LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon", registry.ALL_ACCESS)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defer key.Close()
|
||||||
|
|
||||||
|
err = key.SetDWordValue("DisableCAD", 1)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EnableSystemDisableCAD 关闭 Ctrl + Alt + Del 组合键来登录
|
||||||
|
func EnableSystemDisableCAD() error {
|
||||||
|
key, err := registry.OpenKey(registry.LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", registry.ALL_ACCESS)
|
||||||
|
if err != nil {
|
||||||
|
if err == registry.ErrNotExist {
|
||||||
|
// 项不存在 创建它
|
||||||
|
key, _, err = registry.CreateKey(registry.LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", registry.ALL_ACCESS)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defer key.Close()
|
||||||
|
|
||||||
|
err = key.SetDWordValue("DisableCAD", 1)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// createRandomString 生成指定长度的随机字符串
|
||||||
|
func createRandomString(len int) string {
|
||||||
|
var container string
|
||||||
|
var str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"
|
||||||
|
b := bytes.NewBufferString(str)
|
||||||
|
length := b.Len()
|
||||||
|
bigInt := big.NewInt(int64(length))
|
||||||
|
for i := 0; i < len; i++ {
|
||||||
|
randomInt, _ := rand.Int(rand.Reader, bigInt)
|
||||||
|
container += string(str[randomInt.Int64()])
|
||||||
|
}
|
||||||
|
return container
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# shell
|
||||||
|
|
||||||
|
被控端 Web 终端(自 remote-backend-server internal/handlers/shell 移植,去 DB
|
||||||
|
依赖):WebSocket 交互式终端(Windows ConPTY / Unix pty)+ asciinema 会话录制。
|
||||||
|
|
||||||
|
## 路由
|
||||||
|
|
||||||
|
```go
|
||||||
|
import "git.zeroonesoft.cn/golib/remote-core/shell"
|
||||||
|
|
||||||
|
shell.RegisterRoutersWebShell(r *gin.RouterGroup, recDir)
|
||||||
|
```
|
||||||
|
|
||||||
|
| 方法 | 路径 | 说明 |
|
||||||
|
|---|---|---|
|
||||||
|
| GET | `/web/shell` | WebSocket 升级,启动终端(Windows 优先 powershell.exe,缺失回退 cmd.exe;Unix 为 bash) |
|
||||||
|
| GET | `/web/shell/record` | 录制文件列表 |
|
||||||
|
|
||||||
|
## 协议
|
||||||
|
|
||||||
|
WebSocket JSON 信封 `OpDataType{op, data}`:输入/输出流与 `resize`(`ResizeDataType`
|
||||||
|
调整行列)走同一连接。
|
||||||
|
|
||||||
|
## 注意
|
||||||
|
|
||||||
|
- 录制为 asciinema 格式,落盘 `recDir`,可用 asciinema 播放器回放审计。
|
||||||
|
- `CheckOrigin` 放开所有来源(跨域),接入公网必须由网关侧补鉴权。
|
||||||
Reference in New Issue
Block a user