diff --git a/defs/config.go b/defs/config.go index 78dab415..50316d40 100644 --- a/defs/config.go +++ b/defs/config.go @@ -197,6 +197,10 @@ const ( // The prefix for all server configuration keys. ServerKeyPrefix = PrivilegedKeyPrefix + "server." + // If true, the REST payload will report the fully-qualified domain name for + // the server. Otherwise, the "shortname" is used, which is the default case. + ServerReportFQDNSetting = ServerKeyPrefix + "report.fqdn" + // The default user if no userdatabase has been initialized yet. This is a // string of the form "user:password", which is defined as the root user. DefaultCredentialSetting = ServerKeyPrefix + "default.credential" @@ -368,6 +372,7 @@ var ValidSettings map[string]bool = map[string]bool{ PrecisionErrorSetting: true, UnusedVarsSetting: true, UnusedVarLoggingSetting: true, + ServerReportFQDNSetting: true, } // RestrictedSettings is a list of settings that cannot be read using the diff --git a/runtime/profile/initialization.go b/runtime/profile/initialization.go index 5edffbab..cbc39068 100644 --- a/runtime/profile/initialization.go +++ b/runtime/profile/initialization.go @@ -45,6 +45,7 @@ func InitProfileDefaults() error { defs.StaticTypesSetting: defs.Dynamic, defs.UnusedVarsSetting: defs.True, defs.UnusedVarLoggingSetting: defs.False, + defs.ServerReportFQDNSetting: defs.False, defs.OutputFormatSetting: ui.TextFormat, defs.ExtensionsEnabledSetting: defs.False, defs.UseReadline: defs.True, diff --git a/tools/buildver.txt b/tools/buildver.txt index db3be4e7..747b6c83 100644 --- a/tools/buildver.txt +++ b/tools/buildver.txt @@ -1 +1 @@ -1.5-1185 +1.5-1186 diff --git a/util/strings.go b/util/strings.go index 27188f31..81e8d71f 100644 --- a/util/strings.go +++ b/util/strings.go @@ -6,7 +6,9 @@ import ( "sort" "strings" + "github.com/tucats/ego/app-cli/settings" "github.com/tucats/ego/data" + "github.com/tucats/ego/defs" ) // Hostname gets a short form of the host namme (i.e. the first part of an FQDN). @@ -15,15 +17,13 @@ func Hostname() string { if hostName, err := os.Hostname(); err == nil { // If this is a multipart name, use only the first part. // If this is not a multipart name, return the entire name. - // Note: This assumes that the FQDN will not contain multiple + // Note: This assumes that the FQDN will contain multiple // dots, which is a common scenario. - if strings.Count(hostName, ".") > 1 { - parts := strings.SplitN(hostName, ".", 2) - - return parts[0] - } else { - return hostName + if !settings.GetBool(defs.ServerReportFQDNSetting) { + hostName = strings.SplitN(hostName, ".", 2)[0] } + + return hostName } else { return "" }