Browse Source

add custom dashboard bind address

pull/539/head
timerever 7 years ago
parent
commit
8c65b337ca
  1. 5
      conf/frps_full.ini
  2. 9
      models/config/server_common.go
  3. 4
      server/service.go

5
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

9
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)

4
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
}

Loading…
Cancel
Save