|
@@ -9,12 +9,14 @@ package config
|
|
import (
|
|
import (
|
|
"net/url"
|
|
"net/url"
|
|
"os"
|
|
"os"
|
|
|
|
+ "strconv"
|
|
"strings"
|
|
"strings"
|
|
)
|
|
)
|
|
|
|
|
|
type GUIConfiguration struct {
|
|
type GUIConfiguration struct {
|
|
Enabled bool `xml:"enabled,attr" json:"enabled" default:"true"`
|
|
Enabled bool `xml:"enabled,attr" json:"enabled" default:"true"`
|
|
RawAddress string `xml:"address" json:"address" default:"127.0.0.1:8384"`
|
|
RawAddress string `xml:"address" json:"address" default:"127.0.0.1:8384"`
|
|
|
|
+ RawUnixSocketPermissions string `xml:"unixSocketPermissions,omitempty" json:"unixSocketPermissions"`
|
|
User string `xml:"user,omitempty" json:"user"`
|
|
User string `xml:"user,omitempty" json:"user"`
|
|
Password string `xml:"password,omitempty" json:"password"`
|
|
Password string `xml:"password,omitempty" json:"password"`
|
|
AuthMode AuthMode `xml:"authMode,omitempty" json:"authMode"`
|
|
AuthMode AuthMode `xml:"authMode,omitempty" json:"authMode"`
|
|
@@ -59,6 +61,15 @@ func (c GUIConfiguration) Address() string {
|
|
return c.RawAddress
|
|
return c.RawAddress
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func (c GUIConfiguration) UnixSocketPermissions() os.FileMode {
|
|
|
|
+ perm, err := strconv.ParseUint(c.RawUnixSocketPermissions, 8, 32)
|
|
|
|
+ if err != nil {
|
|
|
|
+ // ignore incorrectly formatted permissions
|
|
|
|
+ return 0
|
|
|
|
+ }
|
|
|
|
+ return os.FileMode(perm) & os.ModePerm
|
|
|
|
+}
|
|
|
|
+
|
|
func (c GUIConfiguration) Network() string {
|
|
func (c GUIConfiguration) Network() string {
|
|
if override := os.Getenv("STGUIADDRESS"); strings.Contains(override, "/") {
|
|
if override := os.Getenv("STGUIADDRESS"); strings.Contains(override, "/") {
|
|
url, err := url.Parse(override)
|
|
url, err := url.Parse(override)
|