mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	Fix isOpen for TUN/TAP actor
This commit is contained in:
		
							parent
							
								
									d37133e311
								
							
						
					
					
						commit
						cd93969930
					
				
					 1 changed files with 9 additions and 2 deletions
				
			
		| 
						 | 
					@ -143,9 +143,12 @@ func (tun *TunAdapter) Start() error {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (tun *TunAdapter) _start() error {
 | 
					func (tun *TunAdapter) _start() error {
 | 
				
			||||||
 | 
						if tun.isOpen {
 | 
				
			||||||
 | 
							return errors.New("TUN/TAP module is already started")
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	current := tun.config.GetCurrent()
 | 
						current := tun.config.GetCurrent()
 | 
				
			||||||
	if tun.config == nil || tun.listener == nil || tun.dialer == nil {
 | 
						if tun.config == nil || tun.listener == nil || tun.dialer == nil {
 | 
				
			||||||
		return errors.New("No configuration available to TUN/TAP")
 | 
							return errors.New("no configuration available to TUN/TAP")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	var boxPub crypto.BoxPubKey
 | 
						var boxPub crypto.BoxPubKey
 | 
				
			||||||
	boxPubHex, err := hex.DecodeString(current.EncryptionPublicKey)
 | 
						boxPubHex, err := hex.DecodeString(current.EncryptionPublicKey)
 | 
				
			||||||
| 
						 | 
					@ -182,7 +185,11 @@ func (tun *TunAdapter) _start() error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// IsStarted returns true if the module has been started.
 | 
					// IsStarted returns true if the module has been started.
 | 
				
			||||||
func (tun *TunAdapter) IsStarted() bool {
 | 
					func (tun *TunAdapter) IsStarted() bool {
 | 
				
			||||||
	return tun.isOpen
 | 
						var isOpen bool
 | 
				
			||||||
 | 
						phony.Block(tun, func() {
 | 
				
			||||||
 | 
							isOpen = tun.isOpen
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						return isOpen
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Start the setup process for the TUN/TAP adapter. If successful, starts the
 | 
					// Start the setup process for the TUN/TAP adapter. If successful, starts the
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue