read configuration file

This commit is contained in:
Xavier Henner
2019-07-08 22:32:12 +02:00
parent 9dc7d19811
commit dd38706b0b
30 changed files with 3621 additions and 24 deletions

View File

28
vendor/github.com/pyke369/golang-support/fqdn/fqdn.go generated vendored Normal file
View File

@@ -0,0 +1,28 @@
package fqdn
import (
"net"
"os"
"strings"
)
func FQDN() (string, string) {
if hostname, err := os.Hostname(); err == nil {
if addresses, err := net.LookupHost(hostname); err != nil {
return hostname, "*"
} else {
for _, address := range addresses {
if hostnames, err := net.LookupAddr(address); err == nil && len(hostnames) > 0 {
for _, hostname := range hostnames {
if strings.Count(hostname, ".") > 1 {
hostname = strings.TrimSuffix(hostname, ".")
addresses, _ = net.LookupHost(hostname)
return hostname, addresses[0]
}
}
}
}
}
}
return "unknown", "*"
}