Browse Source

Merge remote-tracking branch 'upstream/main' into ipv6

asmcc 3 years ago
parent
commit
52fef291d9

+ 1 - 1
bin/v-add-firewall-chain

@@ -31,7 +31,7 @@ source $HESTIA/func/firewall.sh
 source_conf "$HESTIA/conf/hestia.conf"
 source_conf "$HESTIA/conf/hestia.conf"
 
 
 # Get hestia port by reading nginx.conf
 # Get hestia port by reading nginx.conf
-hestiaport=$(grep 'listen' $HESTIA/nginx/conf/nginx.conf | awk '{print $2}' | sed "s|;||")
+hestiaport=$(grep -m 1 'listen' $HESTIA/nginx/conf/nginx.conf | awk '{print $2}' | sed "s|;||")
 if [ -z "$hestiaport" ]; then
 if [ -z "$hestiaport" ]; then
 	hestiaport=8083
 	hestiaport=8083
 fi
 fi

+ 7 - 2
bin/v-change-sys-port

@@ -12,6 +12,7 @@
 
 
 # Argument definition
 # Argument definition
 PORT=$1
 PORT=$1
+NGINX_CONFIG="$HESTIA/nginx/conf/nginx.conf"									
 
 
 # Includes
 # Includes
 # shellcheck source=/etc/hestiacp/hestia.conf
 # shellcheck source=/etc/hestiacp/hestia.conf
@@ -54,7 +55,8 @@ check_hestia_demo_mode
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
 # Get original port
 # Get original port
-ORIGINAL_PORT=$(cat $HESTIA/nginx/conf/nginx.conf | grep "listen" | sed 's/[^0-9]*//g')
+LISTEN_ROWS=$(cat ${NGINX_CONFIG} | grep -c "listen")
+ORIGINAL_PORT=$(cat ${NGINX_CONFIG} | grep -m 1 "listen" | sed 's/[^0-9]*//g')
 
 
 # Check if port is different to nginx.conf
 # Check if port is different to nginx.conf
 if [ "$ORIGINAL_PORT" = "$PORT" ]; then
 if [ "$ORIGINAL_PORT" = "$PORT" ]; then
@@ -64,7 +66,7 @@ else
 	# Set new port in config via v-change-sys-config-value
 	# Set new port in config via v-change-sys-config-value
 	$BIN/v-change-sys-config-value "BACKEND_PORT" "$PORT"
 	$BIN/v-change-sys-config-value "BACKEND_PORT" "$PORT"
 	# Replace port in config files.
 	# Replace port in config files.
-	sed -i "/listen/c\        listen          $PORT ssl;" $HESTIA/nginx/conf/nginx.conf
+	sed -i "s/\(listen[ \t]*.*[: \t]\)[0-9][0-9]*\([^0-9]*ssl\;$\)/\1$PORT\2/" ${NGINX_CONFIG}
 	if [ -d /etc/roundcube/ ]; then
 	if [ -d /etc/roundcube/ ]; then
 		sed -i "/password_hestia_port/c\$rcmail_config['password_hestia_port'] = '$PORT';" /etc/roundcube/plugins/password/config.inc.php
 		sed -i "/password_hestia_port/c\$rcmail_config['password_hestia_port'] = '$PORT';" /etc/roundcube/plugins/password/config.inc.php
 	fi
 	fi
@@ -97,6 +99,9 @@ fi
 
 
 # Logging
 # Logging
 $BIN/v-log-action "system" "Warning" "System" "Hestia Control Panel backend port changed (New Value: $PORT, Old Value: $ORIGINAL_PORT)."
 $BIN/v-log-action "system" "Warning" "System" "Hestia Control Panel backend port changed (New Value: $PORT, Old Value: $ORIGINAL_PORT)."
