This commit is contained in:
sindricn
2025-09-24 15:57:45 +08:00
parent 914c8eaca5
commit 43818ba7fe
4 changed files with 38 additions and 20 deletions
+8 -6
View File
@@ -15,12 +15,14 @@ else
exit 1
fi
# 防火墙类型常量
readonly FW_UNKNOWN=0
readonly FW_IPTABLES=1
readonly FW_FIREWALLD=2
readonly FW_UFW=3
readonly FW_NFTABLES=4
# 防火墙类型常量 (防止重复定义)
if [[ -z "${FW_UNKNOWN:-}" ]]; then
readonly FW_UNKNOWN=0
readonly FW_IPTABLES=1
readonly FW_FIREWALLD=2
readonly FW_UFW=3
readonly FW_NFTABLES=4
fi
# 全局变量
DETECTED_FIREWALL=$FW_UNKNOWN
+10 -4
View File
@@ -15,10 +15,16 @@ else
exit 1
fi
# 配置路径
readonly HYSTERIA_CONFIG="/etc/hysteria/config.yaml"
readonly OUTBOUND_TEMPLATES_DIR="$SCRIPT_DIR/outbound-templates"
readonly BACKUP_DIR="/var/backups/s-hy2/outbound"
# 配置路径 (防止重复定义)
if [[ -z "${HYSTERIA_CONFIG:-}" ]]; then
readonly HYSTERIA_CONFIG="/etc/hysteria/config.yaml"
fi
if [[ -z "${OUTBOUND_TEMPLATES_DIR:-}" ]]; then
readonly OUTBOUND_TEMPLATES_DIR="$SCRIPT_DIR/outbound-templates"
fi
if [[ -z "${BACKUP_DIR:-}" ]]; then
readonly BACKUP_DIR="/var/backups/s-hy2/outbound"
fi
# 初始化出站管理
init_outbound_manager() {
+10 -4
View File
@@ -20,10 +20,16 @@ if [[ -f "$SCRIPT_DIR/firewall-manager.sh" ]]; then
source "$SCRIPT_DIR/firewall-manager.sh"
fi
# 配置路径
readonly HYSTERIA_CONFIG="/etc/hysteria/config.yaml"
readonly HYSTERIA_SERVICE="hysteria-server"
readonly CHECK_TIMEOUT=10
# 配置路径 (防止重复定义)
if [[ -z "${HYSTERIA_CONFIG:-}" ]]; then
readonly HYSTERIA_CONFIG="/etc/hysteria/config.yaml"
fi
if [[ -z "${HYSTERIA_SERVICE:-}" ]]; then
readonly HYSTERIA_SERVICE="hysteria-server"
fi
if [[ -z "${CHECK_TIMEOUT:-}" ]]; then
readonly CHECK_TIMEOUT=10
fi
# 全面部署检查
comprehensive_deploy_check() {
+10 -6
View File
@@ -6,14 +6,18 @@
# 严格错误处理
set -euo pipefail
# 安全下载配置
readonly DOWNLOAD_TIMEOUT=30
readonly MAX_FILE_SIZE=$((10 * 1024 * 1024)) # 10MB
readonly ALLOWED_PROTOCOLS=("https")
readonly USER_AGENT="s-hy2-secure-downloader/1.0"
# 安全下载配置 (防止重复定义)
if [[ -z "${DOWNLOAD_TIMEOUT:-}" ]]; then
readonly DOWNLOAD_TIMEOUT=30
readonly MAX_FILE_SIZE=$((10 * 1024 * 1024)) # 10MB
readonly ALLOWED_PROTOCOLS=("https")
readonly USER_AGENT="s-hy2-secure-downloader/1.0"
fi
# 临时目录
readonly SECURE_TEMP_DIR="/tmp/s-hy2-secure-$$"
if [[ -z "${SECURE_TEMP_DIR:-}" ]]; then
readonly SECURE_TEMP_DIR="/tmp/s-hy2-secure-$$"
fi
# 清理函数
cleanup_temp_files() {