mirror of https://github.com/namecoin/ncdns
refactor
parent
7db179406d
commit
f8ae24af22
@ -1,28 +1,11 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import "os"
|
import denet "github.com/hlandau/degoutils/net"
|
||||||
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 {
|
func (s *Server) ServerName() string {
|
||||||
n := s.cfg.SelfName
|
n := s.cfg.SelfName
|
||||||
if n == "" {
|
if n == "" {
|
||||||
n = hostname
|
n = denet.Hostname()
|
||||||
}
|
}
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue