Skip to content

Commit 416c9fa

Browse files
author
Marius Burkard
committed
Merge branch '3122-axfr-range' into 'develop'
Allow subnet for xfer and also notify (#3122) Closes #3122 See merge request ispconfig/ispconfig3!1358
2 parents 8a8b9d2 + 0a42311 commit 416c9fa

File tree

15 files changed

+56
-40
lines changed

15 files changed

+56
-40
lines changed

interface/lib/classes/validate_dns.inc.php

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -283,33 +283,54 @@ function increase_serial($serial){
283283
}
284284
return $new_serial;
285285
}
286-
287-
function validate_xfer($field_name, $field_value, $validator) {
286+
287+
function validate_ip($field_name, $field_value, $validator) {
288288
global $app;
289-
289+
290290
$errorMessage = '';
291-
291+
292292
if($validator['allowempty'] != 'y') $validator['allowempty'] = 'n';
293293
if($validator['allowempty'] == 'y' && $field_value == '') {
294294
//* Do nothing
295295
} elseif ($field_value == 'any') {
296296
//* Do nothing
297297
} else {
298-
//* Check if its a IPv4 or IPv6 address
298+
//* Check if its a IPv4 or IPv6 address/range
299299
if(isset($validator['separator']) && $validator['separator'] != '') {
300300
//* When the field may contain several IP addresses, split them by the char defined as separator
301301
$field_value_array = explode($validator['separator'], $field_value);
302302
} else {
303303
$field_value_array[] = $field_value;
304304
}
305+
// Check if it's a valid input
305306
foreach($field_value_array as $field_value) {
306-
$field_value = trim($field_value);
307+
// Check if the IP is valid without range
308+
$subnet = '';
309+
$ip = trim($field_value);
310+
if(strpos($ip, '/') !== false) {
311+
list($ip, $subnet) = explode('/', $ip, 2);
312+
$ip = trim($ip);
313+
$subnet = intval($subnet);
314+
}
307315
if(function_exists('filter_var')) {
308-
if(!filter_var($field_value, FILTER_VALIDATE_IP)) {
316+
if(!filter_var($ip, FILTER_VALIDATE_IP)) {
309317
$errmsg = $validator['errmsg'];
310318
$errorMessage .= $app->tform->lng($errmsg)."<br />\r\n";
311319
}
312320
} else $this->errorMessage .= "function filter_var missing <br />\r\n";
321+
// Check if the range is valid
322+
if ($subnet !== '') {
323+
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
324+
if ($subnet < 1 || $subnet > 128) {
325+
$errmsg = $validator['errmsg'];
326+
$errorMessage .= $app->tform->lng($errmsg)."<br />\r\n";
327+
}
328+
}
329+
elseif ($subnet < 1 || $subnet > 32) {
330+
$errmsg = $validator['errmsg'];
331+
$errorMessage .= $app->tform->lng($errmsg)."<br />\r\n";
332+
}
333+
}
313334
}
314335
}
315336
return $errorMessage;

interface/web/dns/form/dns_soa.tform.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -244,18 +244,11 @@
244244
'formtype' => 'TEXT',
245245
'validators' => array ( 0 => array ( 'type' => 'CUSTOM',
246246
'class' => 'validate_dns',
247-
'function' => 'validate_xfer',
247+
'function' => 'validate_ip',
248248
'allowempty' => 'y',
249249
'separator' => ',',
250250
'errmsg'=> 'xfer_error_regex'),
251251
),
252-
/*
253-
'validators' => array ( 0 => array ( 'type' => 'ISIP',
254-
'allowempty' => 'y',
255-
'separator' => ',',
256-
'errmsg'=> 'xfer_error_regex'),
257-
),
258-
*/
259252
'default' => '',
260253
'value' => '',
261254
'width' => '30',
@@ -264,7 +257,9 @@
264257
'also_notify' => array (
265258
'datatype' => 'VARCHAR',
266259
'formtype' => 'TEXT',
267-
'validators' => array ( 0 => array ( 'type' => 'ISIP',
260+
'validators' => array ( 0 => array ( 'type' => 'CUSTOM',
261+
'class' => 'validate_dns',
262+
'function' => 'validate_ip',
268263
'allowempty' => 'y',
269264
'separator' => ',',
270265
'errmsg'=> 'also_notify_error_regex'

interface/web/dns/lib/lang/ar_dns_soa.lng

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $wb['ns_error_regex'] = 'NS has a invalid format.';
2222
$wb['mbox_error_empty'] = 'Email is empty.';
2323
$wb['mbox_error_regex'] = 'Email format invalid.';
2424
$wb['also_notify_txt'] = 'Also Notify';
25-
$wb['also_notify_error_regex'] = 'Please use an IP address.';
25+
$wb['also_notify_error_regex'] = 'Also notify: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
2626
$wb['update_acl_txt'] = 'Update ACL';
2727
$wb['seconds_txt'] = 'Seconds';
2828
$wb['eg_domain_tld'] = 'e.g. domain.tld';
@@ -34,7 +34,7 @@ $wb['retry_range_error'] = 'Min. Retry time is 60 seconds.';
3434
$wb['expire_range_error'] = 'Min. Expire time is 60 seconds.';
3535
$wb['minimum_range_error'] = 'Min. Minimum time is 60 seconds.';
3636
$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.';
37-
$wb['xfer_error_regex'] = 'Also notify: Please use an IP address.';
37+
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
3838
$wb['dnssec_info_txt'] = 'DNSSEC DS-Data for registry';
3939
$wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
4040
$wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delivered in signed format afterwards. If you use PowerDNS, keys WILL be deleted!';

interface/web/dns/lib/lang/bg_dns_soa.lng

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ $wb['mbox_error_empty'] = 'Полето с емайл е празно.';
2323
$wb['mbox_error_regex'] = 'Полето е емайл е в грешен формат.';
2424
$wb['also_notify_txt'] = 'Also Notify';
2525
$wb['update_acl_txt'] = 'Обнови ACL';
26-
$wb['also_notify_error_regex'] = 'Please use an IP address.';
26+
$wb['also_notify_error_regex'] = 'Also notify: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
2727
$wb['seconds_txt'] = 'Seconds';
2828
$wb['eg_domain_tld'] = 'e.g. domain.tld';
2929
$wb['eg_ns1_domain_tld'] = 'e.g. ns1.domain.tld';
@@ -34,7 +34,7 @@ $wb['retry_range_error'] = 'Min. Retry time is 60 seconds.';
3434
$wb['expire_range_error'] = 'Min. Expire time is 60 seconds.';
3535
$wb['minimum_range_error'] = 'Min. Minimum time is 60 seconds.';
3636
$wb['ttl_range_error'] = 'Минималния TTL е 60 секунди.';
37-
$wb['xfer_error_regex'] = 'Also notify: Please use an IP address.';
37+
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
3838
$wb['dnssec_info_txt'] = 'DNSSEC DS-Data for registry';
3939
$wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
4040
$wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delivered in signed format afterwards. If you use PowerDNS, keys WILL be deleted!';

interface/web/dns/lib/lang/el_dns_soa.lng

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ $wb['retry_range_error'] = 'Min. Retry time is 60 seconds.';
3434
$wb['expire_range_error'] = 'Min. Expire time is 60 seconds.';
3535
$wb['minimum_range_error'] = 'Min. Minimum time is 60 seconds.';
3636
$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.';
37-
$wb['xfer_error_regex'] = 'Also notify: Please use an IP address.';
37+
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
3838
$wb['dnssec_info_txt'] = 'DNSSEC DS-Data for registry';
3939
$wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
4040
$wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delivered in signed format afterwards. If you use PowerDNS, keys WILL be deleted!';

interface/web/dns/lib/lang/en_dns_soa.lng

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ $wb['ns_error_regex'] = 'NS has a invalid format.';
2525
$wb['mbox_error_empty'] = 'Email is empty.';
2626
$wb['mbox_error_regex'] = 'Email format invalid.';
2727
$wb['also_notify_txt'] = 'Also Notify';
28-
$wb['also_notify_error_regex'] = 'Also notify: Please use an IP address.';
29-
$wb['xfer_error_regex'] = 'Xfer: Please use one or more IP addresses, separated by , or use the keyword: any';
28+
$wb['also_notify_error_regex'] = 'Also notify: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
29+
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
3030
$wb['update_acl_txt'] = 'Update ACL';
3131
$wb['seconds_txt'] = 'Seconds';
3232
$wb['eg_domain_tld'] = 'e.g. domain.tld';

interface/web/dns/lib/lang/fi_dns_soa.lng

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $wb['ns_error_regex'] = 'Nimipalvelin-kenttä on tyhjä.';
2222
$wb['mbox_error_empty'] = 'Sähköpostiosoite on tyhjä.';
2323
$wb['mbox_error_regex'] = 'Sähköpostiosoite on vääränlainen';
2424
$wb['also_notify_txt'] = 'Läheta ilmoitus';
25-
$wb['also_notify_error_regex'] = 'Please use an IP address.';
25+
$wb['also_notify_error_regex'] = 'Also notify: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
2626
$wb['update_acl_txt'] = 'Päivitä ACL';
2727
$wb['seconds_txt'] = 'Seconds';
2828
$wb['eg_domain_tld'] = 'e.g. domain.tld';
@@ -34,7 +34,7 @@ $wb['retry_range_error'] = 'Min. Retry time is 60 seconds.';
3434
$wb['expire_range_error'] = 'Min. Expire time is 60 seconds.';
3535
$wb['minimum_range_error'] = 'Min. Minimum time is 60 seconds.';
3636
$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.';
37-
$wb['xfer_error_regex'] = 'Also notify: Please use an IP address.';
37+
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
3838
$wb['dnssec_info_txt'] = 'DNSSEC DS-Data for registry';
3939
$wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
4040
$wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delivered in signed format afterwards. If you use PowerDNS, keys WILL be deleted!';

interface/web/dns/lib/lang/hu_dns_soa.lng

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $wb['ns_error_regex'] = 'NS has a invalid format.';
2222
$wb['mbox_error_empty'] = 'Email is empty.';
2323
$wb['mbox_error_regex'] = 'Email format invalid.';
2424
$wb['also_notify_txt'] = 'Also Notify';
25-
$wb['also_notify_error_regex'] = 'Please use an IP address.';
25+
$wb['also_notify_error_regex'] = 'Also notify: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
2626
$wb['update_acl_txt'] = 'Update ACL';
2727
$wb['seconds_txt'] = 'Seconds';
2828
$wb['eg_domain_tld'] = 'e.g. domain.tld';
@@ -34,7 +34,7 @@ $wb['retry_range_error'] = 'Min. Retry time is 60 seconds.';
3434
$wb['expire_range_error'] = 'Min. Expire time is 60 seconds.';
3535
$wb['minimum_range_error'] = 'Min. Minimum time is 60 seconds.';
3636
$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.';
37-
$wb['xfer_error_regex'] = 'Also notify: Please use an IP address.';
37+
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
3838
$wb['dnssec_info_txt'] = 'DNSSEC DS-Data for registry';
3939
$wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
4040
$wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delivered in signed format afterwards. If you use PowerDNS, keys WILL be deleted!';

interface/web/dns/lib/lang/id_dns_soa.lng

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $wb['ns_error_regex'] = 'Format NS salah.';
2222
$wb['mbox_error_empty'] = 'Email kosong.';
2323
$wb['mbox_error_regex'] = 'Format Email tidak valid.';
2424
$wb['also_notify_txt'] = 'Notifikasi Juga';
25-
$wb['also_notify_error_regex'] = 'Please use an IP address.';
25+
$wb['also_notify_error_regex'] = 'Also notify: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
2626
$wb['update_acl_txt'] = 'Mutakhirkan ACL';
2727
$wb['seconds_txt'] = 'Seconds';
2828
$wb['eg_domain_tld'] = 'e.g. domain.tld';
@@ -34,7 +34,7 @@ $wb['retry_range_error'] = 'Min. Retry time is 60 seconds.';
3434
$wb['expire_range_error'] = 'Min. Expire time is 60 seconds.';
3535
$wb['minimum_range_error'] = 'Min. Minimum time is 60 seconds.';
3636
$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.';
37-
$wb['xfer_error_regex'] = 'Also notify: Please use an IP address.';
37+
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
3838
$wb['dnssec_info_txt'] = 'DNSSEC DS-Data for registry';
3939
$wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
4040
$wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delivered in signed format afterwards. If you use PowerDNS, keys WILL be deleted!';

interface/web/dns/lib/lang/ja_dns_soa.lng

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $wb['ns_error_regex'] = 'NS が不正な文字を含んでいます。';
2222
$wb['mbox_error_empty'] = 'メールアドレスを指定してください';
2323
$wb['mbox_error_regex'] = 'メールアドレスの形式が不正です。';
2424
$wb['also_notify_txt'] = 'Also Notify';
25-
$wb['also_notify_error_regex'] = 'Please use an IP address.';
25+
$wb['also_notify_error_regex'] = 'Also notify: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
2626
$wb['update_acl_txt'] = 'Update ACL';
2727
$wb['seconds_txt'] = 'Seconds';
2828
$wb['eg_domain_tld'] = 'e.g. domain.tld';
@@ -34,7 +34,7 @@ $wb['retry_range_error'] = 'Min. Retry time is 60 seconds.';
3434
$wb['expire_range_error'] = 'Min. Expire time is 60 seconds.';
3535
$wb['minimum_range_error'] = 'Min. Minimum time is 60 seconds.';
3636
$wb['ttl_range_error'] = 'Min. TTL time is 60 seconds.';
37-
$wb['xfer_error_regex'] = 'Also notify: Please use an IP address.';
37+
$wb['xfer_error_regex'] = 'Zone transfers: Please use a valid IP range, one or more IP addresses separated by a comma or use the keyword: any';
3838
$wb['dnssec_info_txt'] = 'DNSSEC DS-Data for registry';
3939
$wb['dnssec_wanted_txt'] = 'Sign zone (DNSSEC)';
4040
$wb['dnssec_wanted_info'] = 'When disabling DNSSEC keys are not going to be deleted if DNSSEC was enabled before and keys already have been generated but the zone will no longer be delivered in signed format afterwards. If you use PowerDNS, keys WILL be deleted!';

0 commit comments

Comments
 (0)