From 64060a447c5301e3ac0602f6730a9b46909fdc08 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Wed, 12 Dec 2018 22:58:16 +0000 Subject: [PATCH] Remove metadata-peer association until we have some sensible way to cache it --- src/yggdrasil/peer.go | 4 +--- src/yggdrasil/router.go | 4 +--- src/yggdrasil/session.go | 1 + src/yggdrasil/tcp.go | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/yggdrasil/peer.go b/src/yggdrasil/peer.go index 4a81cb83..abdfa0ce 100644 --- a/src/yggdrasil/peer.go +++ b/src/yggdrasil/peer.go @@ -86,7 +86,6 @@ type peer struct { shared boxSharedKey linkShared boxSharedKey endpoint string - metadata metadata firstSeen time.Time // To track uptime for getPeers linkOut (chan []byte) // used for protocol traffic (to bypass queues) doSend (chan struct{}) // tell the linkLoop to send a switchMsg @@ -96,14 +95,13 @@ type peer struct { } // Creates a new peer with the specified box, sig, and linkShared keys, using the lowest unocupied port number. -func (ps *peers) newPeer(box *boxPubKey, sig *sigPubKey, linkShared *boxSharedKey, endpoint string, metadata metadata) *peer { +func (ps *peers) newPeer(box *boxPubKey, sig *sigPubKey, linkShared *boxSharedKey, endpoint string) *peer { now := time.Now() p := peer{box: *box, sig: *sig, shared: *getSharedKey(&ps.core.boxPriv, box), linkShared: *linkShared, endpoint: endpoint, - metadata: metadata, firstSeen: now, doSend: make(chan struct{}, 1), core: ps.core} diff --git a/src/yggdrasil/router.go b/src/yggdrasil/router.go index b0655eb6..4914a6b8 100644 --- a/src/yggdrasil/router.go +++ b/src/yggdrasil/router.go @@ -58,9 +58,7 @@ func (r *router) init(core *Core) { r.addr = *address_addrForNodeID(&r.core.dht.nodeID) r.subnet = *address_subnetForNodeID(&r.core.dht.nodeID) in := make(chan []byte, 32) // TODO something better than this... - r.core.sessions.myMetadataMutex.RLock() - p := r.core.peers.newPeer(&r.core.boxPub, &r.core.sigPub, &boxSharedKey{}, "(self)", r.core.sessions.myMetadata) - r.core.sessions.myMetadataMutex.RUnlock() + p := r.core.peers.newPeer(&r.core.boxPub, &r.core.sigPub, &boxSharedKey{}, "(self)") p.out = func(packet []byte) { // This is to make very sure it never blocks select { diff --git a/src/yggdrasil/session.go b/src/yggdrasil/session.go index 6a49d582..31fe375b 100644 --- a/src/yggdrasil/session.go +++ b/src/yggdrasil/session.go @@ -546,6 +546,7 @@ func (ss *sessions) handleMetadata(meta *sessionMeta) { if meta.IsResponse { sinfo.theirMetadata = meta.Metadata sinfo.metaResTime = time.Now() + } else { ss.sendMetadata(sinfo, true) } diff --git a/src/yggdrasil/tcp.go b/src/yggdrasil/tcp.go index dc1e2b16..5ca66304 100644 --- a/src/yggdrasil/tcp.go +++ b/src/yggdrasil/tcp.go @@ -287,7 +287,7 @@ func (iface *tcpInterface) handler(sock net.Conn, incoming bool) { }() // Note that multiple connections to the same node are allowed // E.g. over different interfaces - p := iface.core.peers.newPeer(&info.box, &info.sig, getSharedKey(myLinkPriv, &meta.link), sock.RemoteAddr().String(), metadata{}) + p := iface.core.peers.newPeer(&info.box, &info.sig, getSharedKey(myLinkPriv, &meta.link), sock.RemoteAddr().String()) p.linkOut = make(chan []byte, 1) in := func(bs []byte) { p.handlePacket(bs)