mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Check tun.config is not equal to nil before usage (#830)
We have to check tun.config is not nil before first use, not after.
This commit is contained in:
		
							parent
							
								
									3613614b41
								
							
						
					
					
						commit
						52345a2de4
					
				
					 1 changed files with 2 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -114,11 +114,11 @@ func (tun *TunAdapter) _start() error {
 | 
			
		|||
	if tun.isOpen {
 | 
			
		||||
		return errors.New("TUN module is already started")
 | 
			
		||||
	}
 | 
			
		||||
	tun.config.RLock()
 | 
			
		||||
	defer tun.config.RUnlock()
 | 
			
		||||
	if tun.config == nil {
 | 
			
		||||
		return errors.New("no configuration available to TUN")
 | 
			
		||||
	}
 | 
			
		||||
	tun.config.RLock()
 | 
			
		||||
	defer tun.config.RUnlock()
 | 
			
		||||
	tun.addr = tun.rwc.Address()
 | 
			
		||||
	tun.subnet = tun.rwc.Subnet()
 | 
			
		||||
	addr := fmt.Sprintf("%s/%d", net.IP(tun.addr[:]).String(), 8*len(address.GetPrefix())-1)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue