mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	Fix Yggdrasil subnet routing
This commit is contained in:
		
							parent
							
								
									bc62af7f7d
								
							
						
					
					
						commit
						2f75075da3
					
				
					 1 changed files with 3 additions and 5 deletions
				
			
		| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
package yggdrasil
 | 
					package yggdrasil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import (
 | 
					import (
 | 
				
			||||||
 | 
						"bytes"
 | 
				
			||||||
	"encoding/hex"
 | 
						"encoding/hex"
 | 
				
			||||||
	"errors"
 | 
						"errors"
 | 
				
			||||||
	"fmt"
 | 
						"fmt"
 | 
				
			||||||
| 
						 | 
					@ -49,15 +50,12 @@ func (c *cryptokey) isValidSource(addr address) bool {
 | 
				
			||||||
	ip := net.IP(addr[:])
 | 
						ip := net.IP(addr[:])
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Does this match our node's address?
 | 
						// Does this match our node's address?
 | 
				
			||||||
	if addr == c.core.router.addr {
 | 
						if bytes.Equal(addr[:16], c.core.router.addr[:16]) {
 | 
				
			||||||
		return true
 | 
							return true
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Does this match our node's subnet?
 | 
						// Does this match our node's subnet?
 | 
				
			||||||
	var subnet net.IPNet
 | 
						if bytes.Equal(addr[:8], c.core.router.subnet[:8]) {
 | 
				
			||||||
	copy(subnet.IP, c.core.router.subnet[:])
 | 
					 | 
				
			||||||
	copy(subnet.Mask, net.CIDRMask(64, 128))
 | 
					 | 
				
			||||||
	if subnet.Contains(ip) {
 | 
					 | 
				
			||||||
		return true
 | 
							return true
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue