summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/config.defaults.php8
-rw-r--r--includes/utils.php18
2 files changed, 21 insertions, 5 deletions
diff --git a/includes/config.defaults.php b/includes/config.defaults.php
index 25eaf6f..dfc0d58 100644
--- a/includes/config.defaults.php
+++ b/includes/config.defaults.php
@@ -2,7 +2,7 @@
/*
* Looking Glass - An easy to deploy Looking Glass
- * Copyright (C) 2014-2015 Guillaume Mazoyer <gmazoyer@gravitons.in>
+ * Copyright (C) 2014-2016 Guillaume Mazoyer <gmazoyer@gravitons.in>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -92,7 +92,11 @@ $config = array(
'allow_private_ip' => true,
// Allow reserved IPv4 addresses (0.0.0.0/8, 169.254.0.0/16,
// 192.0.2.0/24 and 224.0.0.0/4)
- 'allow_reserved_ip' => true
+ 'allow_reserved_ip' => true,
+ // Disable IPv6
+ 'disable_ipv6' => false,
+ // Disable IPv4
+ 'disable_ipv4' => false
),
// Tools used for some processing
diff --git a/includes/utils.php b/includes/utils.php
index b297d61..0fbf3f7 100644
--- a/includes/utils.php
+++ b/includes/utils.php
@@ -2,7 +2,7 @@
/*
* Looking Glass - An easy to deploy Looking Glass
- * Copyright (C) 2014 Guillaume Mazoyer <gmazoyer@gravitons.in>
+ * Copyright (C) 2014-2016 Guillaume Mazoyer <gmazoyer@gravitons.in>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -243,7 +243,20 @@ function match_aspath_regex($aspath_regex) {
* @return string an IPv6 or IPv4 address based on the DNS records.
*/
function hostname_to_ip_address($hostname) {
- $dns_record = dns_get_record($hostname, DNS_AAAA + DNS_A);
+ global $config;
+
+ $record_types = DNS_AAAA + DNS_A;
+
+ // IPv6 is disabled look for A records only
+ if ($config['misc']['disable_ipv6']) {
+ $record_types = DNS_A;
+ }
+ // IPv4 is disabled look for AAAA records only
+ if ($config['misc']['disabke_ipv4']) {
+ $record_types = DNS_AAAA;
+ }
+
+ $dns_record = dns_get_record($hostname, $record_types);
// No DNS record found
if (!$dns_record) {
@@ -265,7 +278,6 @@ function hostname_to_ip_address($hostname) {
// Several records found
if ($records_nb > 1) {
- // TODO: this could probably be more optimal
foreach ($dns_record as $record) {
if ($record['type'] == 'AAAA') {
return $record['ipv6'];