From 8c65b337cadfffdb570114d7a95e6beda316d9e6 Mon Sep 17 00:00:00 2001 From: timerever <1156594716@qq.com> Date: Tue, 28 Nov 2017 15:56:34 +0800 Subject: [PATCH] add custom dashboard bind address --- conf/frps_full.ini | 5 ++++- models/config/server_common.go | 9 +++++++++ server/service.go | 4 ++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/conf/frps_full.ini b/conf/frps_full.ini index 94f481c..eac8826 100644 --- a/conf/frps_full.ini +++ b/conf/frps_full.ini @@ -19,7 +19,10 @@ kcp_bind_port = 7000 vhost_http_port = 80 vhost_https_port = 443 -# set dashboard_port to view dashboard of frps +# set dashboard_addr and dashboard_port to view dashboard of frps +# dashboard_addr's default value is same with bind_addr +# dashboard is available only if dashboard_port is set +dashboard_addr = 0.0.0.0 dashboard_port = 7500 # dashboard user and pwd for basic auth protect, if not set, both default value is admin diff --git a/models/config/server_common.go b/models/config/server_common.go index 91a9b8b..4d17766 100644 --- a/models/config/server_common.go +++ b/models/config/server_common.go @@ -39,6 +39,7 @@ type ServerCommonConf struct { // if VhostHttpsPort equals 0, don't listen a public port for https protocol VhostHttpsPort int64 + DashboardAddr string // if DashboardPort equals 0, dashboard is not available DashboardPort int64 @@ -72,6 +73,7 @@ func GetDefaultServerCommonConf() *ServerCommonConf { ProxyBindAddr: "0.0.0.0", VhostHttpPort: 0, VhostHttpsPort: 0, + DashboardAddr: "0.0.0.0", DashboardPort: 0, DashboardUser: "admin", DashboardPwd: "admin", @@ -158,6 +160,13 @@ func LoadServerCommonConf(conf ini.File) (cfg *ServerCommonConf, err error) { cfg.VhostHttpsPort = 0 } + tmpStr, ok = conf.Get("common", "dashboard_addr") + if ok { + cfg.DashboardAddr = tmpStr + } else { + cfg.DashboardAddr = cfg.BindAddr + } + tmpStr, ok = conf.Get("common", "dashboard_port") if ok { cfg.DashboardPort, err = strconv.ParseInt(tmpStr, 10, 64) diff --git a/server/service.go b/server/service.go index 7802170..fb99008 100644 --- a/server/service.go +++ b/server/service.go @@ -143,12 +143,12 @@ func NewService() (svr *Service, err error) { // Create dashboard web server. if cfg.DashboardPort > 0 { - err = RunDashboardServer(cfg.BindAddr, cfg.DashboardPort) + err = RunDashboardServer(cfg.DashboardAddr, cfg.DashboardPort) if err != nil { err = fmt.Errorf("Create dashboard web server error, %v", err) return } - log.Info("Dashboard listen on %s:%d", cfg.BindAddr, cfg.DashboardPort) + log.Info("Dashboard listen on %s:%d", cfg.DashboardAddr, cfg.DashboardPort) } return }