mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	
						commit
						b455c225fc
					
				
					 2 changed files with 8 additions and 12 deletions
				
			
		| 
						 | 
				
			
			@ -31,7 +31,7 @@ func (s *tunConn) close() {
 | 
			
		|||
}
 | 
			
		||||
 | 
			
		||||
func (s *tunConn) _close_from_tun() {
 | 
			
		||||
	s.conn.Close()
 | 
			
		||||
	go s.conn.Close() // Just in case it blocks on actor operations
 | 
			
		||||
	delete(s.tun.addrToConn, s.addr)
 | 
			
		||||
	delete(s.tun.subnetToConn, s.snet)
 | 
			
		||||
	func() {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -96,7 +96,7 @@ func (c *Conn) setMTU(from phony.Actor, mtu uint16) {
 | 
			
		|||
	c.Act(from, func() { c.mtu = mtu })
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// This should never be called from the router goroutine, used in the dial functions
 | 
			
		||||
// This should never be called from an actor, used in the dial functions
 | 
			
		||||
func (c *Conn) search() error {
 | 
			
		||||
	var err error
 | 
			
		||||
	done := make(chan struct{})
 | 
			
		||||
| 
						 | 
				
			
			@ -118,6 +118,10 @@ func (c *Conn) search() error {
 | 
			
		|||
						sinfo.setConn(nil, c)
 | 
			
		||||
					}
 | 
			
		||||
					c.session = sinfo
 | 
			
		||||
					c.nodeID = crypto.GetNodeID(&c.session.theirPermPub)
 | 
			
		||||
					for i := range c.nodeMask {
 | 
			
		||||
						c.nodeMask[i] = 0xFF
 | 
			
		||||
					}
 | 
			
		||||
					err = e
 | 
			
		||||
					close(done)
 | 
			
		||||
				}
 | 
			
		||||
| 
						 | 
				
			
			@ -133,12 +137,6 @@ func (c *Conn) search() error {
 | 
			
		|||
	if c.session == nil && err == nil {
 | 
			
		||||
		panic("search failed but returned no error")
 | 
			
		||||
	}
 | 
			
		||||
	if c.session != nil {
 | 
			
		||||
		c.nodeID = crypto.GetNodeID(&c.session.theirPermPub)
 | 
			
		||||
		for i := range c.nodeMask {
 | 
			
		||||
			c.nodeMask[i] = 0xFF
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	return err
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -353,10 +351,8 @@ func (c *Conn) LocalAddr() crypto.NodeID {
 | 
			
		|||
 | 
			
		||||
// RemoteAddr returns the complete node ID of the remote side of the connection.
 | 
			
		||||
func (c *Conn) RemoteAddr() crypto.NodeID {
 | 
			
		||||
	// TODO warn that this can block while waiting for the Conn actor to run, so don't call it from other actors...
 | 
			
		||||
	var n crypto.NodeID
 | 
			
		||||
	phony.Block(c, func() { n = *c.nodeID })
 | 
			
		||||
	return n
 | 
			
		||||
	// RemoteAddr is set during the dial or accept, and isn't changed, so it's safe to access directly
 | 
			
		||||
	return *c.nodeID
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// SetDeadline is equivalent to calling both SetReadDeadline and
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue