mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-09 14:50:56 +00:00
Multicast test utility
This commit is contained in:
parent
e4f266883a
commit
b783169c72
@ -86,7 +86,13 @@ func (b *Beacon) run() {
|
||||
if debug {
|
||||
dlog.Printf("recv %d bytes from %s on %s", n, addr, dst.intf)
|
||||
}
|
||||
b.outbox <- recv{bs[:n], addr}
|
||||
select {
|
||||
case b.outbox <- recv{bs[:n], addr}:
|
||||
default:
|
||||
if debug {
|
||||
dlog.Println("Dropping message")
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
31
mc/cmd/mctest/main.go
Normal file
31
mc/cmd/mctest/main.go
Normal file
@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/calmh/syncthing/mc"
|
||||
)
|
||||
|
||||
func main() {
|
||||
b := mc.NewBeacon("239.21.0.25", 21025)
|
||||
go func() {
|
||||
for {
|
||||
bs, addr := b.Recv()
|
||||
log.Printf("Received %d bytes from %s: %x %x", len(bs), addr, bs[:8], bs[8:])
|
||||
}
|
||||
}()
|
||||
go func() {
|
||||
bs := [16]byte{}
|
||||
binary.BigEndian.PutUint64(bs[:], uint64(time.Now().UnixNano()))
|
||||
log.Printf("My ID: %x", bs[:8])
|
||||
for {
|
||||
binary.BigEndian.PutUint64(bs[8:], uint64(time.Now().UnixNano()))
|
||||
b.Send(bs[:])
|
||||
log.Printf("Sent %d bytes", len(bs[:]))
|
||||
time.Sleep(10 * time.Second)
|
||||
}
|
||||
}()
|
||||
select {}
|
||||
}
|
Loading…
Reference in New Issue
Block a user