Permalink
Browse files

Handle Inactivity timeout in fruhod daemon. kill-ovpn-by-saved-pid re…

…factoring
  • Loading branch information...
hypatia2 committed Apr 18, 2016
1 parent f85416c commit 78a14be43333a1e1a7d9d5ff8170f248e7e24c0b
Showing with 20 additions and 4 deletions.
  1. +20 −4 fruhod/main.tcl
@@ -249,6 +249,21 @@ proc load-config {conf} {
return ""
}
proc kill-ovpn-by-saved-pid {} {
set ovpnpid [ovpn-pid]
if {$ovpnpid != 0} {
if {[catch {exec kill $ovpnpid} out err]} {
log "kill $ovpnpid failed"
log $out \n $err
} else {
log "killed ovpn with pid $ovpnpid"
}
}
}
proc ffread {} {
try {
set sock $::model::Ffconn_sock
@@ -266,10 +281,7 @@ proc ffread {} {
switch -regexp -matchvar tokens $line {
{^stop$} {
if {[ovpn-pid] != 0} {
if {[catch {exec kill [ovpn-pid]} out err]} {
log "kill [ovpn-pid] failed"
log $out \n $err
}
kill-ovpn-by-saved-pid
OvpnExit 0
} else {
ffwrite ctrl "Nothing to be stopped"
@@ -440,6 +452,10 @@ proc OvpnRead {line} {
{SIGTERM.*received, process exiting} {
OvpnExit 0
}
{Inactivity timeout.*restarting} {
kill-ovpn-by-saved-pid
OvpnExit 0
}
{PUSH: Received control message} {
# We need to handle PUSH commands from the openvpn server. Primarily DNS because we need to change resolv.conf
#PUSH: Received control message: 'PUSH_REPLY,redirect-gateway def1 bypass-dhcp,dhcp-option DNS 10.10.0.1,route 10.10.0.1,topology net30,ping 5,ping-restart 28,ifconfig 10.10.0.66 10.10.0.65'

0 comments on commit 78a14be

Please sign in to comment.