mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 14:50:56 +00:00
Discovery tracing
This commit is contained in:
parent
d4ef6a6285
commit
52ee7d5724
@ -49,7 +49,8 @@ const (
|
|||||||
|
|
||||||
STTRACE A comma separated string of facilities to trace. The valid
|
STTRACE A comma separated string of facilities to trace. The valid
|
||||||
facility strings:
|
facility strings:
|
||||||
- "scanner" (the file change scanner)`
|
- "scanner" (the file change scanner)
|
||||||
|
- "discover" (the node discovery package)`
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -15,7 +15,6 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
AnnouncementPort = 21025
|
AnnouncementPort = 21025
|
||||||
Debug = false
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Discoverer struct {
|
type Discoverer struct {
|
||||||
@ -111,8 +110,8 @@ func (d *Discoverer) sendAnnouncements() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(srcAddr) == 0 {
|
if len(srcAddr) == 0 {
|
||||||
if Debug {
|
if debug {
|
||||||
log.Println("discover: debug: no source address found on interface", intf.Name)
|
dlog.Println("no source address found on interface", intf.Name)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -131,8 +130,8 @@ func (d *Discoverer) sendAnnouncements() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if Debug {
|
if debug {
|
||||||
log.Println("discover: debug: send announcement from", conn.LocalAddr(), "to", remote, "on", intf.Name)
|
dlog.Println("send announcement from", conn.LocalAddr(), "to", remote, "on", intf.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = conn.WriteTo(buf, remote)
|
_, err = conn.WriteTo(buf, remote)
|
||||||
@ -140,8 +139,8 @@ func (d *Discoverer) sendAnnouncements() {
|
|||||||
// Some interfaces don't seem to support broadcast even though the flags claims they do, i.e. vmnet
|
// Some interfaces don't seem to support broadcast even though the flags claims they do, i.e. vmnet
|
||||||
conn.Close()
|
conn.Close()
|
||||||
|
|
||||||
if Debug {
|
if debug {
|
||||||
log.Println("discover/write: debug:", err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
errCounter++
|
errCounter++
|
||||||
@ -173,8 +172,8 @@ func (d *Discoverer) sendExtAnnouncements() {
|
|||||||
var errCounter = 0
|
var errCounter = 0
|
||||||
|
|
||||||
for errCounter < maxErrors {
|
for errCounter < maxErrors {
|
||||||
if Debug {
|
if debug {
|
||||||
log.Println("send announcement -> ", remote)
|
dlog.Println("send announcement -> ", remote)
|
||||||
}
|
}
|
||||||
_, err = d.conn.WriteTo(buf, remote)
|
_, err = d.conn.WriteTo(buf, remote)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -200,8 +199,8 @@ func (d *Discoverer) recvAnnouncements() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if Debug {
|
if debug {
|
||||||
log.Printf("read announcement:\n%s", hex.Dump(buf[:n]))
|
dlog.Printf("read announcement:\n%s", hex.Dump(buf[:n]))
|
||||||
}
|
}
|
||||||
|
|
||||||
var pkt AnnounceV2
|
var pkt AnnounceV2
|
||||||
@ -212,8 +211,8 @@ func (d *Discoverer) recvAnnouncements() {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if Debug {
|
if debug {
|
||||||
log.Printf("read announcement: %#v", pkt)
|
dlog.Printf("parsed announcement: %#v", pkt)
|
||||||
}
|
}
|
||||||
|
|
||||||
errCounter = 0
|
errCounter = 0
|
||||||
@ -229,8 +228,8 @@ func (d *Discoverer) recvAnnouncements() {
|
|||||||
}
|
}
|
||||||
addrs = append(addrs, nodeAddr)
|
addrs = append(addrs, nodeAddr)
|
||||||
}
|
}
|
||||||
if Debug {
|
if debug {
|
||||||
log.Printf("register: %#v", addrs)
|
dlog.Printf("register: %#v", addrs)
|
||||||
}
|
}
|
||||||
d.registryLock.Lock()
|
d.registryLock.Lock()
|
||||||
_, seen := d.registry[pkt.NodeID]
|
_, seen := d.registry[pkt.NodeID]
|
||||||
@ -287,8 +286,8 @@ func (d *Discoverer) externalLookup(node string) []string {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if Debug {
|
if debug {
|
||||||
log.Printf("read external:\n%s", hex.Dump(buf[:n]))
|
dlog.Printf("read external:\n%s", hex.Dump(buf[:n]))
|
||||||
}
|
}
|
||||||
|
|
||||||
var pkt AnnounceV2
|
var pkt AnnounceV2
|
||||||
@ -298,8 +297,8 @@ func (d *Discoverer) externalLookup(node string) []string {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if Debug {
|
if debug {
|
||||||
log.Printf("read external: %#v", pkt)
|
dlog.Printf("parsed external: %#v", pkt)
|
||||||
}
|
}
|
||||||
|
|
||||||
var addrs []string
|
var addrs []string
|
||||||
|
@ -180,7 +180,7 @@ func (w *Walker) walkAndHashFiles(res *[]File, ign map[string][]string) filepath
|
|||||||
pf.Version++
|
pf.Version++
|
||||||
w.previous[rn] = pf
|
w.previous[rn] = pf
|
||||||
} else if debug {
|
} else if debug {
|
||||||
dlog.Println("unchanged:", p)
|
dlog.Println("unchanged:", rn)
|
||||||
}
|
}
|
||||||
*res = append(*res, pf)
|
*res = append(*res, pf)
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user