mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Modify source address check for CKR
This commit is contained in:
		
							parent
							
								
									7218b5a56c
								
							
						
					
					
						commit
						cfdbc481a5
					
				
					 2 changed files with 7 additions and 6 deletions
				
			
		| 
						 | 
				
			
			@ -99,7 +99,7 @@ func (c *cryptokey) getPublicKeyForAddress(addr address) (boxPubKey, error) {
 | 
			
		|||
	// Check if the address is a valid Yggdrasil address - if so it
 | 
			
		||||
	// is exempt from all CKR checking
 | 
			
		||||
	if addr.isValid() {
 | 
			
		||||
		return
 | 
			
		||||
		return boxPubKey{}, errors.New("Cannot look up CKR for Yggdrasil addresses")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	// Check if there's a cache entry for this addr
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -124,14 +124,11 @@ func (r *router) sendPacket(bs []byte) {
 | 
			
		|||
	}
 | 
			
		||||
	var sourceAddr address
 | 
			
		||||
	var sourceSubnet subnet
 | 
			
		||||
	var dest address
 | 
			
		||||
	var snet subnet
 | 
			
		||||
	copy(sourceAddr[:], bs[8:])
 | 
			
		||||
	copy(sourceSubnet[:], bs[8:])
 | 
			
		||||
	if !sourceAddr.isValid() && !sourceSubnet.isValid() {
 | 
			
		||||
		return
 | 
			
		||||
	}
 | 
			
		||||
	var dest address
 | 
			
		||||
	copy(dest[:], bs[24:])
 | 
			
		||||
	var snet subnet
 | 
			
		||||
	copy(snet[:], bs[24:])
 | 
			
		||||
	if !dest.isValid() && !snet.isValid() {
 | 
			
		||||
		if key, err := r.cryptokey.getPublicKeyForAddress(dest); err == nil {
 | 
			
		||||
| 
						 | 
				
			
			@ -144,6 +141,10 @@ func (r *router) sendPacket(bs []byte) {
 | 
			
		|||
		} else {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		if !sourceAddr.isValid() && !sourceSubnet.isValid() {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	doSearch := func(packet []byte) {
 | 
			
		||||
		var nodeID, mask *NodeID
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue