diff --git a/bin/create_config.sh b/bin/create_config.sh index 9a43dff..986c341 100644 --- a/bin/create_config.sh +++ b/bin/create_config.sh @@ -106,6 +106,29 @@ create_tuic_self_tls_config() { green "成功创建配置" } +create_hysteria_self_tls_config() { + local SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 + local CONFIG_FILE="$SCRIPT_DIR/../config/config.json" + + cp "$SCRIPT_DIR/../config/template/hysteria/hysteria_self_tls_config.json" "$CONFIG_FILE" + + # 生成自签名证书和设置域名 + local DOMAIN="bing.com" + create_self_tls "$DOMAIN" + sed -i "s/你的域名/$DOMAIN/g" "$CONFIG_FILE" + + # 设置端口 + update_port + + # 设置密码 + update_password + + # 设置混淆密码 + update_obfs_password + + green "成功创建配置" +} + create_config(){ local SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 local CONFIG_FILE="$SCRIPT_DIR/../config/config.json" @@ -132,7 +155,7 @@ create_config(){ ;; 2) echo "功能未是实现, 敬请期待..." - return 0 + create_hysteria_config ;; *) echo "无效的选择, 请重新选择." diff --git a/bin/password.sh b/bin/password.sh index 7329b04..f58886a 100644 --- a/bin/password.sh +++ b/bin/password.sh @@ -14,3 +14,18 @@ update_password() { echo "设置密码成功" } + +# 更新混淆密码 +update_obfs_password() { + local SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # 脚本文件夹绝对路径 + local CONFIG_FILE="$SCRIPT_DIR/../config/config.json" + + + # 生成一个长度为16的随机密码 + local NEW_PASSWORD=$(gen_password 16) + + # 修改密码 + sed -i 's/你的混淆密码/'"$NEW_PASSWORD"'/g' $CONFIG_FILE + + echo "设置密码成功" +} diff --git a/config/template/hysteria/hysteria_self_tls_config.json b/config/template/hysteria/hysteria_self_tls_config.json new file mode 100644 index 0000000..f947ff9 --- /dev/null +++ b/config/template/hysteria/hysteria_self_tls_config.json @@ -0,0 +1,53 @@ +{ + "log": { + "level": "info", + "timestamp": true, + "output": "/var/log/sing-box/sing-box.log" + }, + "inbounds": [ + { + "type": "hysteria2", + "tag": "hysteria2-in", + "listen": "::", + "listen_port": 8443, + "obfs": { + "type": "salamander", + "password": "你的混淆密码" + }, + "users": [ + { + "name": "user1", + "password": "你的密码" + } + ], + "up_mbps": 100, + "down_mbps": 100, + "tls": { + "enabled": true, + "server_name": "你的域名", + "alpn": ["h3"], + "key_path": "/etc/sing-box/tls/self-tls/server.key", + "certificate_path": "/etc/sing-box/tls/self-tls/server.crt" + } + } + ], + "outbounds": [ + { + "type": "direct", + "tag": "direct" + }, + { + "type": "block", + "tag": "block" + } + ], + "route": { + "rules": [ + { + "ip_is_private": true, + "outbound": "block" + } + ], + "final": "direct" + } +}