Project

General

Profile

« Previous | Next » 

Revision ebe833f6

Added by NOYB NOYB about 9 years ago

Firewall / Aliases / Edit - New URL Table Alias Type

Make the code cleaner and easier to follow by using the same alias type designations as config.

View differences:

src/etc/inc/filter.inc
850 850
				// TODO: Change it when pf supports tables with ports
851 851
				$urlfn = alias_expand_urltable($aliased['name']);
852 852
				if ($urlfn) {
853
					$ports_tmp = parse_aliases_file($urlfn, "url_ports", "-1", false);
853
					$ports_tmp = parse_aliases_file($urlfn, "urltable_ports", "-1", false);
854 854
					$aliases .= "{$aliased['name']} = \"{ " . preg_replace("/\n/", " ", implode("\n", $ports_tmp)) . " }\"\n";
855 855
				}
856 856
				break;
src/etc/inc/pfsense-utils.inc
1957 1957
			if (!empty($tmp_str)) {
1958 1958
				$tmp = $tmp_str;
1959 1959
			}
1960
			$valid = ($type == "url" && (is_ipaddr($tmp) || is_subnet($tmp))) ||
1961
				($type == "url_ports" && (is_port($tmp) || is_portrange($tmp)));
1960
			$valid = (($type == "url" || $type == "urltable") && (is_ipaddr($tmp) || is_subnet($tmp))) ||
1961
				(($type == "url_ports" || $type == "urltable_ports") && (is_port($tmp) || is_portrange($tmp)));
1962 1962
			if ($valid) {
1963 1963
				$items[] = $tmp;
1964 1964
				if (count($items) == $max_items) {
......
2177 2177
		if (download_file($url, $tmp_urltable_filename, $verify_ssl)) {
2178 2178
			// Convert lines that begin with '$' or ';' to comments '#' instead of deleting them.
2179 2179
			mwexec("/usr/bin/sed -i \"\" -E 's/^[[:space:]]*($|#|;)/#/g; /^#/!s/\;.*//g;' ". escapeshellarg($tmp_urltable_filename));
2180

  
2180 2181
			$type = ($type) ? $type : alias_get_type($name);	// If empty type passed, try to get it from config.
2181
			if ($type == "urltable_ports") {
2182
				$ports = parse_aliases_file($tmp_urltable_filename, "url_ports", "-1", true);
2183
				$ports = group_ports($ports, true);
2184
				file_put_contents($urltable_filename, implode("\n", $ports));
2185
			} else {
2186
				$urltable = parse_aliases_file($tmp_urltable_filename, "url", "-1", true);
2187
				if (is_array($urltable)) {
2188
					file_put_contents($urltable_filename, implode("\n", $urltable));
2189
				}
2182

  
2183
			$parsed_contents = parse_aliases_file($tmp_urltable_filename, $type, "-1", true);
2184
			if ($type == "url_ports") {
2185
				$parsed_contents = group_ports($parsed_contents, true);
2186
			}
2187
			if (is_array($parsed_contents)) {
2188
				file_put_contents($urltable_filename, implode("\n", $parsed_contents));
2190 2189
			}
2190

  
2191 2191
			/* If this backup is still there on a full install, but we aren't going to use ram disks, remove the archive since this is a transition. */
2192 2192
			if (($g['platform'] == $g['product_name']) && !isset($config['system']['use_mfs_tmpvar'])) {
2193 2193
				unlink_if_exists("{$g['cf_conf_path']}/RAM_Disk_Store{$urltable_filename}.tgz");

Also available in: Unified diff