feat: if service can not found fqdn, replace fqdn with hostname (#1435)

Signed-off-by: Gaius <gaius.qi@gmail.com>
This commit is contained in:
Gaius 2022-07-05 16:19:05 +08:00
parent f68ce30f26
commit 9eaf08a193
No known key found for this signature in database
GPG Key ID: 8B4E5D1290FA2FFB
1 changed files with 11 additions and 1 deletions

View File

@ -17,7 +17,11 @@
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
}