Rename hostname to nickname

Accept -nickname parameter to weave script
This commit is contained in:
Adam Harrison committed 2015-02-19 17:09:08 +00:00
1 parent 8f6a525bde
commit 244af11701
7 files changed
+46 -38

No files matched your search

+7 -11
View File
@@ -37,7 +37,7 @@ func main() {
justVersion bool
ifaceName string
routerName string
hostName string
nickName string
password string
wait int
debug bool
@@ -50,7 +50,7 @@ func main() {
flag.BoolVar(&justVersion, "version", false, "print version and exit")
flag.StringVar(&ifaceName, "iface", "", "name of interface to read from")
flag.StringVar(&routerName, "name", "", "name of router (defaults to MAC)")
flag.StringVar(&hostName, "hostname", "", "name of host (defaults to kernel hostname)")
flag.StringVar(&nickName, "nickname", "", "nickname of host (defaults to container hostname)")
flag.StringVar(&password, "password", "", "network password")
flag.IntVar(&wait, "wait", 0, "number of seconds to wait for interface to be created and come up (defaults to 0, i.e. don't wait)")
flag.BoolVar(&debug, "debug", false, "enable debug logging")
@@ -89,16 +89,12 @@ func main() {
routerName = iface.HardwareAddr.String()
}
if hostName == "" {
osHostName, err := os.Hostname()
if nickName == "" {
osHostname, err := os.Hostname()
if err != nil {
log.Fatal(err)
}
if osHostName == "" {
hostName = "<unknown>"
} else {
hostName = osHostName
}
nickName = osHostname
}
ourName, err := weave.PeerNameFromUserInput(routerName)
@@ -135,8 +131,8 @@ func main() {
defer profile.Start(&p).Stop()
}
router := weave.NewRouter(iface, ourName, hostName, []byte(password), connLimit, bufSz*1024*1024, logFrame)
log.Println("Our name is", router.Ourself.Name, "(" + hostName + ")")
router := weave.NewRouter(iface, ourName, nickName, []byte(password), connLimit, bufSz*1024*1024, logFrame)
log.Println("Our name is", router.Ourself.Name, "(" + router.Ourself.NickName + ")")
router.Start()
for _, peer := range peers {
if addr, err := net.ResolveTCPAddr("tcp4", weave.NormalisePeerAddr(peer)); err == nil {