+if [ $LISTEN_ROWS -gt 1 ]; then
+	$BIN/v-log-action "system" "Warning" "System" "Hestia Control Panel backend port: Use first of $LISTEN_ROWS listened ports in ${NGINX_CONFIG}"
+fi
 log_event "$OK" "$ARGUMENTS"
 log_event "$OK" "$ARGUMENTS"
 
 
 exit
 exit

+ 1 - 1
func/syshealth.sh

@@ -285,7 +285,7 @@ function syshealth_repair_system_config() {
 
 
 	# Backend port
 	# Backend port
 	if [[ -z $(check_key_exists 'BACKEND_PORT') ]]; then
 	if [[ -z $(check_key_exists 'BACKEND_PORT') ]]; then
-		ORIGINAL_PORT=$(cat $HESTIA/nginx/conf/nginx.conf | grep "listen" | sed 's/[^0-9]*//g')
+		ORIGINAL_PORT=$(cat $HESTIA/nginx/conf/nginx.conf | grep -m 1 "listen" | sed 's/[^0-9]*//g')
 		echo "[ ! ] Adding missing variable to hestia.conf: BACKEND_PORT ('$ORIGINAL_PORT')"
 		echo "[ ! ] Adding missing variable to hestia.conf: BACKEND_PORT ('$ORIGINAL_PORT')"
 		$BIN/v-change-sys-config-value 'BACKEND_PORT' $ORIGINAL_PORT
 		$BIN/v-change-sys-config-value 'BACKEND_PORT' $ORIGINAL_PORT
 	fi
 	fi

+ 1 - 1
web/js/pages/add_dns_rec.js

@@ -2,7 +2,7 @@
 //
 //
 // Updates database dns record dynamically, showing its full domain path
 // Updates database dns record dynamically, showing its full domain path
 App.Actions.DB.update_dns_record_hint = function (elm, hint) {
 App.Actions.DB.update_dns_record_hint = function (elm, hint) {
-	domain = $('input[name="v_domain"]').val();
+	const domain = $('input[name="v_domain"]').val();
 	// clean hint
 	// clean hint
 	if (hint.trim() == '') {
 	if (hint.trim() == '') {
 		$(elm).parent().find('.hint').text('');
 		$(elm).parent().find('.hint').text('');

+ 1 - 1
web/js/pages/edit_dns_rec.js

@@ -3,7 +3,7 @@
 // Updates database dns record dynamically, showing its full domain path
 // Updates database dns record dynamically, showing its full domain path
 App.Actions.DB.update_dns_record_hint = function (elm, hint) {
 App.Actions.DB.update_dns_record_hint = function (elm, hint) {
 	// clean hint
 	// clean hint
-	domain = $('input[name="v_domain"]').val();
+	const domain = $('input[name="v_domain"]').val();
 	if (hint.trim() == '') {
 	if (hint.trim() == '') {
 		$(elm).parent().find('.hint').text('');
 		$(elm).parent().find('.hint').text('');
 	}
 	}

+ 8 - 1
web/js/pages/edit_web.js

@@ -213,7 +213,14 @@ $(function () {
 		var elm = $(evt.target);
 		var elm = $(evt.target);
 		App.Actions.WEB.passwordChanged(elm);
 		App.Actions.WEB.passwordChanged(elm);
 	});
 	});
-	App.Actions.WEB.toggle_letsencrypt($('input[name=v_letsencrypt]'));
+	$('input[name=v_letsencrypt]').change(function (evt) {
+		var input = $(evt.target);
+		if (input.prop('checked')) {
+			$('#ssl-details').hide();
+		} else {
+			$('#ssl-details').show();
+		}
+	});
 
 
 	$('select[name="v_stats"]').change(function (evt) {
 	$('select[name="v_stats"]').change(function (evt) {
 		var select = $(evt.target);
 		var select = $(evt.target);

+ 17 - 16
web/templates/footer.php

@@ -74,24 +74,25 @@
 <?php if (!empty($_SESSION["error_msg"])): ?>
 <?php if (!empty($_SESSION["error_msg"])): ?>
 	<div>
 	<div>
 		<script>
 		<script>
-			// TODO: This is broken, $ is not defined
-			$(function() {
-				$('#dialog:ui-dialog').dialog('destroy');
-				$('#dialog-message').dialog({
-					modal: true,
-					resizable: false,
-					buttons: {
-						Ok: function() {
-							$(this).dialog('close');
+			window.onload=function(){
+				$(function() {
+					$('#dialog:ui-dialog').dialog('destroy');
+					$('#dialog-message').dialog({
+						modal: true,
+						resizable: false,
+						buttons: {
+							Ok: function() {
+								$(this).dialog('close');
+							}
+						},
+						create: function() {
+							var buttonGroup = $(this).closest(".ui-dialog").find('.ui-dialog-buttonset');
+							buttonGroup.find('button:first').addClass('button submit')
+							buttonGroup.find('button:last').addClass('button button-secondary cancel');
 						}
 						}
-					},
-					create: function() {
-						var buttonGroup = $(this).closest(".ui-dialog").find('.ui-dialog-buttonset');
-						buttonGroup.find('button:first').addClass('button submit')
-						buttonGroup.find('button:last').addClass('button button-secondary cancel');
-					}
+					});
 				});
 				});
-			});
+			}
 		</script>
 		</script>
 		<div id="dialog-message" title="">
 		<div id="dialog-message" title="">
 			<p><?= htmlentities($_SESSION["error_msg"]) ?></p>
 			<p><?= htmlentities($_SESSION["error_msg"]) ?></p>

+ 23 - 22
web/templates/pages/add_firewall_ipset.php

@@ -91,34 +91,35 @@
 	blacklist_iplists.sort(function (a, b) {
 	blacklist_iplists.sort(function (a, b) {
 		return a.name > b.name;
 		return a.name > b.name;
 	});
 	});
+	window.onload = function(){
+		$(function () {
+			var targetElement = document.getElementById('datasource_list');
 
 
-	$(function () {
-		var targetElement = document.getElementById('datasource_list');
-
-		// Blacklist
-		var newEl = document.createElement("option");
-		newEl.text = "<?= _("BLACKLIST") ?>";
-		newEl.disabled = true;
-		targetElement.appendChild(newEl);
-
-		blacklist_iplists.forEach(iplist => {
+			// Blacklist
 			var newEl = document.createElement("option");
 			var newEl = document.createElement("option");
-			newEl.text = iplist.name;
-			newEl.value = iplist.source;
+			newEl.text = "<?= _("BLACKLIST") ?>";
+			newEl.disabled = true;
 			targetElement.appendChild(newEl);
 			targetElement.appendChild(newEl);
-		});
 
 
-		// IPVERSE
-		var newEl = document.createElement("option");
-		newEl.text = "<?= _("IPVERSE") ?>";
-		newEl.disabled = true;
-		targetElement.appendChild(newEl);
+			blacklist_iplists.forEach(iplist => {
+				var newEl = document.createElement("option");
+				newEl.text = iplist.name;
+				newEl.value = iplist.source;
+				targetElement.appendChild(newEl);
+			});
 
 
-		country_iplists.forEach(iplist => {
+			// IPVERSE
 			var newEl = document.createElement("option");
 			var newEl = document.createElement("option");
-			newEl.text = iplist.name;
-			newEl.value = iplist.source;
+			newEl.text = "<?= _("IPVERSE") ?>";
+			newEl.disabled = true;
 			targetElement.appendChild(newEl);
 			targetElement.appendChild(newEl);
+
+			country_iplists.forEach(iplist => {
+				var newEl = document.createElement("option");
+				newEl.text = iplist.name;
+				newEl.value = iplist.source;
+				targetElement.appendChild(newEl);
+			});
 		});
 		});
-	});
+	}
 </script>
 </script>