Browse Source

Bug fix for loop on message receive & other fixes

master
Lyndsay Roger 9 years ago
parent
commit
0330c53fa1
  1. 17
      crawler.go
  2. 1
      dnsseeder.go
  3. 2
      server.go

17
crawler.go

@ -14,6 +14,11 @@ import (
// list of currently active addresses // list of currently active addresses
func crawlTwistee(tw *Twistee) { func crawlTwistee(tw *Twistee) {
tw.crawlActive = true
tw.crawlStart = time.Now()
defer crawlEnd(tw)
if config.debug { if config.debug {
log.Printf("status - start crawl: twistee %s status: %v:%v lastcrawl: %s\n", log.Printf("status - start crawl: twistee %s status: %v:%v lastcrawl: %s\n",
net.JoinHostPort(tw.na.IP.String(), net.JoinHostPort(tw.na.IP.String(),
@ -23,11 +28,6 @@ func crawlTwistee(tw *Twistee) {
time.Since(tw.crawlStart).String()) time.Since(tw.crawlStart).String())
} }
tw.crawlActive = true
tw.crawlStart = time.Now()
defer crawlEnd(tw)
// connect to the remote ip and ask them for their addr list // connect to the remote ip and ask them for their addr list
ras, err := crawlIP(tw) ras, err := crawlIP(tw)
if err != nil { if err != nil {
@ -202,6 +202,7 @@ func crawlIP(tw *Twistee) ([]*wire.NetAddress, error) {
return nil, err return nil, err
} }
c := 0
dowhile := true dowhile := true
for dowhile == true { for dowhile == true {
@ -224,10 +225,14 @@ func crawlIP(tw *Twistee) ([]*wire.NetAddress, error) {
} }
} }
} }
// if we get more than 25 messages before the addr we asked for then give up on this client
if c++; c >= 25 {
dowhile = false
}
} }
// should never get here but need a return command // should never get here but need a return command
return nil, nil return nil, errors.New("FIXME - something went wrong and did not get an Addr response")
} }
/* /*

1
dnsseeder.go

@ -150,7 +150,6 @@ func (s *Seeder) startCrawlers() {
} }
// all looks go so start a go routine to crawl the remote twistee // all looks go so start a go routine to crawl the remote twistee
tw.crawlActive = true
go crawlTwistee(tw) go crawlTwistee(tw)
c.started++ c.started++
} }

2
server.go

@ -40,7 +40,7 @@ func updateDNS(s *Seeder) {
for _, tw := range s.theList { for _, tw := range s.theList {
// when we reach max exit // when we reach max exit
if numRR >= 15 { if numRR >= 25 {
break break
} }

Loading…
Cancel
Save