include peer nickname in display output whenever possible
This commit is contained in:
1 parent
1eca5e1097
commit
33520ea230
8 files changed
+29
-25
No files matched your search
@@ -84,17 +84,17 @@ func (conn *RemoteConnection) BreakTie(Connection) ConnectionTieBreak { return T
|
||||
func (conn *RemoteConnection) Shutdown(error) {}
|
||||
|
||||
func (conn *RemoteConnection) Log(args ...interface{}) {
|
||||
log.Println(append(append([]interface{}{}, fmt.Sprintf("->[%s]:", conn.remote.Name)), args...)...)
|
||||
log.Println(append(append([]interface{}{}, fmt.Sprintf("->[%s]:", conn.remote.FullName())), args...)...)
|
||||
}
|
||||
|
||||
func (conn *RemoteConnection) String() string {
|
||||
from := "<nil>"
|
||||
if conn.local != nil {
|
||||
from = conn.local.Name.String()
|
||||
from = conn.local.FullName()
|
||||
}
|
||||
to := "<nil>"
|
||||
if conn.remote != nil {
|
||||
to = conn.remote.Name.String()
|
||||
to = conn.remote.FullName()
|
||||
}
|
||||
return fmt.Sprint("Connection ", from, "->", to)
|
||||
}
|
||||
@@ -223,7 +223,7 @@ func (conn *LocalConnection) ReceivedHeartbeat(remoteUDPAddr *net.UDPAddr, connU
|
||||
if oldRemoteUDPAddr == nil {
|
||||
return conn.sendFastHeartbeats()
|
||||
} else if oldRemoteUDPAddr.String() != remoteUDPAddr.String() {
|
||||
log.Println("Peer", conn.remote.Name, "moved from", old, "to", remoteUDPAddr)
|
||||
log.Println("Peer", conn.remote.FullName(), "moved from", old, "to", remoteUDPAddr)
|
||||
}
|
||||
return nil
|
||||
})
|
||||
@@ -288,7 +288,7 @@ func (conn *LocalConnection) run(actionChan <-chan ConnectionAction, finished ch
|
||||
log.Printf("->[%s] connection shutting down due to error during handshake: %v\n", conn.remoteTCPAddr, err)
|
||||
return
|
||||
}
|
||||
log.Printf("->[%s] completed handshake with %s\n", conn.remoteTCPAddr, conn.remote.Name)
|
||||
log.Printf("->[%s] completed handshake with %s\n", conn.remoteTCPAddr, conn.remote.FullName())
|
||||
|
||||
// We invoke AddConnection in the same goroutine that subsequently
|
||||
// becomes the tcp receive loop, rather than outside, because a)
|
||||
|
||||
@@ -38,7 +38,7 @@ func (peer *LocalPeer) Relay(srcPeer, dstPeer *Peer, df bool, frame []byte, dec
|
||||
if !found {
|
||||
// Not necessarily an error as there could be a race with the
|
||||
// dst disappearing whilst the frame is in flight
|
||||
log.Println("Received packet for unknown destination:", dstPeer.Name)
|
||||
log.Println("Received packet for unknown destination:", dstPeer.FullName())
|
||||
return nil
|
||||
}
|
||||
conn, found := peer.ConnectionTo(relayPeerName)
|
||||
@@ -171,7 +171,7 @@ func (peer *LocalPeer) handleAddConnection(conn Connection) {
|
||||
log.Fatal("Attempt made to add connection to peer with unknown remote peer")
|
||||
}
|
||||
toName := conn.Remote().Name
|
||||
dupErr := fmt.Errorf("Multiple connections to %s added to %s", toName, peer.Name)
|
||||
dupErr := fmt.Errorf("Multiple connections to %s added to %s", conn.Remote().FullName(), peer.FullName())
|
||||
// deliberately non symmetrical
|
||||
if dupConn, found := peer.connections[toName]; found {
|
||||
if dupConn == conn {
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ func (cache *MacCache) String() string {
|
||||
cache.RLock()
|
||||
defer cache.RUnlock()
|
||||
for key, entry := range cache.table {
|
||||
fmt.Fprintf(&buf, "%v -> %s (%v)\n", intmac(key), entry.peer.Name, entry.lastSeen)
|
||||
fmt.Fprintf(&buf, "%v -> %s (%v)\n", intmac(key), entry.peer.FullName(), entry.lastSeen)
|
||||
}
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
+5
-1
@@ -33,7 +33,11 @@ func NewPeer(name PeerName, nickName string, uid uint64, version uint64) *Peer {
|
||||
func (peer *Peer) String() string {
|
||||
peer.RLock()
|
||||
defer peer.RUnlock()
|
||||
return fmt.Sprint("Peer ", peer.Name, " (", peer.NickName, ") (v", peer.version, ") (UID ", peer.UID, ")")
|
||||
return fmt.Sprint("Peer ", peer.FullName(), " (v", peer.version, ") (UID ", peer.UID, ")")
|
||||
}
|
||||
|
||||
func (peer *Peer) FullName() string {
|
||||
return fmt.Sprint(peer.Name, "(", peer.NickName, ")")
|
||||
}
|
||||
|
||||
func (peer *Peer) Version() uint64 {
|
||||
|
||||
+1
-1
@@ -136,7 +136,7 @@ func (peers *Peers) String() string {
|
||||
if !conn.Established() {
|
||||
established = " (unestablished)"
|
||||
}
|
||||
fmt.Fprintf(&buf, " -> %v (%v) [%v%s]\n", conn.Remote().Name, conn.Remote().NickName, conn.RemoteTCPAddr(), established)
|
||||
fmt.Fprintf(&buf, " -> %s [%v%s]\n", conn.Remote().FullName(), conn.RemoteTCPAddr(), established)
|
||||
}
|
||||
})
|
||||
return buf.String()
|
||||
|
||||
+4
-4
@@ -55,11 +55,11 @@ func NewRouter(iface *net.Interface, name PeerName, nickName string, password []
|
||||
BufSz: bufSz,
|
||||
LogFrame: logFrame}
|
||||
onMacExpiry := func(mac net.HardwareAddr, peer *Peer) {
|
||||
log.Println("Expired MAC", mac, "at", peer.Name)
|
||||
log.Println("Expired MAC", mac, "at", peer.FullName())
|
||||
}
|
||||
onPeerGC := func(peer *Peer) {
|
||||
router.Macs.Delete(peer)
|
||||
log.Println("Removed unreachable", peer)
|
||||
log.Println("Removed unreachable peer", peer.FullName())
|
||||
}
|
||||
router.Ourself = NewLocalPeer(name, nickName, router)
|
||||
router.Macs = NewMacCache(macMaxAge, onMacExpiry)
|
||||
@@ -92,7 +92,7 @@ func (router *Router) UsingPassword() bool {
|
||||
|
||||
func (router *Router) Status() string {
|
||||
var buf bytes.Buffer
|
||||
fmt.Fprintln(&buf, "Our name is", router.Ourself.Name, "("+router.Ourself.NickName+")")
|
||||
fmt.Fprintln(&buf, "Our name is", router.Ourself.FullName())
|
||||
fmt.Fprintln(&buf, "Sniffing traffic on", router.Iface)
|
||||
fmt.Fprintf(&buf, "MACs:\n%s", router.Macs)
|
||||
fmt.Fprintf(&buf, "Peers:\n%s", router.Peers)
|
||||
@@ -322,7 +322,7 @@ func (router *Router) handleUDPPacketFunc(dec *EthernetDecoder, po PacketSink) F
|
||||
dstMac := dec.eth.DstMAC
|
||||
|
||||
if router.Macs.Enter(srcMac, srcPeer) {
|
||||
log.Println("Discovered remote MAC", srcMac, "at", srcPeer.Name)
|
||||
log.Println("Discovered remote MAC", srcMac, "at", srcPeer.FullName())
|
||||
}
|
||||
router.LogFrame("Injecting", frame, &dec.eth)
|
||||
checkWarn(po.WritePacket(frame))
|
||||
|
||||
+10
-10
@@ -58,19 +58,19 @@ This produces output like:
|
||||
````
|
||||
weave router 0.7.0
|
||||
Encryption off
|
||||
Our name is 7a:f4:56:87:76:3b (weave01)
|
||||
Our name is 7a:f4:56:87:76:3b(weave01)
|
||||
Sniffing traffic on &{39 65535 ethwe ae:e3:07:9c:8c:d4 up|broadcast|multicast}
|
||||
MACs:
|
||||
ba:8c:b9:dc:e1:c9 -> 7a:f4:56:87:76:3b (2014-10-23 16:39:19.482338935 +0000 UTC)
|
||||
ce:15:34:a9:b5:6d -> 7a:f4:56:87:76:3b (2014-10-23 16:39:28.257103595 +0000 UTC)
|
||||
7a:61:a2:49:4b:91 -> 7a:f4:56:87:76:3b (2014-10-23 16:39:27.482970752 +0000 UTC)
|
||||
9e:95:0c:54:8e:39 -> 7a:16:dd:5b:83:de (2014-10-23 16:39:28.795601325 +0000 UTC)
|
||||
72:5f:a4:60:e5:ce -> 7a:16:dd:5b:83:de (2014-10-23 16:39:29.575995255 +0000 UTC)
|
||||
ba:8c:b9:dc:e1:c9 -> 7a:f4:56:87:76:3b(weave01) (2014-10-23 16:39:19.482338935 +0000 UTC)
|
||||
ce:15:34:a9:b5:6d -> 7a:f4:56:87:76:3b(weave01) (2014-10-23 16:39:28.257103595 +0000 UTC)
|
||||
7a:61:a2:49:4b:91 -> 7a:f4:56:87:76:3b(weave01) (2014-10-23 16:39:27.482970752 +0000 UTC)
|
||||
9e:95:0c:54:8e:39 -> 7a:16:dd:5b:83:de(weave02) (2014-10-23 16:39:28.795601325 +0000 UTC)
|
||||
72:5f:a4:60:e5:ce -> 7a:16:dd:5b:83:de(weave02) (2014-10-23 16:39:29.575995255 +0000 UTC)
|
||||
Peers:
|
||||
Peer 7a:16:dd:5b:83:de (weave02) (v31) (UID 13151318985609435078)
|
||||
-> 7a:f4:56:87:76:3b (weave01) [37.157.33.76:7195]
|
||||
Peer 7a:f4:56:87:76:3b (weave01) (v1) (UID 6913268221365110570)
|
||||
-> 7a:16:dd:5b:83:de (weave02) [191.235.147.190:6783]
|
||||
Peer 7a:16:dd:5b:83:de(weave02) (v31) (UID 13151318985609435078)
|
||||
-> 7a:f4:56:87:76:3b(weave01) [37.157.33.76:7195]
|
||||
Peer 7a:f4:56:87:76:3b(weave01) (v1) (UID 6913268221365110570)
|
||||
-> 7a:16:dd:5b:83:de(weave02) [191.235.147.190:6783]
|
||||
Routes:
|
||||
unicast:
|
||||
7a:f4:56:87:76:3b -> 00:00:00:00:00:00
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ func main() {
|
||||
}
|
||||
|
||||
router := weave.NewRouter(iface, ourName, nickName, pwSlice, connLimit, bufSz*1024*1024, logFrameFunc(debug))
|
||||
log.Println("Our name is", router.Ourself.Name, "("+router.Ourself.NickName+")")
|
||||
log.Println("Our name is", router.Ourself.FullName())
|
||||
router.Start()
|
||||
initiateConnections(router, peers)
|
||||
go handleHTTP(router)
|
||||
|
||||
Reference in new issue
Block a user