Project

General

Profile

« Previous | Next » 

Revision abc9d914

Added by Marcos M almost 2 years ago

Refactor translation target for outbound NAT

View differences:

src/etc/inc/upgrade_config.inc
30 30
if (!function_exists("console_configure")) {
31 31
	require_once("/etc/inc/pfsense-utils.inc");
32 32
}
33
if (!function_exists("get_specialnet")) {
34
	require_once("/etc/inc/util.inc");
35
}
33 36

  
34 37
/* Upgrade functions must be named:
35 38
 *    upgrade_XXX_to_YYY
......
6782 6785
	mwexec("$rrdtool tune {$rrddbpath}{$database} DS:buffers:GAUGE:{$valid}:0:10000000 2>&1");
6783 6786
}
6784 6787

  
6788
function upgrade_229_to_230() {
6789
	/* The "target" GUI for outbound NAT rules now behaves similarly to other pages. */
6790
	$obn_rules = config_get_path('nat/outbound/rule', []);
6791
	foreach ($obn_rules as & $obent) {
6792
		if (empty($obent['target'])) {
6793
			// migrate interface address selection
6794
			$obent['target_type'] = $obent['interface'] . 'ip';
6795
			$obent['target'] = '';
6796
			$obent['target_subnet'] = '';
6797
		} elseif (str_contains($obent['target'], ':') ||
6798
		          str_contains($obent['target'], '.')) {
6799
			// migrate VIPs
6800
			if (get_specialnet($obent['target'])) {
6801
				$obent['target_type'] = $obent['target'];
6802
				$obent['target'] = '';
6803
			} else {
6804
				$obent['target_type'] = '';
6805
			}
6806
			$obent['target_subnet'] = '';
6807
		} elseif ($obent['target'] == 'other-subnet') {
6808
			// migrate custom subnets
6809
			$obent['target_type'] = 'network';
6810
			$obent['target'] = $obent['targetip'];
6811
			$obent['target_subnet'] = $obent['targetip_subnet'];
6812
		} else {
6813
			// migrate aliases
6814
			$obent['target_type'] = 'network';
6815
			$obent['target_subnet'] = '';
6816
		}
6817
		foreach (['targetip', 'targetip_subnet'] as $old) {
6818
			if (array_key_exists($old, $obent)) {
6819
				unset($obent[$old]);
6820
			}
6821
		}
6822
	}
6823
	if (isset($obent)) {
6824
		unset($obent);
6825
	}
6826
	config_set_path('nat/outbound/rule', $obn_rules);
6827
}
6828

  
6785 6829
/*
6786 6830
 * Special function that is called independent of current config version. It's
6787 6831
 * a workaround to have config_upgrade running on older versions after next

Also available in: Unified diff