function GetRoutes(){ $routess=array(); $cleaned_routes=array(); $ini=new Bs_IniHandler(); if(isset($GLOBALS["CLASS_SOCKETS"])){$sock=$GLOBALS["CLASS_SOCKETS"];}else{$GLOBALS["CLASS_SOCKETS"]=new sockets();$sock=$GLOBALS["CLASS_SOCKETS"];} $ini->loadString($sock->GET_INFO("ArticaOpenVPNSettings")); if(!isset($ini->_params["GLOBAL"]["ENABLE_BRIDGE_MODE"])){$ini->_params["GLOBAL"]["ENABLE_BRIDGE_MODE"]=0;} if($ini->_params["GLOBAL"]["ENABLE_BRIDGE_MODE"]==1){ $BRIDGE_ETH=$ini->_params["GLOBAL"]["BRIDGE_ETH"]; $array_ip=BuildBridgeServer_eth_infos($BRIDGE_ETH); echo "Starting......: OpenVPN binding $BRIDGE_ETH to \"{$array_ip["IPADDR"]}/{$array_ip["NETMASK"]}\"\n"; if(preg_match("#(.+?)\.[0-9]+$#",trim($array_ip["IPADDR"]),$re)){ $LOCAL_ROUTE="{$re[1]}.0 {$array_ip["NETMASK"]}"; $LOCAL_ROUTE=str_replace("Array","",$LOCAL_ROUTE); echo "Starting......: OpenVPN default Local route \"$LOCAL_ROUTE\"\n"; if(trim($LOCAL_ROUTE<>null)){$routess[]="--push \"route $LOCAL_ROUTE\"";} } } if (is_file('/etc/artica-postfix/settings/Daemons/OpenVPNRoutes')){ $routes=(explode("\n",@file_get_contents("/etc/artica-postfix/settings/Daemons/OpenVPNRoutes"))); while (list ($num, $ligne) = each ($routes) ){ if(!preg_match("#(.+?)\s+(.+)#",$ligne,$re)){continue;} $re[1]=trim($re[1]); $re[2]=trim($re[2]); $routess[]="--push \"route {$re[1]} {$re[2]}\""; } } if(count($routess)>0){while (list ($index, $route) = each ($routess) ){$cleaned_routes[$route]=$route;}} if(count($cleaned_routes)>0){ $c=array(); while (list ($a, $b) = each ($cleaned_routes) ){ echo "Starting......: OpenVPN route $b\n"; $c[]=$b;} } if(isset($c)){return $c;}else{return array();} }
function GetRoutes() { $ini = new Bs_IniHandler(); $sock = new sockets(); $ini->loadString($sock->GET_INFO("ArticaOpenVPNSettings")); if ($ini->_params["GLOBAL"]["ENABLE_BRIDGE_MODE"] == 1) { $BRIDGE_ETH = $ini->_params["GLOBAL"]["BRIDGE_ETH"]; $array_ip = BuildBridgeServer_eth_infos($BRIDGE_ETH); echo "Starting......: OpenVPN binding {$BRIDGE_ETH} to \"{$array_ip["IPADDR"]}/{$array_ip["NETMASK"]}\"\n"; if (preg_match("#(.+?)\\.[0-9]+\$#", trim($array_ip["IPADDR"]), $re)) { $LOCAL_ROUTE = "{$re[1]}.0 {$array_ip["NETMASK"]}"; echo "Starting......: OpenVPN default Local route \"{$LOCAL_ROUTE}\"\n"; if (trim($LOCAL_ROUTE != null)) { $routess[] = "--push \"route {$LOCAL_ROUTE}\""; } } } if (is_file('/etc/artica-postfix/settings/Daemons/OpenVPNRoutes')) { $routes = explode("\n", @file_get_contents("/etc/artica-postfix/settings/Daemons/OpenVPNRoutes")); while (list($num, $ligne) = each($routes)) { if (!preg_match("#(.+?)\\s+(.+)#", $ligne, $re)) { continue; } $re[1] = trim($re[1]); $re[2] = trim($re[2]); $routess[] = "--push \"route {$re[1]} {$re[2]}\""; } } if (is_array($routess)) { while (list($index, $route) = each($routess)) { $cleaned_routes[$route] = $route; } } if (is_array($cleaned_routes)) { while (list($a, $b) = each($cleaned_routes)) { $c[] = $a; } } return $c; }