@@ -119,7 +119,7 @@ function create_jwt_server_key($rotate=false) {
119119 # Create a new server key if one is not set
120120 if (empty ($ api_config ["server_key " ]) or $ rotate === true ) {
121121 $ config ["installedpackages " ]["package " ][$ pkg_index ]["conf " ]["server_key " ] = bin2hex (random_bytes (32 ));
122- write_config ();
122+ write_config (" API server key created " );
123123 }
124124}
125125
@@ -691,34 +691,36 @@ function unbound_reload_config() {
691691}
692692
693693// Check if a DNS Resolver (Unbound) host override already exists
694- function is_unbound_fqdn ($ hostname , $ domain , $ instance_id =null ) {
694+ function is_unbound_fqdn ($ hostname , $ domain , $ ip = null , $ instance_id =null ) {
695695 # Local variables
696696 global $ config ;
697697 $ curr_hosts = (array_key_exists ("hosts " , $ config ["unbound " ])) ? $ config ["unbound " ]["hosts " ] : [];
698- $ host_exists = false ;
699698 $ index = 0 ;
700699
701700 # Loop through each host override and check if the FQDN already exists
702- foreach ($ curr_hosts as $ host_ent ) {
701+ foreach ($ curr_hosts as $ ent ) {
703702 # Check the FQDN matches this entry
704- if ($ host_ent ["host " ] === $ hostname and $ host_ent ["domain " ] === $ domain ) {
705- # If we are working with an existing instance, allow existing FQDN if ID matches
706- if ($ index !== $ instance_id ) {
707- return true ;
703+ if ($ ent ["host " ] === $ hostname and $ ent ["domain " ] === $ domain ) {
704+ # Host overrides are allowed an IPv4 and IPv6 address, check if it already has one.
705+ if (!$ ip or (is_ipaddrv4 ($ ent ["ip " ]) and is_ipaddrv4 ($ ip )) or (is_ipaddrv6 ($ ent ["ip " ]) and is_ipaddrv6 ($ ip ))){
706+ # If we are working with an existing instance, allow existing FQDN if ID matches
707+ if ($ index !== $ instance_id ) {
708+ return true ;
709+ }
708710 }
709711 }
710712
711713 # Check FQDN within host override aliases as well
712- if (is_array ($ host_ent ["aliases " ])) {
713- foreach ($ host_ent ["aliases " ]["item " ] as $ alias_ent ) {
714+ if (is_array ($ ent ["aliases " ])) {
715+ foreach ($ ent ["aliases " ]["item " ] as $ alias_ent ) {
714716 if ($ alias_ent ["host " ] === $ hostname and $ alias_ent ["domain " ] === $ domain ) {
715717 return true ;
716718 }
717719 }
718720 }
719721 $ index ++;
720722 }
721- return $ host_exists ;
723+ return false ;
722724}
723725
724726// Get a complete config list of ALL interfaces. Based off interfaces_assign.php
0 commit comments