summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhil Davis <phil.davis@inf.org>2016-12-03 19:21:07 +0545
committerRenato Botelho <renato@netgate.com>2016-12-27 10:47:49 -0200
commit4a1a2050862defed55ce2e06537af694ca6a2561 (patch)
treecf3f777c6130cd9a8e70b090f57bfab872e8da74 /src
parent914ddfa2830879618a7f61168c46b1efb8c39336 (diff)
downloadpfsense-4a1a2050862defed55ce2e06537af694ca6a2561.zip
pfsense-4a1a2050862defed55ce2e06537af694ca6a2561.tar.gz
Form_IpAddress add types remove patterns
1) Add alias and host types to Form_IpAddress with the appropriate hover text. 2) Remove the patterns - the UI of those is not so effective anyway, so leave the validation of input to the back end. 3) Update uses of Form_IpAddress to use the appropriate Alias or Host type as needed. 4) Remove explicit setPattern() from those uses of Form_IpAddress. (cherry picked from commit 45541aae63596ea28aa18c84b65946bce6adbffd)
Diffstat (limited to 'src')
-rw-r--r--src/usr/local/www/classes/Form/IpAddress.class.php27
-rw-r--r--src/usr/local/www/firewall_aliases_edit.php3
-rw-r--r--src/usr/local/www/firewall_nat_1to1_edit.php7
-rw-r--r--src/usr/local/www/firewall_nat_edit.php15
-rw-r--r--src/usr/local/www/firewall_nat_out_edit.php10
-rw-r--r--src/usr/local/www/firewall_rules_edit.php5
-rw-r--r--src/usr/local/www/services_dhcp.php8
-rw-r--r--src/usr/local/www/services_router_advertisements.php8
-rw-r--r--src/usr/local/www/system_routes_edit.php5
9 files changed, 60 insertions, 28 deletions
diff --git a/src/usr/local/www/classes/Form/IpAddress.class.php b/src/usr/local/www/classes/Form/IpAddress.class.php
index 28ca402..bbf5d7a 100644
--- a/src/usr/local/www/classes/Form/IpAddress.class.php
+++ b/src/usr/local/www/classes/Form/IpAddress.class.php
@@ -62,17 +62,38 @@ class Form_IpAddress extends Form_Input
switch ($type) {
case "BOTH":
- $this->_attributes['pattern'] = '[a-fA-F0-9:.]*';
$this->_attributes['title'] = 'An IPv4 address like 1.2.3.4 or an IPv6 address like 1:2a:3b:ffff::1';
break;
case "V4":
- $this->_attributes['pattern'] = '[0-9.]*';
+ $this->_attributes['title'] = 'An IPv4 address like 1.2.3.4';
break;
case "V6":
- $this->_attributes['pattern'] = '[a-fA-F0-9:.]*';
$this->_attributes['title'] = 'An IPv6 address like 1:2a:3b:ffff::1';
+
+ case "ALIASV4V6":
+ $this->_attributes['title'] = 'An IPv4 address like 1.2.3.4 or an IPv6 address like 1:2a:3b:ffff::1 or an alias';
+ break;
+
+ case "ALIASV4":
+ $this->_attributes['title'] = 'An IPv4 address like 1.2.3.4 or an alias';
+ break;
+
+ case "ALIASV6":
+ $this->_attributes['title'] = 'An IPv6 address like 1:2a:3b:ffff::1 or an alias';
+ break;
+
+ case "HOSTV4V6":
+ $this->_attributes['title'] = 'An IPv4 address like 1.2.3.4 or an IPv6 address like 1:2a:3b:ffff::1 or a host name like myhost.example.com';
+ break;
+
+ case "HOSTV4":
+ $this->_attributes['title'] = 'An IPv4 address like 1.2.3.4 or a host name like myhost.example.com';
+ break;
+
+ case "HOSTV6":
+ $this->_attributes['title'] = 'An IPv6 address like 1:2a:3b:ffff::1 or a host name like myhost.example.com';
break;
}
}
diff --git a/src/usr/local/www/firewall_aliases_edit.php b/src/usr/local/www/firewall_aliases_edit.php
index dfc1557..0484ce3 100644
--- a/src/usr/local/www/firewall_aliases_edit.php
+++ b/src/usr/local/www/firewall_aliases_edit.php
@@ -738,7 +738,8 @@ while ($counter < count($addresses)) {
$group->add(new Form_IpAddress(
'address' . $counter,
$tab == 'port' ? 'Port':'Address',
- $address
+ $address,
+ 'ALIASV4V6'
))->addMask('address_subnet' . $counter, $address_subnet)->setWidth(4)->setPattern($pattern_str[$tab]);
$group->add(new Form_Input(
diff --git a/src/usr/local/www/firewall_nat_1to1_edit.php b/src/usr/local/www/firewall_nat_1to1_edit.php
index 99db602..3f5bc48 100644
--- a/src/usr/local/www/firewall_nat_1to1_edit.php
+++ b/src/usr/local/www/firewall_nat_1to1_edit.php
@@ -523,7 +523,7 @@ $group->add(new Form_IpAddress(
'src',
null,
is_specialnet($pconfig['src']) ? '': $pconfig['src']
-))->addMask('srcmask', $pconfig['srcmask'], 31)->setHelp('Address/mask')->setPattern('[a-zA-Z0-9.:_]+');
+))->addMask('srcmask', $pconfig['srcmask'], 31)->setHelp('Address/mask');
$group->setHelp('Enter the internal (LAN) subnet for the 1:1 mapping. ' .
'The subnet size specified for the internal subnet will be applied to the external subnet.');
@@ -549,8 +549,9 @@ $group->add(new Form_Select(
$group->add(new Form_IpAddress(
'dst',
null,
- is_specialnet($pconfig['dst']) ? '': $pconfig['dst']
-))->addMask('dstmask', $pconfig['dstmask'], 31)->setHelp('Address/mask')->setPattern('[a-zA-Z0-9.:_]+');
+ is_specialnet($pconfig['dst']) ? '': $pconfig['dst'],
+ 'ALIASV4V6'
+))->addMask('dstmask', $pconfig['dstmask'], 31)->setHelp('Address/mask');
$group->setHelp('The 1:1 mapping will only be used for connections to or from the specified destination. Hint: this is usually "Any".');
diff --git a/src/usr/local/www/firewall_nat_edit.php b/src/usr/local/www/firewall_nat_edit.php
index 3474da5..1942fbf 100644
--- a/src/usr/local/www/firewall_nat_edit.php
+++ b/src/usr/local/www/firewall_nat_edit.php
@@ -771,8 +771,9 @@ $group->add(new Form_Select(
$group->add(new Form_IpAddress(
'src',
null,
- is_specialnet($pconfig['src']) ? '': $pconfig['src']
-))->setPattern('[.a-zA-Z0-9_:]+')->addMask('srcmask', $pconfig['srcmask'])->setHelp('Address/mask');
+ is_specialnet($pconfig['src']) ? '': $pconfig['src'],
+ 'ALIASV4V6'
+))->addMask('srcmask', $pconfig['srcmask'])->setHelp('Address/mask');
$section->add($group);
@@ -838,8 +839,9 @@ $group->add(new Form_Select(
$group->add(new Form_IpAddress(
'dst',
null,
- is_specialnet($pconfig['dst']) ? '': $pconfig['dst']
-))->setPattern('[.a-zA-Z0-9_:]+')->addMask('dstmask', $pconfig['dstmask'], 31)->setHelp('Address/mask');
+ is_specialnet($pconfig['dst']) ? '': $pconfig['dst'],
+ 'ALIASV4V6'
+))->addMask('dstmask', $pconfig['dstmask'], 31)->setHelp('Address/mask');
$section->add($group);
@@ -882,8 +884,9 @@ $section->add($group);
$section->addInput(new Form_IpAddress(
'localip',
'Redirect target IP',
- $pconfig['localip']
-))->setPattern('[.a-zA-Z0-9_:]+')->setHelp('Enter the internal IP address of the server on which to map the ports.' . '<br />' .
+ $pconfig['localip'],
+ 'ALIASV4V6'
+))->setHelp('Enter the internal IP address of the server on which to map the ports.' . '<br />' .
'e.g.: 192.168.1.12');
$group = new Form_Group('Redirect target port');
diff --git a/src/usr/local/www/firewall_nat_out_edit.php b/src/usr/local/www/firewall_nat_out_edit.php
index 157aa8d..b7b77f9 100644
--- a/src/usr/local/www/firewall_nat_out_edit.php
+++ b/src/usr/local/www/firewall_nat_out_edit.php
@@ -530,8 +530,9 @@ $group->add(new Form_Select(
$group->add(new Form_IpAddress(
'source',
null,
- $pconfig['source']
-))->addMask('source_subnet', $pconfig['source_subnet'])->setHelp('Source network for the outbound NAT mapping.')->setPattern('[a-zA-Z0-9_.:]+');
+ $pconfig['source'],
+ 'ALIASV4V6'
+))->addMask('source_subnet', $pconfig['source_subnet'])->setHelp('Source network for the outbound NAT mapping.');
$group->add(new Form_Input(
'sourceport',
@@ -554,8 +555,9 @@ $group->add(new Form_Select(
$group->add(new Form_IpAddress(
'destination',
null,
- $pconfig['destination'] == "any" ? "":$pconfig['destination']
-))->addMask('destination_subnet', $pconfig['destination_subnet'])->setHelp('Destination network for the outbound NAT mapping.')->setPattern('[a-zA-Z0-9_.:]+');
+ $pconfig['destination'] == "any" ? "":$pconfig['destination'],
+ 'ALIASV4V6'
+))->addMask('destination_subnet', $pconfig['destination_subnet'])->setHelp('Destination network for the outbound NAT mapping.');
$group->add(new Form_Input(
'dstport',
diff --git a/src/usr/local/www/firewall_rules_edit.php b/src/usr/local/www/firewall_rules_edit.php
index 5df533b..3762921 100644
--- a/src/usr/local/www/firewall_rules_edit.php
+++ b/src/usr/local/www/firewall_rules_edit.php
@@ -1357,8 +1357,9 @@ foreach (['src' => 'Source', 'dst' => 'Destination'] as $type => $name) {
$group->add(new Form_IpAddress(
$type,
$name .' Address',
- $pconfig[$type]
- ))->addMask($type .'mask', $pconfig[$type.'mask'])->setPattern('[a-zA-Z0-9_.:]+');
+ $pconfig[$type],
+ 'ALIASV4V6'
+ ))->addMask($type .'mask', $pconfig[$type.'mask']);
$section->add($group);
diff --git a/src/usr/local/www/services_dhcp.php b/src/usr/local/www/services_dhcp.php
index 59d069e..67ddb16 100644
--- a/src/usr/local/www/services_dhcp.php
+++ b/src/usr/local/www/services_dhcp.php
@@ -1155,15 +1155,15 @@ $section->addInput(new Form_IpAddress(
'ntp1',
'NTP Server 1',
$pconfig['ntp1'],
- 'V4'
-))->setPattern('[.a-zA-Z0-9-]+');
+ 'HOSTV4'
+));
$section->addInput(new Form_IpAddress(
'ntp2',
'NTP Server 2',
$pconfig['ntp2'],
- 'V4'
-))->setPattern('[.a-zA-Z0-9-]+');
+ 'HOSTV4'
+));
// Advanced TFTP
$btnadv = new Form_Button(
diff --git a/src/usr/local/www/services_router_advertisements.php b/src/usr/local/www/services_router_advertisements.php
index 53d5215..eaeeca1 100644
--- a/src/usr/local/www/services_router_advertisements.php
+++ b/src/usr/local/www/services_router_advertisements.php
@@ -439,7 +439,8 @@ foreach ($pconfig['subnets'] as $subnet) {
$group->add(new Form_IpAddress(
$address_name,
null,
- $address
+ $address,
+ 'V6'
))->addMask($bits_name, $subnet);
$group->add(new Form_Button(
@@ -471,8 +472,9 @@ for ($idx=1; $idx<=3; $idx++) {
$section->addInput(new Form_IpAddress(
'radns' . $idx,
'Server ' . $idx,
- $pconfig['radns' . $idx]
- ))->setPattern('[a-zA-Z0-9_.:]+')->setHelp(($idx < 3) ? '':'Leave blank to use the system default DNS servers - this interface\'s IP if DNS Forwarder or Resolver is enabled, otherwise the servers configured on the General page');
+ $pconfig['radns' . $idx],
+ 'ALIASV6'
+ ))->setHelp(($idx < 3) ? '':'Leave blank to use the system default DNS servers - this interface\'s IP if DNS Forwarder or Resolver is enabled, otherwise the servers configured on the General page');
}
$section->addInput(new Form_Input(
diff --git a/src/usr/local/www/system_routes_edit.php b/src/usr/local/www/system_routes_edit.php
index 6ba7ec8..98ae6a0 100644
--- a/src/usr/local/www/system_routes_edit.php
+++ b/src/usr/local/www/system_routes_edit.php
@@ -277,8 +277,9 @@ $section = new Form_Section('Edit Route Entry');
$section->addInput(new Form_IpAddress(
'network',
'Destination network',
- $pconfig['network']
-))->addMask('network_subnet', $pconfig['network_subnet'])->setPattern('[.a-zA-Z0-9_:]+')->setHelp('Destination network for this static route');
+ $pconfig['network'],
+ 'ALIASV4V6'
+))->addMask('network_subnet', $pconfig['network_subnet'])->setHelp('Destination network for this static route');
$allGateways = array_combine(
array_map(function($g){ return $g['name']; }, $a_gateways),
OpenPOWER on IntegriCloud