diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 246498e..e4cfcbc 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -1,33 +1,24 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/go
{
- "name": "NeZha",
- // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
- "image": "mcr.microsoft.com/devcontainers/go:1-1.24-bookworm",
+ "name": "NeZha",
+ "image": "mcr.microsoft.com/devcontainers/go:1-1.24-bookworm",
- // Features to add to the dev container. More info: https://containers.dev/features.
- "features": {
- "ghcr.io/devcontainers/features/docker-in-docker:2": {
- "installDockerBuildx": true,
- "installDockerComposeSwitch": true,
- "version": "latest",
- "dockerDashComposeVersion": "latest"
- }
- },
+ "features": {},
- // Use 'forwardPorts' to make a list of ports inside the container available locally.
- // "forwardPorts": [],
+ // 开启 TUN 后不需要 GOPROXY 也能跑,但保留国内源也没坏处
+ "containerEnv": {
+ "GOPROXY": "https://goproxy.cn,direct",
+ "GOSUMDB": "sum.golang.google.cn"
+ },
- // Use 'postCreateCommand' to run commands after the container is created.
- "postCreateCommand": {
- "Init": "sudo apt update && sudo apt install -y protobuf-compiler && go install github.com/swaggo/swag/cmd/swag@latest && go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest && go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && sudo chmod +x /usr/bin/yq && touch ./cmd/dashboard/user-dist/a && touch ./cmd/dashboard/admin-dist/a && script/bootstrap.sh && script/fetch-frontends.sh",
- "Init_build": "wget https://github.com/goreleaser/goreleaser/releases/download/v2.7.0/goreleaser_2.7.0_amd64.deb && sudo apt install -y ./goreleaser_2.7.0_amd64.deb && rm -rf ./goreleaser_2.7.0_amd64.deb && sudo apt install -y gcc-aarch64-linux-gnu gcc-s390x-linux-gnu mingw-w64",
- "Init_DiD_Buildx": "docker buildx create --name nezha-builder --platform linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/386,linux/arm64,linux/arm/v7,linux/s390x && docker buildx use nezha-builder && docker buildx inspect --bootstrap"
- }
-
- // Configure tool-specific properties.
- // "customizations": {},
-
- // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
- // "remoteUser": "root"
-}
+ "postCreateCommand": {
+ // 【关键修改】
+ // 删除了: rm -rf ../agent/proto && cp -r proto ../agent
+ // 保留了: swagger init, protoc 生成 dashboard 代码, wget 下载工具
+ // 这些命令只在当前目录下操作,绝对安全。
+ "Init": "sudo apt update && sudo apt install -y protobuf-compiler && go install github.com/swaggo/swag/cmd/swag@latest && go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest && go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && swag init --pd -d . -g ./cmd/dashboard/main.go -o ./cmd/dashboard/docs --requiredByDefault && protoc --go-grpc_out=\"require_unimplemented_servers=false:.\" --go_out=\".\" proto/*.proto && sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && sudo chmod +x /usr/bin/yq && touch ./cmd/dashboard/user-dist/a && touch ./cmd/dashboard/admin-dist/a && script/bootstrap.sh && script/fetch-frontends.sh",
+
+ "Init_build": "wget https://github.com/goreleaser/goreleaser/releases/download/v2.7.0/goreleaser_2.7.0_amd64.deb && sudo apt install -y ./goreleaser_2.7.0_amd64.deb && rm -rf ./goreleaser_2.7.0_amd64.deb && sudo apt install -y gcc-aarch64-linux-gnu gcc-s390x-linux-gnu mingw-w64"
+ }
+}
\ No newline at end of file
diff --git a/.devcontainer/devcontainer_old.json b/.devcontainer/devcontainer_old.json
new file mode 100644
index 0000000..246498e
--- /dev/null
+++ b/.devcontainer/devcontainer_old.json
@@ -0,0 +1,33 @@
+// For format details, see https://aka.ms/devcontainer.json. For config options, see the
+// README at: https://github.com/devcontainers/templates/tree/main/src/go
+{
+ "name": "NeZha",
+ // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
+ "image": "mcr.microsoft.com/devcontainers/go:1-1.24-bookworm",
+
+ // Features to add to the dev container. More info: https://containers.dev/features.
+ "features": {
+ "ghcr.io/devcontainers/features/docker-in-docker:2": {
+ "installDockerBuildx": true,
+ "installDockerComposeSwitch": true,
+ "version": "latest",
+ "dockerDashComposeVersion": "latest"
+ }
+ },
+
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
+ // "forwardPorts": [],
+
+ // Use 'postCreateCommand' to run commands after the container is created.
+ "postCreateCommand": {
+ "Init": "sudo apt update && sudo apt install -y protobuf-compiler && go install github.com/swaggo/swag/cmd/swag@latest && go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest && go install google.golang.org/protobuf/cmd/protoc-gen-go@latest && sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && sudo chmod +x /usr/bin/yq && touch ./cmd/dashboard/user-dist/a && touch ./cmd/dashboard/admin-dist/a && script/bootstrap.sh && script/fetch-frontends.sh",
+ "Init_build": "wget https://github.com/goreleaser/goreleaser/releases/download/v2.7.0/goreleaser_2.7.0_amd64.deb && sudo apt install -y ./goreleaser_2.7.0_amd64.deb && rm -rf ./goreleaser_2.7.0_amd64.deb && sudo apt install -y gcc-aarch64-linux-gnu gcc-s390x-linux-gnu mingw-w64",
+ "Init_DiD_Buildx": "docker buildx create --name nezha-builder --platform linux/amd64,linux/amd64/v2,linux/amd64/v3,linux/386,linux/arm64,linux/arm/v7,linux/s390x && docker buildx use nezha-builder && docker buildx inspect --bootstrap"
+ }
+
+ // Configure tool-specific properties.
+ // "customizations": {},
+
+ // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
+ // "remoteUser": "root"
+}
diff --git a/README.md b/README.md
index d16e032..5090c5e 100644
--- a/README.md
+++ b/README.md
@@ -1,115 +1,81 @@
-
-
-

