Skip to content

Commit

Permalink
feat: if service can not found fqdn, replace fqdn with hostname
Browse files Browse the repository at this point in the history
Signed-off-by: Gaius <[email protected]>
  • Loading branch information
gaius-qi committed Jul 5, 2022
1 parent e45cdf5 commit 5c724d2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/net/fqdn/fqdn.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
package fqdn

import (
"os"

"github.com/Showmax/go-fqdn"

logger "d7y.io/dragonfly/v2/internal/dflog"
)

var FQDNHostname string
Expand All @@ -30,7 +34,13 @@ func init() {
func fqdnHostname() string {
fqdn, err := fqdn.FqdnHostname()
if err != nil {
panic(err)
logger.Warnf("can not found fqdn: %s", err.Error())
hostname, err := os.Hostname()
if err != nil {
panic(err)
}

return hostname
}

return fqdn
Expand Down

0 comments on commit 5c724d2

Please sign in to comment.