Project

General

Profile

« Previous | Next » 

Revision 4f1ebacb

Added by Ermal LUÇI almost 15 years ago

Ticket #769. Convert assigned openvpn interfaces by using custom options to 2.0 style assigned openvpn interfaces. This upgrade removes the 'dev tun#' from cutom options and upgrades the assigned interface name to new style.

View differences:

etc/inc/upgrade_config.inc
1415 1415
			/* allocate vpnid */
1416 1416
			$server['vpnid'] = $vpnid++;
1417 1417

  
1418
			if (!empty($server['custom_options'])) {
1419
				$cstmopts = array();
1420
				$tmpcstmopts = explode(";", $server['custom_options']);
1421
				$assigned = false;
1422
				$tmpstr = "";
1423
				foreach ($tmpcstmopts as $tmpcstmopt) {
1424
					$tmpstr = str_replace(" ", "", $tmpcstmopt);
1425
					if (substr($tmpstr,0 ,6) == "devtun") {
1426
						$assigned = true;
1427
						continue;
1428
					} else
1429
						$cstmopts[] = $tmpcstmopt;
1430
				}
1431
				$server['custom_options'] = implode(";", $cstmopts);
1432
				if ($assigned == true) {
1433
					$realif = substr($tmpstr, 3);
1434
					foreach ($config['interfaces'] as $iface => $cfgif) {
1435
						if ($cfgif['if'] == $realif) {
1436
							$config['interfaces'][$iface]['if'] = "ovpns{$server['vpnid']}";
1437
							break;
1438
						}
1439
					}
1440
				}
1441
			}
1442

  
1418 1443
			$config['openvpn']['openvpn-server'][] = $server;
1419 1444
		}
1420 1445
		unset($config['installedpackages']['openvpnserver']);
......
1489 1514
			/* allocate vpnid */
1490 1515
			$client['vpnid'] = $vpnid++;
1491 1516

  
1517
			if (!empty($client['custom_options'])) {
1518
				$cstmopts = array();
1519
				$tmpcstmopts = explode(";", $client['custom_options']);
1520
				$assigned = false;
1521
				$tmpstr = "";
1522
				foreach ($tmpcstmopts as $tmpcstmopt) {
1523
					$tmpstr = str_replace(" ", "", $tmpcstmopt);
1524
					if (substr($tmpstr,0 ,6) == "devtun") {
1525
						$assigned = true;
1526
						continue;
1527
					} else
1528
						$cstmopts[] = $tmpcstmopt;
1529
				}
1530
				$client['custom_options'] = implode(";", $cstmopts);
1531
				if ($assigned == true) {
1532
					$realif = substr($tmpstr, 3);
1533
					foreach ($config['interfaces'] as $iface => $cfgif) {
1534
						if ($cfgif['if'] == $realif) {
1535
							$config['interfaces'][$iface]['if'] = "ovpnc{$client['vpnid']}";
1536
							break;
1537
						}
1538
					}
1539
				}
1540
			}
1541

  
1492 1542
			if (!empty($client['disable']))
1493 1543
				$client['disable'] = true;
1494 1544
			else

Also available in: Unified diff