1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-12-24 13:43:12 +02:00

localOnly config flag

This commit is contained in:
Chen-I Lim 2021-01-26 15:29:13 -08:00
parent a144fe113d
commit b4e52b4073
5 changed files with 20 additions and 7 deletions

View File

@ -6,5 +6,6 @@
"useSSL": false,
"webpath": "./pack",
"filespath": "./files",
"telemetry": true
"telemetry": true,
"localOnly": true
}

View File

@ -13,6 +13,7 @@
"secret": "this-is-a-secret-string",
"session_expire_time": 2592000,
"session_refresh_time": 18000,
"localOnly": false,
"enableLocalMode": true,
"localModeSocketLocation": "/var/tmp/octo_local.socket"
}

View File

@ -84,7 +84,7 @@ func New(cfg *config.Configuration, singleUser bool) (*Server, error) {
// Init workspace
appBuilder().GetRootWorkspace()
webServer := web.NewServer(cfg.WebPath, cfg.Port, cfg.UseSSL)
webServer := web.NewServer(cfg.WebPath, cfg.Port, cfg.UseSSL, cfg.LocalOnly)
webServer.AddRoutes(wsServer)
webServer.AddRoutes(api)

View File

@ -25,6 +25,7 @@ type Configuration struct {
Secret string `json:"secret" mapstructure:"secret"`
SessionExpireTime int64 `json:"session_expire_time" mapstructure:"session_expire_time"`
SessionRefreshTime int64 `json:"session_refresh_time" mapstructure:"session_refresh_time"`
LocalOnly bool `json:"localonly" mapstructure:"localonly"`
EnableLocalMode bool `json:"enableLocalMode" mapstructure:"enableLocalMode"`
LocalModeSocketLocation string `json:"localModeSocketLocation" mapstructure:"localModeSocketLocation"`
}
@ -40,9 +41,11 @@ func ReadConfigFile() (*Configuration, error) {
viper.SetDefault("DBConfigString", "./octo.db")
viper.SetDefault("WebPath", "./pack")
viper.SetDefault("FilesPath", "./files")
viper.SetDefault("Telemetry", true)
viper.SetDefault("WebhookUpdate", nil)
viper.SetDefault("SessionExpireTime", 60*60*24*30) // 30 days session lifetime
viper.SetDefault("SessionRefreshTime", 60*60*5) // 5 minutes session refresh
viper.SetDefault("LocalOnly", false)
viper.SetDefault("EnableLocalMode", false)
viper.SetDefault("LocalModeSocketLocation", "/var/tmp/octo_local.socket")

View File

@ -23,18 +23,26 @@ type RoutedService interface {
type Server struct {
http.Server
rootPath string
port int
ssl bool
rootPath string
port int
ssl bool
localOnly bool
}
// NewServer creates a new instance of the webserver.
func NewServer(rootPath string, port int, ssl bool) *Server {
func NewServer(rootPath string, port int, ssl bool, localOnly bool) *Server {
r := mux.NewRouter()
var addr string
if localOnly {
addr = fmt.Sprintf(`localhost:%d`, port)
} else {
addr = fmt.Sprintf(`:%d`, port)
}
ws := &Server{
Server: http.Server{
Addr: fmt.Sprintf(`:%d`, port),
Addr: addr,
Handler: r,
},
rootPath: rootPath,