mirror of https://github.com/namecoin/ncdns
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
376 B
Go
29 lines
376 B
Go
package server
|
|
|
|
import "os"
|
|
import "net"
|
|
|
|
var hostname string
|
|
|
|
func init() {
|
|
names, err := net.LookupAddr("127.0.0.1")
|
|
if err != nil || len(names) == 0 {
|
|
hn, err := os.Hostname()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
hostname = hn
|
|
return
|
|
}
|
|
|
|
hostname = names[0]
|
|
}
|
|
|
|
func (s *Server) ServerName() string {
|
|
n := s.cfg.SelfName
|
|
if n == "" {
|
|
n = hostname
|
|
}
|
|
return n
|
|
}
|