Rename externalAddr to addressLister

It's going to have to list internal addresses too.
This commit is contained in:
Jakob Borg 2015-09-13 18:09:12 +02:00
parent e6d5372029
commit 95fc253d6b
2 changed files with 10 additions and 10 deletions

View File

@ -14,13 +14,13 @@ import (
"github.com/syncthing/syncthing/lib/config"
)
type externalAddr struct {
type addressLister struct {
upnpSvc *upnpSvc
cfg *config.Wrapper
}
func newExternalAddr(upnpSvc *upnpSvc, cfg *config.Wrapper) *externalAddr {
return &externalAddr{
func newAddressLister(upnpSvc *upnpSvc, cfg *config.Wrapper) *addressLister {
return &addressLister{
upnpSvc: upnpSvc,
cfg: cfg,
}
@ -31,7 +31,7 @@ func newExternalAddr(upnpSvc *upnpSvc, cfg *config.Wrapper) *externalAddr {
// one or more addresses with an empty IP address (0.0.0.0 or ::) and just
// port number - this means that the outside address of a NAT gateway should
// be substituted.
func (e *externalAddr) ExternalAddresses() []string {
func (e *addressLister) ExternalAddresses() []string {
var addrs []string
// Grab our listen addresses from the config. Unspecified ones are passed

View File

@ -687,7 +687,7 @@ func syncthingMain() {
// The externalAddr tracks our external addresses for discovery purposes.
var extAddr *externalAddr
var addrList *addressLister
// Start UPnP. The UPnP service will restart global discovery if the
// external port changes.
@ -698,14 +698,14 @@ func syncthingMain() {
// The external address tracker needs to know about the UPnP service
// so it can check for an external mapped port.
extAddr = newExternalAddr(upnpSvc, cfg)
addrList = newAddressLister(upnpSvc, cfg)
} else {
extAddr = newExternalAddr(nil, cfg)
addrList = newAddressLister(nil, cfg)
}
// Start discovery
discoverer := discovery(extAddr, relaySvc)
discoverer := discovery(addrList, relaySvc)
// GUI
@ -941,7 +941,7 @@ func shutdown() {
stop <- exitSuccess
}
func discovery(extAddr *externalAddr, relaySvc *relay.Svc) *discover.Discoverer {
func discovery(addrList *addressLister, relaySvc *relay.Svc) *discover.Discoverer {
opts := cfg.Options()
disc := discover.NewDiscoverer(myID, opts.ListenAddress, relaySvc)
if opts.LocalAnnEnabled {
@ -955,7 +955,7 @@ func discovery(extAddr *externalAddr, relaySvc *relay.Svc) *discover.Discoverer
// to relay servers.
time.Sleep(5 * time.Second)
l.Infoln("Starting global discovery announcements")
disc.StartGlobal(opts.GlobalAnnServers, extAddr)
disc.StartGlobal(opts.GlobalAnnServers, addrList)
}()
}