mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Remove metadata-peer association until we have some sensible way to cache it
This commit is contained in:
		
							parent
							
								
									2056e75ad5
								
							
						
					
					
						commit
						64060a447c
					
				
					 4 changed files with 4 additions and 7 deletions
				
			
		| 
						 | 
				
			
			@ -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}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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 {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue