Commit Graph
34 Commits
Author SHA1 Message Date
naibaandnaiba/CloudCode 3f6de265a0 fix(mcp): harden dashboard dispatch lifecycle
Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
2026-07-20 04:32:16 +00:00
naiba 083bc985c5 feat(auth): split inventory scope out of server scope
Carve a new nezha:inventory:{read,delete,*} resource family out of
nezha:server:*. Listing and deleting servers/server-groups (GET /server,
/server-group, /ws/server, batch-delete/server[-group], MCP server.list)
now require nezha:inventory:*, while nezha:server:* covers per-server
runtime operations (get, exec, fs, config, metrics, batch-move,
force-update).

Also declare MCP tool OutputSchema for exec/fs/meta/server/transfer and
wrap server.list output in {servers,count} so strict MCP clients accept
the structured result. Correct the /file all-of scope entry and the stale
server:read documentation.
2026-05-31 15:14:41 +00:00
naibaandcloudcode e8dabf5bc6 feat(auth): add PAT auth, scoped REST/MCP access, CSRF, and tenant isolation
Introduce Personal Access Tokens (nzp_*) as a stateless auth path alongside
JWT, gated per-endpoint by a scope middleware (nezha:{resource}:{verb}) with
fail-closed empty-scope defaults and a server-id whitelist. Self-management
endpoints (profile, api-tokens, oauth2 bind, refresh-token) explicitly reject
PATs to block privilege-escalation chains. A revoke registry tears down active
long-lived connections (terminal, fm, ws, transfer, mcp) the moment a PAT is
deleted, with a tombstone closing the revoke->register race.

Add an MCP endpoint that proxies tool calls (exec, fs read/write/delete,
transfer) to agents over gRPC, guarded by origin/DNS-rebinding checks, a
per-token rate limiter, audit logging, and a kill switch. Serialize all
sends through the IOStream wrapper to honour grpc-go's concurrency contract.

Add CSRF double-submit protection on unsafe cookie-authenticated methods,
exempting authenticated PAT requests by context identity (not a forgeable
Authorization header). Apply visibility/whitelist filtering consistently
across list, get-by-id, and mutate paths to enforce tenant isolation.

Migrate legacy mcp:* scopes: rewrite read/exec to nezha:* equivalents and
drop dangerous write/delete/wildcard grants.

