Do not try to close connection if it is not opened in VPNTCPCheck()
This commit is contained in:
11
vpn.go
11
vpn.go
@@ -64,8 +64,6 @@ func UpdateVPNStatus() {
|
|||||||
|
|
||||||
// VPNTCPCheck intended to check arbitrary service inside vpn segment, to indicate that openvpn sevice not stoned.
|
// VPNTCPCheck intended to check arbitrary service inside vpn segment, to indicate that openvpn sevice not stoned.
|
||||||
func VPNTCPCheck() bool {
|
func VPNTCPCheck() bool {
|
||||||
var status bool
|
|
||||||
|
|
||||||
conn, err := net.DialTimeout(
|
conn, err := net.DialTimeout(
|
||||||
"tcp",
|
"tcp",
|
||||||
fmt.Sprintf("%s:%d", Conf.Vpn.TCPCheck.Host, Conf.Vpn.TCPCheck.Port),
|
fmt.Sprintf("%s:%d", Conf.Vpn.TCPCheck.Host, Conf.Vpn.TCPCheck.Port),
|
||||||
@@ -73,14 +71,11 @@ func VPNTCPCheck() bool {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
status = true
|
_ = conn.Close()
|
||||||
} else {
|
return true
|
||||||
status = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_ = conn.Close()
|
return false
|
||||||
|
|
||||||
return status
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// VPNFileCheck checks modification time of openvpn-status file.
|
// VPNFileCheck checks modification time of openvpn-status file.
|
||||||
|
|||||||
Reference in New Issue
Block a user