Skip to content

Commit

Permalink
add custom dashboard bind address
Browse files Browse the repository at this point in the history
  • Loading branch information
timerever committed Nov 28, 2017
1 parent 0f1005f commit 8c65b33
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
5 changes: 4 additions & 1 deletion conf/frps_full.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions models/config/server_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 8c65b33

Please sign in to comment.