mirror of
https://github.com/cwinfo/yggdrasil-go.git
synced 2024-11-09 17:30:26 +00: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
@ -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…
Reference in New Issue
Block a user