feat: if service can not found fqdn, replace fqdn with hostname
package fqdn
import (
+ "os"
+
"github.com/Showmax/go-fqdn"
+
+ logger "d7y.io/dragonfly/v2/internal/dflog"
)
var FQDNHostname string
@@ -29,9 +33,15 @@ func init() {
// Get FQDN hostname
func fqdnHostname() string {
fqdn, err := fqdn.FqdnHostname()
+ if err != nil {
+ logger.Warnf("can not found fqdn: %s", err.Error())
+ hostname, err := os.Hostname()
if err != nil {
panic(err)
}
+ return hostname
+ }
+
return fqdn
}
