Fix local announce (IPv6 multicast, include all listen addresses)

This commit is contained in:
Jakob Borg
2014-03-18 17:51:55 +01:00
parent 58fd379e35
commit 8db1bf9732
5 changed files with 125 additions and 120 deletions

View File

@@ -14,7 +14,6 @@ import (
"path"
"runtime"
"runtime/debug"
"strconv"
"strings"
"time"
@@ -263,7 +262,7 @@ func main() {
if verbose {
infoln("Attempting to connect to other nodes")
}
disc := discovery(cfg.Options.ListenAddress[0])
disc := discovery()
go connect(myID, disc, m, tlsCfg, connOpts)
// Routine to pull blocks from other nodes to synchronize the local
@@ -452,24 +451,20 @@ listen:
}
}
func discovery(addr string) *discover.Discoverer {
_, portstr, err := net.SplitHostPort(addr)
fatalErr(err)
port, _ := strconv.Atoi(portstr)
func discovery() *discover.Discoverer {
if !cfg.Options.LocalAnnEnabled {
port = -1
} else if verbose {
infoln("Sending local discovery announcements")
return nil
}
infoln("Sending local discovery announcements")
if !cfg.Options.GlobalAnnEnabled {
cfg.Options.GlobalAnnServer = ""
} else if verbose {
infoln("Sending external discovery announcements")
}
disc, err := discover.NewDiscoverer(myID, port, cfg.Options.GlobalAnnServer)
disc, err := discover.NewDiscoverer(myID, cfg.Options.ListenAddress, cfg.Options.GlobalAnnServer)
if err != nil {
warnf("No discovery possible (%v)", err)