summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2012-03-07 14:42:59 +0100
committerPetr Vobornik <pvoborni@redhat.com>2012-03-20 17:30:04 +0100
commitc09c21aef08229507cddb187b25ad7cf9ebd8c68 (patch)
treedf78184834c1c4b865815ae1816f3226754e46ad /install
parent0acc3e25b56983d46b344d5fe14c0059088b7e36 (diff)
downloadfreeipa.git-c09c21aef08229507cddb187b25ad7cf9ebd8c68.tar.gz
freeipa.git-c09c21aef08229507cddb187b25ad7cf9ebd8c68.tar.xz
freeipa.git-c09c21aef08229507cddb187b25ad7cf9ebd8c68.zip
DNS forwarder validator
DNS forwarder's value can consist of IP address and a port. The syntax is '<IP ADDRESS> port <PORT>'. A new validator was created for this purpose. It is based on IP address validator. https://fedorahosted.org/freeipa/ticket/2490
Diffstat (limited to 'install')
-rw-r--r--install/ui/dns.js37
-rw-r--r--install/ui/test/data/ipa_init.json1
2 files changed, 35 insertions, 3 deletions
diff --git a/install/ui/dns.js b/install/ui/dns.js
index 54683586..33b21e4c 100644
--- a/install/ui/dns.js
+++ b/install/ui/dns.js
@@ -49,7 +49,7 @@ IPA.dns.config_entity = function(spec) {
{
type: 'multivalued',
name: 'idnsforwarders',
- validators: [IPA.ip_address_validator()]
+ validators: [IPA.dnsforwarder_validator()]
},
{
type: 'checkboxes',
@@ -167,7 +167,7 @@ IPA.dns.zone_entity = function(spec) {
{
type: 'multivalued',
name: 'idnsforwarders',
- validators: [IPA.ip_address_validator()]
+ validators: [IPA.dnsforwarder_validator()]
},
{
type: 'checkboxes',
@@ -2170,7 +2170,6 @@ IPA.dns.ptr_redirection_dialog = function(spec) {
return that;
};
-
IPA.ip_address_validator = function(spec) {
spec = spec || {};
@@ -2202,6 +2201,8 @@ IPA.ip_address_validator = function(spec) {
(that.address_type === 'IPv6' && net_type === 'v6'));
};
+ that.ip_address_validate = that.validate;
+
return that;
};
@@ -2221,6 +2222,36 @@ IPA.ip_v6_address_validator = function(spec) {
return IPA.ip_address_validator(spec);
};
+IPA.dnsforwarder_validator = function(spec) {
+
+ spec = spec || {};
+ var that = IPA.ip_address_validator(spec);
+
+ that.validate = function(value) {
+
+ var address_part = value;
+
+ if (value.indexOf(' ') > - 1) {
+ var parts = value.split(' ');
+
+ if (parts.length !== 3 || parts[1] !== 'port') return that.false_result();
+
+ address_part = parts[0];
+ var port = parts[2];
+
+ if (!port.match(/^[1-9]\d*$|^0$/) || port < 0 || port > 65535) {
+ var message = IPA.messages.widget.validation.port;
+ message = message.replace('${port}', port);
+ return that.false_result(message);
+ }
+ }
+
+ return that.ip_address_validate(address_part);
+ };
+
+ return that;
+};
+
IPA.network_validator = function(spec) {
spec = spec || {};
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index 36a3388d..8aa47608 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -452,6 +452,7 @@
"max_value": "Maximum value is ${value}",
"min_value": "Minimum value is ${value}",
"net_address": "Not a valid network address",
+ "port": "'${port}' is not a valid port",
"required": "Required field",
"unsupported": "Unsupported value"
}