-
-
LOGO designed by 熊大 .
-
-

-
-
-
:trollface: Nezha Monitoring: Self-hostable, lightweight, servers and websites monitoring and O&M tool.
-
Supports monitoring system status, HTTP (SSL certificate change, upcoming expiration, expired), TCP, Ping and supports push alerts, run scheduled tasks and web terminal.
-
+# 哪吒面板 (Nezha Dashboard) - 个人编译指南
+这份文档记录了在 Arch Linux 环境下,使用 VS Code Dev Containers 编译自定义主题版本的哪吒面板的完整流程。
-\>> Official Forum | 官方论坛: [有点意思](https://lajilao.com/c/nezha)
-\>> Telegram Channel: [哪吒监控(中文通知频道)](https://t.me/nezhanews)
+## ⚠️ 核心前置条件 (不做会卡死)
+网络环境:必须开启 TUN 模式 (透明代理)。
-\>> [Use Cases | 我们的用户](https://www.google.com/search?q=%22%E5%93%AA%E5%90%92%E7%9B%91%E6%8E%A7+Nezha+Monitoring%22) (Google)
-\>> Telegram Group: [Nezha Monitoring Global (English Only)](https://t.me/nezhamonitoring_global), [哪吒监控(中文群组)](https://t.me/nezhamonitoring)
+原因:Dev Container 内部的 Go/Apt/Wget 默认不走普通代理,只有宿主机开启 TUN 模式才能让容器内网络畅通无阻。
+工具:v2rayA / NekoRay / Hiddify。
-## User Guide
+环境清理:确保 .devcontainer/devcontainer.json 是纯净版(去除了 docker-in-docker,去除了 sed 换源,去除了 ghproxy)。
-- [English](https://nezhahq.github.io/en_US/index.html)
-- [中文文档](https://nezhahq.github.io/index.html)
+## 🛠️ 编译步骤
+### 1. 进入开发环境
+在 VS Code 中打开本项目,按 F1 -> 选择 Dev Containers: Reopen in Container。 等待容器启动完成。
-## Contributing
+### 2. 准备 GeoIP 数据库
+编译前必须确保 IP 数据库存在,且文件名必须正确。
-### Translation
+```Bash
-
-
-
+# 检查是否存在,没有则下载
+# 注意:必须重命名为 geoip.db,Go 编译器不认 .mmdb 后缀
+if [ ! -f "pkg/geoip/geoip.db" ]; then
+ wget -O pkg/geoip/geoip.db https://github.com/P3TERX/GeoLite.mmdb/raw/download/GeoLite2-Country.mmdb
+fi
+```
-Is Nezha not in your language, or the translation is incorrect or incomplete? Get involved in the translations on [Hosted Weblate](https://hosted.weblate.org/engage/nezha/).
+### 3. 替换自定义前端 (关键)
+我有自定义的 V1 主题,需要手动编译并替换进去,否则编译出来是官方默认皮。
-## Screenshots
+前端项目路径:../nezha-dash-v1 (假设在上一级目录,根据实际调整)
-| 用户前台 [@hamster1963](https://github.com/hamster1963) | 管理后台 [@nezhahq](https://github.com/nezhahq) |
-|---|---|
-|  |  |
-| [hamster1963/nezha-dash](https://github.com/hamster1963/nezha-dash) | [nezhahq/admin-frontend](https://github.com/nezhahq/admin-frontend) |
+后端资源路径:cmd/dashboard/user-dist
-add your theme to [service/singleton/frontend-templates.yaml](service/singleton/frontend-templates.yaml)
+操作命令:
-## Contributors
+```Bash
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+# 1. 清空旧的资源目录
+rm -rf ./nezha_domains/cmd/dashboard/user-dist/*
+rm -rf ./nezha_domains/cmd/dashboard/admin-dist/*
-## Special Thanks
-- [IPInfo](https://ipinfo.io/) for providing an accurate GeoIP Database.
+# 2. 复制自定义的前台主题 (注意 -r 和结尾的 *)
+# 将 nezha-dash-v1/dist 下的所有内容 -> 复制到 user-dist
+cp -r ./nezha-dash-v1/dist/* ./nezha_domains/cmd/dashboard/user-dist/
-## Star History
+# 3. 复制自定义的后台管理 (注意 -r 和结尾的 *)
+# 将 admin-frontend-domain/dist 下的所有内容 -> 复制到 admin-dist
+cp -r ./admin-frontend-domain/dist/* ./nezha_domains/cmd/dashboard/admin-dist/
+```
+### 4. 生成后端代码
+确保 API 文档和 gRPC 代码是最新的。
-[](https://star-history.com/#nezhahq/nezha&Timeline)
+```Bash
+
+# 生成 Swagger 文档
+swag init --pd -d . -g ./cmd/dashboard/main.go -o ./cmd/dashboard/docs --requiredByDefault
+
+# 生成 gRPC 代码
+protoc --go-grpc_out="require_unimplemented_servers=false:." --go_out="." proto/*.proto
+```
+### 5. 最终编译
+生成可执行文件 dashboard。
+
+```Bash
+
+# -s -w: 去除调试符号,减小体积
+go build -ldflags="-s -w" -o dashboard cmd/dashboard/main.go
+```
+## 🚀 快速验证
+编译完成后,运行以下命令测试:
+
+```Bash
+
+# 运行面板
+./dashboard
+
+# 如果能看到 Logo 输出,或者提示 config.yaml 不存在,说明编译成功。
+# 如果提示 user-dist 404 之类的,说明前端文件没复制对。
+```
\ No newline at end of file
diff --git a/dashboard b/dashboard
new file mode 100755
index 0000000..a8d3037
Binary files /dev/null and b/dashboard differ
diff --git a/pkg/geoip/geoip.db b/pkg/geoip/geoip.db
index 1fbe5e3..63d9016 100644
Binary files a/pkg/geoip/geoip.db and b/pkg/geoip/geoip.db differ
diff --git a/proto/nezha.pb.go b/proto/nezha.pb.go
index 0045396..33b7974 100644
--- a/proto/nezha.pb.go
+++ b/proto/nezha.pb.go
@@ -1,6 +1,6 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
-// protoc-gen-go v1.36.9
+// protoc-gen-go v1.36.11
// protoc v3.21.12
// source: proto/nezha.proto
diff --git a/proto/nezha_grpc.pb.go b/proto/nezha_grpc.pb.go
index 0903f04..e2dc453 100644
--- a/proto/nezha_grpc.pb.go
+++ b/proto/nezha_grpc.pb.go
@@ -1,6 +1,6 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
-// - protoc-gen-go-grpc v1.5.1
+// - protoc-gen-go-grpc v1.6.0
// - protoc v3.21.12
// source: proto/nezha.proto
@@ -136,22 +136,22 @@ type NezhaServiceServer interface {
type UnimplementedNezhaServiceServer struct{}
func (UnimplementedNezhaServiceServer) ReportSystemState(grpc.BidiStreamingServer[State, Receipt]) error {
- return status.Errorf(codes.Unimplemented, "method ReportSystemState not implemented")
+ return status.Error(codes.Unimplemented, "method ReportSystemState not implemented")
}
func (UnimplementedNezhaServiceServer) ReportSystemInfo(context.Context, *Host) (*Receipt, error) {
- return nil, status.Errorf(codes.Unimplemented, "method ReportSystemInfo not implemented")
+ return nil, status.Error(codes.Unimplemented, "method ReportSystemInfo not implemented")
}
func (UnimplementedNezhaServiceServer) RequestTask(grpc.BidiStreamingServer[TaskResult, Task]) error {
- return status.Errorf(codes.Unimplemented, "method RequestTask not implemented")
+ return status.Error(codes.Unimplemented, "method RequestTask not implemented")
}
func (UnimplementedNezhaServiceServer) IOStream(grpc.BidiStreamingServer[IOStreamData, IOStreamData]) error {
- return status.Errorf(codes.Unimplemented, "method IOStream not implemented")
+ return status.Error(codes.Unimplemented, "method IOStream not implemented")
}
func (UnimplementedNezhaServiceServer) ReportGeoIP(context.Context, *GeoIP) (*GeoIP, error) {
- return nil, status.Errorf(codes.Unimplemented, "method ReportGeoIP not implemented")
+ return nil, status.Error(codes.Unimplemented, "method ReportGeoIP not implemented")
}
func (UnimplementedNezhaServiceServer) ReportSystemInfo2(context.Context, *Host) (*Uint64Receipt, error) {
- return nil, status.Errorf(codes.Unimplemented, "method ReportSystemInfo2 not implemented")
+ return nil, status.Error(codes.Unimplemented, "method ReportSystemInfo2 not implemented")
}
func (UnimplementedNezhaServiceServer) testEmbeddedByValue() {}
@@ -163,7 +163,7 @@ type UnsafeNezhaServiceServer interface {
}
func RegisterNezhaServiceServer(s grpc.ServiceRegistrar, srv NezhaServiceServer) {
- // If the following call pancis, it indicates UnimplementedNezhaServiceServer was
+ // If the following call panics, it indicates UnimplementedNezhaServiceServer was
// embedded by pointer and is nil. This will cause panics if an
// unimplemented method is ever invoked, so we test this at initialization
// time to prevent it from happening at runtime later due to I/O.