diff --git a/cmd/dashboard/main.go b/cmd/dashboard/main.go index 16982f0..3b6026b 100644 --- a/cmd/dashboard/main.go +++ b/cmd/dashboard/main.go @@ -2,6 +2,7 @@ package main import ( "context" + "github.com/naiba/nezha/util" "log" "time" @@ -46,6 +47,9 @@ func init() { if dao.Conf.GRPCPort == 0 { dao.Conf.GRPCPort = 5555 } + if dao.Conf.GRPCHost == "" { + dao.Conf.GRPCHost = util.FetchGeoIP(false).IP + } dao.Cache = cache.New(5*time.Minute, 10*time.Minute) initSystem() diff --git a/model/config.go b/model/config.go index e2b9c13..0c32d2d 100644 --- a/model/config.go +++ b/model/config.go @@ -39,6 +39,7 @@ type Config struct { } HTTPPort uint GRPCPort uint + GRPCHost string EnableIPChangeNotification bool // IP变更提醒 diff --git a/resource/static/main.js b/resource/static/main.js index 35a442e..f1e2162 100644 --- a/resource/static/main.js +++ b/resource/static/main.js @@ -155,7 +155,7 @@ function addOrEditNotification(notification) { ); } -function addOrEditServer(server) { +function addOrEditServer(server, conf) { const modal = $(".server.modal"); modal.children(".header").text((server ? "修改" : "添加") + "服务器"); modal @@ -172,9 +172,14 @@ function addOrEditServer(server) { modal.find("textarea[name=Note]").val(server ? server.Note : null); if (server) { modal.find(".secret.field").attr("style", ""); + modal.find(".command.field").attr("style", ""); + modal.find(".command.hostSecret").text(server.Secret); + modal.find(".command.GRPCHost").text(conf.GRPCHost); + modal.find(".command.GRPCPort").text(conf.GRPCPort); modal.find("input[name=secret]").val(server.Secret); } else { modal.find(".secret.field").attr("style", "display:none"); + modal.find(".command.field").attr("style", "display:none"); modal.find("input[name=secret]").val(""); } showFormModal(".server.modal", "#serverForm", "/api/server"); diff --git a/resource/template/component/server.html b/resource/template/component/server.html index ff29c47..bd95a6b 100644 --- a/resource/template/component/server.html +++ b/resource/template/component/server.html @@ -32,7 +32,7 @@ Shell(推荐)
- curl -L https://raw.githubusercontent.com/naiba/nezha/master/script/install.sh -o nezha.sh && chmod +x nezha.sh && sudo ./nezha.sh 5555 + curl -L https://raw.githubusercontent.com/cloverzrg/nezha/master/script/install.sh -o nezha.sh && chmod +x nezha.sh && sudo ./nezha.sh
diff --git a/resource/template/dashboard/server.html b/resource/template/dashboard/server.html index 3972c9c..902f2e8 100644 --- a/resource/template/dashboard/server.html +++ b/resource/template/dashboard/server.html @@ -35,7 +35,7 @@ {{$server.Note}}
-