Browse Source

Update docs & improve output

master
Lyndsay Roger 9 years ago
parent
commit
9f4236ca59
  1. 5
      README.md
  2. 9
      crawler.go
  3. 4
      dns.go
  4. 8
      doc.go
  5. 2
      seeder.go

5
README.md

@ -8,8 +8,7 @@ It is based on the original twister-seeder https://github.com/miguelfreitas/twis @@ -8,8 +8,7 @@ It is based on the original twister-seeder https://github.com/miguelfreitas/twis
Also see the associated utility to display information about [non-standard ip addresses](https://github.com/gombadi/nonstd/)
> **NOTE:** This repository is under ongoing development and
is likely to break over time. Use at your own risk.
> **NOTE:** This repository is under ongoing development. Stable releases have been tagged and should be used for production systems.
## Installing
@ -32,6 +31,8 @@ cd dnsseeder @@ -32,6 +31,8 @@ cd dnsseeder
go install
```
The binary will then be available in ${HOME}/go/bin
## Usage

9
crawler.go

@ -30,7 +30,7 @@ func crawlTwistee(tw *Twistee) { @@ -30,7 +30,7 @@ func crawlTwistee(tw *Twistee) {
defer crawlEnd(tw)
if config.debug {
log.Printf("status - start crawl: twistee %s status: %v:%v lastcrawl: %s\n",
log.Printf("debug - start crawl: twistee %s status: %v:%v lastcrawl: %s\n",
net.JoinHostPort(tw.na.IP.String(),
strconv.Itoa(int(tw.na.Port))),
tw.status,
@ -40,6 +40,7 @@ func crawlTwistee(tw *Twistee) { @@ -40,6 +40,7 @@ func crawlTwistee(tw *Twistee) {
// connect to the remote ip and ask them for their addr list
ras, e := crawlIP(tw)
if e != nil {
// update the fact that we have not connected to this twistee
tw.lastTry = time.Now()
@ -67,7 +68,7 @@ func crawlTwistee(tw *Twistee) { @@ -67,7 +68,7 @@ func crawlTwistee(tw *Twistee) {
// no more to do so return which will shutdown the goroutine & call
// the deffered cleanup
if config.verbose {
log.Printf("debug - failed crawl: twistee %s s:r:f: %v:%v:%v %s\n",
log.Printf("status - failed crawl: twistee %s s:r:f: %v:%v:%v %s\n",
net.JoinHostPort(tw.na.IP.String(),
strconv.Itoa(int(tw.na.Port))),
tw.status,
@ -134,14 +135,14 @@ func crawlIP(tw *Twistee) ([]*wire.NetAddress, *CrawlError) { @@ -134,14 +135,14 @@ func crawlIP(tw *Twistee) ([]*wire.NetAddress, *CrawlError) {
conn, err := net.DialTimeout("tcp", dialString, time.Second*10)
if err != nil {
if config.debug {
log.Printf("error - Could not connect to %s - %v\n", ip, err)
log.Printf("debug - Could not connect to %s - %v\n", ip, err)
}
return nil, &CrawlError{"", err}
}
defer conn.Close()
if config.debug {
log.Printf("%s - Connected to remote address. Last connect was %v ago\n", ip, time.Since(tw.lastConnect).String())
log.Printf("debug - Connected to remote address: %s Last connect was %v ago\n", ip, time.Since(tw.lastConnect).String())
}
// set a deadline for all comms to be done by. After this all i/o will error

4
dns.go

@ -151,7 +151,7 @@ func handleDNSStd(w dns.ResponseWriter, r *dns.Msg) { @@ -151,7 +151,7 @@ func handleDNSStd(w dns.ResponseWriter, r *dns.Msg) {
}
if config.verbose {
log.Printf("debug - standard port DNS response to ip: %s Query Type: %s\n", w.RemoteAddr().String(), qtype)
log.Printf("status - DNS response Type: standard To IP: %s Query Type: %s\n", w.RemoteAddr().String(), qtype)
}
// FIXME - add stats and query counts
@ -187,7 +187,7 @@ func handleDNSNon(w dns.ResponseWriter, r *dns.Msg) { @@ -187,7 +187,7 @@ func handleDNSNon(w dns.ResponseWriter, r *dns.Msg) {
}
if config.verbose {
log.Printf("debug - non standard port DNS response to ip: %s Query Type: %s\n", w.RemoteAddr().String(), qtype)
log.Printf("status - DNS response Type: non-standard To IP: %s Query Type: %s\n", w.RemoteAddr().String(), qtype)
}
// FIXME - add stats and query counts

8
doc.go

@ -0,0 +1,8 @@ @@ -0,0 +1,8 @@
/*
This application provides a seeder service to the Twister Network.
http://twister.net.co/
It crawls the Twister Network for active clients and records their ip address and port. It then replies to DNS queries with the ip addresses.
*/
package main

2
seeder.go

@ -255,7 +255,7 @@ func getNonStdIP(rip net.IP, port uint16) net.IP { @@ -255,7 +255,7 @@ func getNonStdIP(rip net.IP, port uint16) net.IP {
encip := net.IPv4(b[0], b[1], b[2], b[3])
if config.debug {
log.Printf("debug encode nonstd - realip: %s port: %v encip: %s crc: %x\n", rip.String(), port, encip.String(), crcAddr)
log.Printf("debug - encode nonstd - realip: %s port: %v encip: %s crc: %x\n", rip.String(), port, encip.String(), crcAddr)
}
return encip

Loading…
Cancel
Save