Skip to content

Commit 6300d64

Browse files
committed
[WebUI] Fix hestiacp#634. DNS ip should use NAT/public ip if available after changing web domain IP
1 parent ef939df commit 6300d64

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

web/edit/web/index.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@
9393
$ips = json_decode(implode('', $output), true);
9494
unset($output);
9595

96+
$v_ip_public = empty($ips[$v_ip]['NAT']) ? $v_ip : $ips[$v_ip]['NAT'];
97+
9698
// List web templates
9799
exec (HESTIA_CMD."v-list-web-templates json", $output, $return_var);
98100
$templates = json_decode(implode('', $output), true);
@@ -130,7 +132,14 @@
130132
}
131133

132134
// Change web domain IP
133-
135+
$v_newip='';
136+
$v_newip_public='';
137+
138+
if(!empty($_POST['v_ip'])) {
139+
$v_newip = $_POST['v_ip'];
140+
$v_newip_public = empty($ips[$v_newip]['NAT']) ? $v_newip : $ips[$v_newip]['NAT'];
141+
}
142+
134143
if (($v_ip != $_POST['v_ip']) && (empty($_SESSION['error_msg']))) {
135144
exec (HESTIA_CMD."v-change-web-domain-ip ".$v_username." ".escapeshellarg($v_domain)." ".escapeshellarg($_POST['v_ip'])." 'no'", $output, $return_var);
136145
check_return_code($return_var,$output);
@@ -144,7 +153,7 @@
144153
exec (HESTIA_CMD."v-list-dns-domain ".$v_username." ".escapeshellarg($v_domain)." json", $output, $return_var);
145154
unset($output);
146155
if ($return_var == 0 ) {
147-
exec (HESTIA_CMD."v-change-dns-domain-ip ".$v_username." ".escapeshellarg($v_domain)." ".escapeshellarg($_POST['v_ip'])." 'no'", $output, $return_var);
156+
exec (HESTIA_CMD."v-change-dns-domain-ip ".$v_username." ".escapeshellarg($v_domain)." ".escapeshellarg($v_newip_public)." 'no'", $output, $return_var);
148157
check_return_code($return_var,$output);
149158
unset($output);
150159
$restart_dns = 'yes';
@@ -157,7 +166,7 @@
157166
exec (HESTIA_CMD."v-list-dns-domain ".$v_username." ".escapeshellarg($v_alias)." json", $output, $return_var);
158167
unset($output);
159168
if ($return_var == 0 ) {
160-
exec (HESTIA_CMD."v-change-dns-domain-ip ".$v_username." ".escapeshellarg($v_alias)." ".escapeshellarg($_POST['v_ip']), $output, $return_var);
169+
exec (HESTIA_CMD."v-change-dns-domain-ip ".$v_username." ".escapeshellarg($v_alias)." ".escapeshellarg($v_newip_public), $output, $return_var);
161170
check_return_code($return_var,$output);
162171
unset($output);
163172
$restart_dns = 'yes';
@@ -215,7 +224,7 @@
215224
exec (HESTIA_CMD."v-list-dns-domain ".$v_username." ".escapeshellarg($v_domain), $output, $return_var);
216225
unset($output);
217226
if ($return_var == 0) {
218-
exec (HESTIA_CMD."v-add-dns-on-web-alias ".$v_username." ".escapeshellarg($alias)." ".$v_ip." no", $output, $return_var);
227+
exec (HESTIA_CMD."v-add-dns-on-web-alias ".$v_username." ".escapeshellarg($alias)." ".escapeshellarg($v_newip_public ?: $v_ip_public)." no", $output, $return_var);
219228
check_return_code($return_var,$output);
220229
unset($output);
221230
$restart_dns = 'yes';

0 commit comments

Comments
 (0)