Skip to content

Commit 0d6f916

Browse files
authored
Merge pull request #31 from chrisgavin/fix-openvpn-exit
Fix not correctly detecting when OpenVPN has died.
2 parents 0542c59 + 7ce4f75 commit 0d6f916

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

internal/vpn/process.go

+3
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ func (connection *Connection) Started() (bool, error) {
3737
func (connection *Connection) Running() (bool, error) {
3838
processID, err := connection.processID()
3939
if err != nil {
40+
if errors.Is(err, os.ErrNotExist) {
41+
return false, nil
42+
}
4043
return false, err
4144
}
4245

internal/vpn/status.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ type Status struct {
2626
func (connection *Connection) Status() (*Status, error) {
2727
managementConnection, err := connection.managementConnection()
2828
if err != nil {
29-
if _, err := os.Stat(connection.controlSocketPath()); errors.Is(err, os.ErrNotExist) {
29+
if _, err := os.Stat(connection.pidPath()); errors.Is(err, os.ErrNotExist) {
3030
return &Status{State: StateDisconnected}, nil
3131
}
3232
return nil, err
@@ -35,7 +35,7 @@ func (connection *Connection) Status() (*Status, error) {
3535

3636
stateData, err := managementConnection.LatestState()
3737
if err != nil {
38-
if _, err := os.Stat(connection.controlSocketPath()); errors.Is(err, os.ErrNotExist) {
38+
if _, err := os.Stat(connection.pidPath()); errors.Is(err, os.ErrNotExist) {
3939
return &Status{State: StateDisconnected}, nil
4040
}
4141
return nil, errors.Wrap(err, "failed to get latest state")

0 commit comments

Comments
 (0)