Co-authored-by: cloudcode <cloudcode@users.noreply.github.com>
2026-05-30 15:56:44 +00:00
naiba 6b88cdb012 feat: server transfer rotation 2026-05-25 10:17:34 +00:00
naibaandnaiba/CloudCode 097d4f7382 fix(controller): hide foreign server IDs from forceUpdateServer response
The previous loop only checked ownership inside the
\`server != nil && server.TaskStream != nil\` branch. A foreign online
server returned permission denied for the whole batch while foreign
offline / unknown IDs silently went into the Offline bucket — the
response-shape delta let a RoleMember enumerate other users' online
server IDs by submitting them in batches.

Drop both foreign and unknown IDs silently into the Offline bucket
(without dispatching the upgrade task) so the response is indistinguishable
across those three states.

Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
2026-05-18 15:16:59 +00:00
naibaandnaiba/CloudCode 2a65a7db80 fix(controller): enforce ownership on notification group, NAT server, and batch move
Co-authored-by: naiba/CloudCode <hi+cloudcode@nai.ba>
2026-05-17 10:24:19 +08:00
3d0c9b963c feat(v2.0.0): tsdb (#1162)
* feat: tsdb

* fix(ci): remove --parseGoList=false from swag init to fix dependency resolution

* fix(ci): fix swag init directory and temporary remove s390x support due to cgo issues

* fix(ci): fix swag init output directory to cmd/dashboard/docs

* fix(ci): set GOTOOLCHAIN=auto for gosec

* feat: add system storage maintenance for SQLite and TSDB

* shit

* feat: add s390x support and improve service monitoring

* ci: upgrade goreleaser-cross image to v1.25

* ci: add libzstd-dev:s390x for cross-compilation

* ci: build libzstd for s390x from source

* ci: add libzstd_linux_s390x.go for gozstd linking

* ci: use vendor mode for s390x gozstd build

* ci: clone zstd source for s390x build

* refactor(tsdb): rename MaxDiskUsageGB to MinFreeDiskSpaceGB and optimize queries

- Rename config to accurately reflect VictoriaMetrics behavior: minimum free disk space threshold
- Add QueryServiceHistoryByServerID for batch query optimization
- Fix hasStatus to avoid false status counting when only delay data exists
- Fix service aggregation boundary: use successCount*2 >= count
- Fix serviceID parsing with strconv.ParseUint error handling
- Add TagFiltersCacheSize for better query performance

* feat(api): add server metrics endpoint and simplify service history response

- Add /server/:id/metrics API for querying TSDB server metrics
- Simplify getServiceHistory by removing redundant data conversion
- Change AvgDelay type from float32 to float64
- Remove generated swagger docs (to be regenerated)
- Update TSDB query, writer and tests

* chore: 临时禁用不支持前端

* ci: cache zstd build for s390x to speed up CI

* fix(tsdb): fix race conditions, data correctness and optimize performance

- Fix TOCTOU race between IsClosed() and write/query by holding RLock
- Fix delay=0 excluded from stats by using hasDelay flag instead of value > 0
- Fix fmt.Sscanf -> strconv.ParseUint for server_id parsing with error logging
- Fix buffer unbounded growth by flushing inside lock when over maxSize
- Split makeMetricRow into makeServerMetricRow/makeServiceMetricRow
- Extract InitGlobalSettings() from Open() for VictoriaMetrics globals
- Remove redundant instance/GetInstance/SetInstance singleton
- Add error logging for silently skipped block decode errors
- Optimize WriteBatch* to build all rows in single write call
- Optimize downsample to use linear scan instead of map for sorted data
- Optimize query slice reuse across block iterations

* 服务添加DisplayIndex (#1166)

* 服务添加DisplayIndex

* 根据ai建议修改

---------

Co-authored-by: huYang <306061454@qq.com>

* fix(tsdb): restore SQLite fallback and monthly status reload on restart

- Restore ServiceHistory model and SQLite write fallback when TSDB is disabled
- Reload monthlyStatus (30-day) and serviceStatusToday from TSDB/SQLite on startup
- Add SQLite fallback query for /service/:id/history and /server/:id/service
- Remove breaking GET /service/:id endpoint, keep /service/:id/history only
- Add QueryServiceDailyStats to TSDB for per-day aggregation
- Add tests for monthly status and today stats loading from both TSDB and SQLite
- Migrate ServiceHistory table only when TSDB is disabled

* ci: exclude false-positive gosec rules G117, G703, G704

* feat(api): expose tsdb_enabled in setting response

* ci: restore G115 exclusion accidentally dropped in previous commit

* fix: update version numbers for OfficialAdmin and Official templates

* chore: upgrade frontend

* chore: upgrade frontend

---------

Co-authored-by: 胡说丷刂 <34758853+laosan-xx@users.noreply.github.com>
Co-authored-by: huYang <306061454@qq.com>
2026-02-15 13:13:33 +08:00
UUBulb e0133a015c fix: use server ids in db query (#1146) 2025-12-04 21:51:33 +08:00
naiba 233bbc23b6 feat: 批量转移服务器给其他用户 2025-06-16 23:46:36 +08:00
UUBulb 043d6c4097 feat: update to go1.24 & support listening https (#1002)
* feat: support listening https

* refactor

* modernize

* support snake case in config

* more precise control of config fields

* update goreleaser config

* remove kubeyaml

* fix: expose agent_secret

* chore
2025-02-28 22:02:54 +08:00
UUBulb ea068d4db1 refactor: simplify server & service manipulation (#993)
* refactor: simplify server & service manipulation

* update

* fix

* update for nat, ddns & notification

* chore

* update cron

* update dependencies

* use of function iterators

* update default dns servers
2025-02-21 23:08:12 +08:00
UUBulb eeb96caf4d feat: batch set server config (#983)
* feat: batch set server config

* run in parallel

* fix route

* fix

* return some information

* fix order
2025-02-04 11:25:49 +08:00
UUBulb b75a49c3c6 feat: edit server config online (#980)
* feat: edit server config online

* clean

* refactor

* generate template

* fix deadlocks

* fix
2025-01-31 13:33:53 +08:00
UUBulb 2a6206f1a9 ddns: allow overriding domains per configuration (#979) 2025-01-30 12:19:40 +08:00
UUBulb fa30df0320 feat: support id query for "list" apis (#908)
* feat: support id query for "list" apis

* gosec
2024-12-24 23:23:01 +08:00
UUBulb dc0132c9aa feat: user roles (#852)
* [WIP] feat: user roles

* update

* update

* admin handler

* update

* feat: user-specific connection secret

* simplify some logics

* cleanup

* update waf

* update user api error handling

* update waf api

* fix codeql

* update waf table

* fix several problems

* add pagination for waf api

* update permission checks

* switch to runtime check

* 1

* cover?

* some changes
2024-12-22 00:05:41 +08:00
UUBulb 8f173f70cb fix server deletion api, add issue templates (#526)
* add issue templates

* fix: server deletion api
2024-12-01 23:45:26 +08:00
naiba a7e4fe0909 rename repo 2024-11-28 19:38:54 +08:00
UUBulb e465134c11 update profile api (#16)
* update profile api

* rename

* fix realip assertion

* add waf api
2024-11-23 16:22:22 +08:00
UUBulb 13810bb38b report geoip separately, fix server creation & deletion bugs (#14)
* new geoip method

* report geoip separately, fix server creation & deletion bugs

* fix struct tag

* fix write name

* remove deleteion list

* remove rpc realip header

* Revert "remove rpc realip header"

This reverts commit 8a5f86cf2d7df87f28cfa2a3b3430f449dd6ed73.
2024-11-22 22:40:43 +08:00
UUBulb 1c3fd9af1c add force update server api (#13) 2024-11-20 21:36:21 +08:00
uubulb d56224a118 feat: add i18n support 2024-11-01 05:07:04 +08:00
UUBulb 8bfe70d519 add cron, nat api & refactor alert rule (#459)
* add cron api & refactor alert rule

* add nat api

* fix swagger

* remove unnecessary steps
2024-10-26 23:57:47 +08:00
UUBulb d742b605a5 fix swaggo (#454) 2024-10-24 14:11:06 +08:00
UUBulb 8b24a30bee fix list apis (#453) 2024-10-24 10:21:59 +08:00
naiba 69799c28d4 🚀 monitor api 2024-10-23 23:06:11 +08:00
naiba dd41017634 💄 refactor common handler 2024-10-23 17:56:51 +08:00
naiba c369f9cba4 feat: list server api 2024-10-23 17:34:15 +08:00
naiba c706950ecc feat: create user, read users, batch delete users 2024-10-22 21:19:30 +08:00
UUBulb 08dea15cbf use plain error type for expected behaviors (#447) 2024-10-22 10:25:45 +08:00
naiba 821baba639 feat: server group api 2024-10-21 23:00:51 +08:00
UUBulb ec83ff0617 dev: add ddns list api (#445) 2024-10-21 16:22:30 +08:00
UUBulb 4061b847b2 dev: add ddns create, edit and batch delete api (#444) 2024-10-21 14:30:50 +08:00
naiba 80740ddf39 refactor agent auth & server api 2024-10-20 23:23:04 +08:00