diff options
-rw-r--r-- | etc/inc/openvpn.inc | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/etc/inc/openvpn.inc b/etc/inc/openvpn.inc index 25d54c5..c2d2e28 100644 --- a/etc/inc/openvpn.inc +++ b/etc/inc/openvpn.inc @@ -361,19 +361,26 @@ function openvpn_reconfigure($mode, $id) { * be sure to change it even on the openvpn command parameters at * openvpn_restart() function. */ + + if ($mode == "client") + $ovpndevice = "ovpnc{$id}"; + else + $ovpndevice = "ovpn{$id}"; + if (!$g['booting']) - mwexec("/sbin/ifconfig ovpn{$id} destroy"); - mwexec("/sbin/ifconfig tun{$id} create"); - mwexec("/sbin/ifconfig tun{$id} name ovpn{$id}"); - mwexec("/sbin/ifconfig ovpn{$id} group openvpn"); + mwexec("/sbin/ifconfig {$ovpndevice} destroy"); + + $tunname = exec("/sbin/ifconfig tun create"); + mwexec("/sbin/ifconfig {$tunname} name {$ovpndevice}"); + mwexec("/sbin/ifconfig {$ovpndevice} group openvpn"); $pidfile = $g['varrun_path'] . "/openvpn_{$mode}{$id}.pid"; $proto = ($settings['protocol'] == 'UDP' ? 'udp' : "tcp-{$mode}"); $cipher = $settings['crypto']; - $openvpn_conf = "dev ovpn{$id}\n"; - $openvpn_conf .= "dev-type tun\n"; - $openvpn_conf .= "dev-node /dev/tun{$id}\n"; $openvpn_conf .= <<<EOD +dev {$ovpndevice} +dev-type tun +dev-node /dev/{$tunname} writepid $pidfile #user nobody #group nobody @@ -823,4 +830,4 @@ EOD; print($javascript); } -?>
\ No newline at end of file +?> |