From 9f4236ca592b6c65c3ebd59bf900ace8473fb647 Mon Sep 17 00:00:00 2001 From: Lyndsay Roger Date: Sat, 22 Aug 2015 10:48:44 +1200 Subject: [PATCH] Update docs & improve output --- README.md | 5 +++-- crawler.go | 9 +++++---- dns.go | 4 ++-- doc.go | 8 ++++++++ seeder.go | 2 +- 5 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 doc.go diff --git a/README.md b/README.md index e8ccdd6..fe69e59 100644 --- a/README.md +++ b/README.md @@ -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 go install ``` +The binary will then be available in ${HOME}/go/bin + ## Usage diff --git a/crawler.go b/crawler.go index 98ad2b3..d3eab84 100644 --- a/crawler.go +++ b/crawler.go @@ -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) { // 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) { // 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) { 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 diff --git a/dns.go b/dns.go index 8187f82..890885e 100644 --- a/dns.go +++ b/dns.go @@ -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) { } 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 diff --git a/doc.go b/doc.go new file mode 100644 index 0000000..241de5e --- /dev/null +++ b/doc.go @@ -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 diff --git a/seeder.go b/seeder.go index 2e1f4fb..5434e2f 100644 --- a/seeder.go +++ b/seeder.go @@ -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