Skip to content

Commit

Permalink
Check for nil inside the Tun function and return nil when needed (#254)
Browse files Browse the repository at this point in the history
Signed-off-by: Marius Sincovici <[email protected]>
  • Loading branch information
mariusSincovici authored Feb 6, 2024
1 parent 25fa2a2 commit 8fdcbdc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion daemon/vpn/nordlynx/libtelio/libtelio.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,11 @@ func (l *Libtelio) State() vpn.State {
func (l *Libtelio) Tun() tunnel.T {
l.mu.Lock()
defer l.mu.Unlock()
return l.tun
if l.tun != nil {
return l.tun
}

return nil
}

// Enable initiates the tunnel if it is not initiated yet. It can be
Expand Down
5 changes: 4 additions & 1 deletion daemon/vpn/openvpn/openvpn.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,10 @@ func (ovpn *OpenVPN) setTun(tun tunnel.Tunnel) {
func (ovpn *OpenVPN) Tun() tunnel.T {
ovpn.Lock()
defer ovpn.Unlock()
return ovpn.tun
if ovpn.tun != nil {
return ovpn.tun
}
return nil
}

func (ovpn *OpenVPN) setState(arg string) {
Expand Down

0 comments on commit 8fdcbdc

Please sign in to comment.