diff --git a/V2bX.sh b/V2bX.sh index 38ee83d..e707de5 100644 --- a/V2bX.sh +++ b/V2bX.sh @@ -245,11 +245,11 @@ show_log() { } install_bbr() { - bash <(curl -L -s https://raw.githubusercontents.com/chiakge/Linux-NetSpeed/master/tcp.sh) + bash <(curl -L -s https://github.com/ylx2016/Linux-NetSpeed/raw/master/tcpx.sh) } update_shell() { - wget -O /usr/bin/V2bX -N --no-check-certificate https://raw.githubusercontents.com/InazumaV/V2bX-script/master/V2bX.sh + wget -O /usr/bin/V2bX -N --no-check-certificate https://raw.githubusercontent.com/InazumaV/V2bX-script/master/V2bX.sh if [[ $? != 0 ]]; then echo "" echo -e "${red}下载脚本失败,请检查本机能否连接 Github${plain}" @@ -353,132 +353,294 @@ show_V2bX_version() { fi } +add_node_config() { + echo -e "${green}请选择节点核心类型:${plain}" + echo -e "${green}1. xray${plain}" + echo -e "${green}2. singbox${plain}" + read -rp "请输入:" core_type + if [ "$core_type" == "1" ]; then + core="xray" + core_xray=true + elif [ "$core_type" == "2" ]; then + core="sing" + core_sing=true + else + echo "无效的选择。请选择 1 或 2。" + continue + fi + while true; do + read -rp "请输入节点Node ID:" NodeID + # 判断NodeID是否为正整数 + if [[ "$NodeID" =~ ^[0-9]+$ ]]; then + break # 输入正确,退出循环 + else + echo "错误:请输入正确的数字作为Node ID。" + fi + done + + echo -e "${yellow}请选择节点传输协议:${plain}" + echo -e "${green}1. Shadowsocks${plain}" + echo -e "${green}2. Vless${plain}" + echo -e "${green}3. Vmess${plain}" + echo -e "${green}4. Hysteria${plain}" + echo -e "${green}5. Hysteria2${plain}" + echo -e "${green}6. Tuic${plain}" + echo -e "${green}7. Trojan${plain}" + read -rp "请输入:" NodeType + case "$NodeType" in + 1 ) NodeType="shadowsocks" ;; + 2 ) NodeType="vless" ;; + 3 ) NodeType="vmess" ;; + 4 ) NodeType="hysteria" ;; + 5 ) NodeType="hysteria2" ;; + 6 ) NodeType="tuic" ;; + 7 ) NodeType="trojan" ;; + * ) NodeType="shadowsocks" ;; + esac + + nodes_config+=( + { + \"Core\": \"$core\", + \"ApiHost\": \"$ApiHost\", + \"ApiKey\": \"$ApiKey\", + \"NodeID\": $NodeID, + \"NodeType\": \"$NodeType\", + \"Timeout\": 4, + \"ListenIP\": \"0.0.0.0\", + \"SendIP\": \"0.0.0.0\", + \"EnableProxyProtocol\": false, + \"EnableUot\": true, + \"EnableTFO\": true, + \"DNSType\": \"UseIPv4\" + } + ) + nodes_config+=(",") +} + + generate_config_file() { echo -e "${yellow}V2bX 配置文件生成向导${plain}" echo -e "${red}请阅读以下注意事项:${plain}" echo -e "${red}1. 目前该功能正处测试阶段${plain}" - echo -e "${red}2. 生成的配置文件会保存到 /etc/V2bX/config.yml${plain}" - echo -e "${red}3. 原来的配置文件会保存到 /etc/V2bX/config.yml.bak${plain}" + echo -e "${red}2. 生成的配置文件会保存到 /etc/V2bX/config.json${plain}" + echo -e "${red}3. 原来的配置文件会保存到 /etc/V2bX/config.json.bak${plain}" echo -e "${red}4. 目前不支持TLS${plain}" - read -rp "是否继续生成配置文件?(y/n)" generate_config_file_continue - if [[ $generate_config_file_continue =~ "y"|"Y" ]]; then - read -rp "请输入机场网址:" ApiHost - read -rp "请输入面板对接API Key:" ApiKey - read -rp "请输入节点Node ID:" NodeID - echo -e "${yellow}请选择节点传输协议,如未列出则不支持:${plain}" - echo -e "${green}1. Shadowsocks ${plain}" - echo -e "${green}2. V2ray ${plain}" - echo -e "${green}3. Trojan ${plain}" - read -rp "请输入机场传输协议 [1-4,默认1]:" NodeType - case "$NodeType" in - 1 ) NodeType="Shadowsocks" ;; - 2 ) NodeType="V2ray" ;; - 3 ) NodeType="Trojan" ;; - * ) NodeType="Shadowsocks" ;; - esac - cd /etc/V2bX - mv config.yml config.yml.bak - cat < /etc/V2bX/config.yml -CoreConfig: - Type: "xray" # Core type, default support "xray" and "hy". If you need many cores, use " " to split - XrayConfig: - Log: - Level: warning # Log level: none, error, warning, info, debug - AccessPath: # /etc/XrayR/access.Log - ErrorPath: # /etc/XrayR/error.log - DnsConfigPath: # /etc/XrayR/dns.json # Path to dns config, check https://xtls.github.io/config/dns.html for help - RouteConfigPath: # /etc/XrayR/route.json # Path to route config, check https://xtls.github.io/config/routing.html for help - InboundConfigPath: # /etc/XrayR/custom_inbound.json # Path to custom inbound config, check https://xtls.github.io/config/inbound.html for help - OutboundConfigPath: # /etc/XrayR/custom_outbound.json # Path to custom outbound config, check https://xtls.github.io/config/outbound.html for help - ConnectionConfig: - Handshake: 4 # Handshake time limit, Second - ConnIdle: 30 # Connection idle time limit, Second - UplinkOnly: 2 # Time limit when the connection downstream is closed, Second - DownlinkOnly: 4 # Time limit when the connection is closed after the uplink is closed, Second - BufferSize: 64 # The internal cache size of each connection, kB -Nodes: - - ApiConfig: - ApiHost: "http://127.0.0.1:667" - ApiKey: "123" - NodeID: 41 - NodeType: V2ray # Node type: V2ray, Shadowsocks, Trojan - Timeout: 30 # Timeout for the api request - RuleListPath: # /etc/XrayR/rulelist Path to local rulelist file - ControllerConfig: - ListenIP: 0.0.0.0 # IP address you want to listen - SendIP: 0.0.0.0 # IP address you want to send pacakage - XrayOptions: - EnableDNS: false # Use custom DNS config, Please ensure that you set the dns.json well - DNSType: AsIs # AsIs, UseIP, UseIPv4, UseIPv6, DNS strategy - EnableTFO: false # Enable TCP Fast Open - EnableProxyProtocol: false # Only works for WebSocket and TCP - EnableFallback: false # Only support for Trojan and Vless - FallBackConfigs: # Support multiple fallbacks - - SNI: # TLS SNI(Server Name Indication), Empty for any - Alpn: # Alpn, Empty for any - Path: # HTTP PATH, Empty for any - Dest: 80 # Required, Destination of fallback, check https://xtls.github.io/config/features/fallback.html for details. - ProxyProtocolVer: 0 # Send PROXY protocol version, 0 for disable - HyOptions: - Resolver: "udp://1.1.1.1:53" # DNS resolver address - ResolvePreference: 64 # DNS IPv4/IPv6 preference. Available options: "64" (IPv6 first, fallback to IPv4), "46" (IPv4 first, fallback to IPv6), "6" (IPv6 only), "4" (IPv4 only) - SendDevice: "eth0" # Bind device for outbound connections (usually requires root) - LimitConfig: - EnableRealtime: false # Check device limit on real time - SpeedLimit: 0 # Mbps, Local settings will replace remote settings, 0 means disable - DeviceLimit: 0 # Local settings will replace remote settings, 0 means disable - ConnLimit: 0 # Connecting limit, only working for TCP, 0mean - EnableIpRecorder: false # Enable online ip report - IpRecorderConfig: - Type: "Recorder" # Recorder type: Recorder, Redis - RecorderConfig: - Url: "http://127.0.0.1:123" # Report url - Token: "123" # Report token - Timeout: 10 # Report timeout, sec. - RedisConfig: - Address: "127.0.0.1:6379" # Redis address - Password: "" # Redis password - DB: 0 # Redis DB - Expiry: 60 # redis expiry time, sec. - Periodic: 60 # Report interval, sec. - EnableIpSync: false # Enable online ip sync - EnableDynamicSpeedLimit: false # Enable dynamic speed limit - DynamicSpeedLimitConfig: - Periodic: 60 # Time to check the user traffic , sec. - Traffic: 0 # Traffic limit, MB - SpeedLimit: 0 # Speed limit, Mbps - ExpireTime: 0 # Time limit, sec. - CertConfig: - CertMode: dns # Option about how to get certificate: none, file, http, dns, reality, remote. Choose "none" will forcedly disable the tls config. - CertDomain: "node1.test.com" # Domain to cert - CertFile: /etc/XrayR/cert/node1.test.com.cert # Provided if the CertMode is file - KeyFile: /etc/XrayR/cert/node1.test.com.key - Provider: alidns # DNS cert provider, Get the full support list here: https://go-acme.github.io/lego/dns/ - Email: test@me.com - DNSEnv: # DNS ENV option used by DNS provider - ALICLOUD_ACCESS_KEY: aaa - ALICLOUD_SECRET_KEY: bbb - RealityConfig: # This config like RealityObject for xray-core, please check https://xtls.github.io/config/transport.html#realityobject - Dest: 80 # Same fallback dest - Xver: 0 # Same fallback xver - ServerNames: - - "example.com" - - "www.example.com" - PrivateKey: "" # Private key for server - MinClientVer: "" # Min client version - MaxClientVer: "" # Max client version - MaxTimeDiff: 0 # Max time difference, ms - ShortIds: # Short ids - - "" - - "0123456789abcdef" + echo -e "${red}5. 使用此功能生成的配置文件会自带审计,确定继续?(y/n)${plain}" + read -rp "请输入:" continue_prompt + if [[ "$continue_prompt" =~ ^[Nn][Oo]? ]]; then + exit 0 + fi + + nodes_config=() + first_node=true + core_xray=false + core_sing=false + fixed_api_info=false + check_api=false + + while true; do + if [ "$first_node" = true ]; then + read -rp "请输入机场网址:" ApiHost + read -rp "请输入面板对接API Key:" ApiKey + read -rp "是否设置固定的机场网址和API Key?(y/n)" fixed_api + if [ "$fixed_api" = "y" ] || [ "$fixed_api" = "Y" ]; then + fixed_api_info=true + echo -e "${red}成功固定地址${plain}" + fi + first_node=false + add_node_config + else + read -rp "是否继续添加节点配置?(回车继续,输入n或no退出)" continue_adding_node + if [[ "$continue_adding_node" =~ ^[Nn][Oo]? ]]; then + break + elif [ "$fixed_api_info" = false ]; then + read -rp "请输入机场网址:" ApiHost + read -rp "请输入面板对接API Key:" ApiKey + fi + add_node_config + fi + done + + # 根据核心类型生成 Cores + if [ "$core_xray" = true ] && [ "$core_sing" = true ]; then + cores_config="[ + { + \"Type\": \"xray\", + \"Log\": { + \"Level\": \"error\", + \"ErrorPath\": \"/etc/V2bX/error.log\" + }, + \"OutboundConfigPath\": \"/etc/V2bX/custom_outbound.json\", + \"RouteConfigPath\": \"/etc/V2bX/route.json\" + }, + { + \"Type\": \"sing\", + \"Log\": { + \"Level\": \"error\", + \"Timestamp\": true + }, + \"NTP\": { + \"Enable\": true, + \"Server\": \"time.apple.com\", + \"ServerPort\": 0 + } + } + ]" + elif [ "$core_xray" = true ]; then + cores_config="[ + { + \"Type\": \"xray\", + \"Log\": { + \"Level\": \"error\", + \"ErrorPath\": \"/etc/V2bX/error.log\" + }, + \"OutboundConfigPath\": \"/etc/V2bX/custom_outbound.json\", + \"RouteConfigPath\": \"/etc/V2bX/route.json\" + } + ]" + elif [ "$core_sing" = true ]; then + cores_config="[ + { + \"Type\": \"sing\", + \"Log\": { + \"Level\": \"error\", + \"Timestamp\": true + }, + \"NTP\": { + \"Enable\": true, + \"Server\": \"time.apple.com\", + \"ServerPort\": 0 + } + } + ]" + fi + + # 切换到配置文件目录 + cd /etc/V2bX + + # 备份旧的配置文件 + mv config.json config.json.bak + formatted_nodes_config=$(echo "${nodes_config[*]}" | sed 's/,\s*$//') + + # 创建 config.json 文件 + cat < /etc/V2bX/config.json + { + "Log": { + "Level": "error", + "Output": "" + }, + "Cores": $cores_config, + "Nodes": [$formatted_nodes_config] + } EOF - echo -e "${green}V2bX 配置文件生成完成,正在重新启动 V2bX 服务${plain}" - restart 0 - before_show_menu - else - echo -e "${red}已取消 V2bX 配置文件生成${plain}" - before_show_menu - fi + + # 创建 custom_outbound.json 文件 + cat < /etc/V2bX/custom_outbound.json + [ + { + "tag": "IPv4_out", + "protocol": "freedom", + "settings": { + "domainStrategy": "UseIPv4" + } + }, + { + "tag": "IPv6_out", + "protocol": "freedom", + "settings": { + "domainStrategy": "UseIPv6" + } + }, + { + "tag": "direct", + "protocol": "freedom" + }, + { + "protocol": "blackhole", + "tag": "block" + } + ] +EOF + + # 创建 route.json 文件 + cat < /etc/V2bX/route.json + { + "domainStrategy": "AsIs", + "rules": [ + { + "type": "field", + "outboundTag": "block", + "ip": [ + "geoip:private", + "58.87.70.69" + ] + }, + { + "type": "field", + "outboundTag": "direct", + "domain": [ + "domain:zgovps.com" + ] + }, + { + "type": "field", + "outboundTag": "block", + "domain": [ + "regexp:(api|ps|sv|offnavi|newvector|ulog.imap|newloc)(.map|).(baidu|n.shifen).com", + "regexp:(.+.|^)(360|so).(cn|com)", + "regexp:(Subject|HELO|SMTP)", + "regexp:(torrent|.torrent|peer_id=|info_hash|get_peers|find_node|BitTorrent|announce_peer|announce.php?passkey=)", + "regexp:(^.@)(guerrillamail|guerrillamailblock|sharklasers|grr|pokemail|spam4|bccto|chacuo|027168).(info|biz|com|de|net|org|me|la)", + "regexp:(.?)(xunlei|sandai|Thunder|XLLiveUD)(.)", + "regexp:(..||)(dafahao|mingjinglive|botanwang|minghui|dongtaiwang|falunaz|epochtimes|ntdtv|falundafa|falungong|wujieliulan|zhengjian).(org|com|net)", + "regexp:(ed2k|.torrent|peer_id=|announce|info_hash|get_peers|find_node|BitTorrent|announce_peer|announce.php?passkey=|magnet:|xunlei|sandai|Thunder|XLLiveUD|bt_key)", + "regexp:(.+.|^)(360|speedtest|fast).(cn|com|net)", + "regexp:(.*.||)(guanjia.qq.com|qqpcmgr|QQPCMGR)", + "regexp:(.*.||)(rising|kingsoft|duba|xindubawukong|jinshanduba).(com|net|org)", + "regexp:(.*.||)(netvigator|torproject).(com|cn|net|org)", + "regexp:(..||)(visa|mycard|gov|gash|beanfun|bank).", + "regexp:(.*.||)(gov|12377|12315|talk.news.pts.org|creaders|zhuichaguoji|efcc.org|cyberpolice|aboluowang|tuidang|epochtimes|nytimes|zhengjian|110.qq|mingjingnews|inmediahk|xinsheng|breakgfw|chengmingmag|jinpianwang|qi-gong|mhradio|edoors|renminbao|soundofhope|xizang-zhiye|bannedbook|ntdtv|12321|secretchina|dajiyuan|boxun|chinadigitaltimes|dwnews|huaglad|oneplusnews|epochweekly|cn.rfi).(cn|com|org|net|club|net|fr|tw|hk|eu|info|me)", + "regexp:(.*.||)(miaozhen|cnzz|talkingdata|umeng).(cn|com)", + "regexp:(.*.||)(mycard).(com|tw)", + "regexp:(.*.||)(gash).(com|tw)", + "regexp:(.bank.)", + "regexp:(.*.||)(pincong).(rocks)", + "regexp:(.*.||)(taobao).(com)", + "regexp:(.*.||)(laomoe|jiyou|ssss|lolicp|vv1234|0z|4321q|868123|ksweb|mm126).(com|cloud|fun|cn|gs|xyz|cc)", + "regexp:(flows|miaoko).(pages).(dev)" + ] + }, + { + "type": "field", + "outboundTag": "block", + "ip": [ + "127.0.0.1/32", + "10.0.0.0/8", + "fc00::/7", + "fe80::/10", + "172.16.0.0/12" + ] + }, + { + "type": "field", + "outboundTag": "block", + "protocol": [ + "bittorrent" + ] + }, + { + "type": "field", + "outboundTag": "block", + "port": "23,24,25,107,194,445,465,587,992,3389,6665-6669,6679,6697,6881-6999,7000" + } + ] + } +EOF + + + echo -e "${green}V2bX 配置文件生成完成,正在重新启动 V2bX 服务${plain}" + restart 0 + before_show_menu } # 放开防火墙端口 @@ -522,7 +684,7 @@ show_usage() { show_menu() { echo -e " ${green}V2bX 后端管理脚本,${plain}${red}不适用于docker${plain} ---- https://github.com/cubemaze/V2bX --- +--- https://github.com/InazumaV/V2bX --- ${green}0.${plain} 修改配置 ———————————————— ${green}1.${plain} 安装 V2bX diff --git a/initconfig.sh b/initconfig.sh new file mode 100644 index 0000000..efaabef --- /dev/null +++ b/initconfig.sh @@ -0,0 +1,295 @@ +#!/bin/bash +# 一键配置 + +add_node_config() { + echo -e "${green}请选择节点核心类型:${plain}" + echo -e "${green}1. xray${plain}" + echo -e "${green}2. singbox${plain}" + read -rp "请输入:" core_type + if [ "$core_type" == "1" ]; then + core="xray" + core_xray=true + elif [ "$core_type" == "2" ]; then + core="sing" + core_sing=true + else + echo "无效的选择。请选择 1 或 2。" + continue + fi + while true; do + read -rp "请输入节点Node ID:" NodeID + # 判断NodeID是否为正整数 + if [[ "$NodeID" =~ ^[0-9]+$ ]]; then + break # 输入正确,退出循环 + else + echo "错误:请输入正确的数字作为Node ID。" + fi + done + + echo -e "${yellow}请选择节点传输协议:${plain}" + echo -e "${green}1. Shadowsocks${plain}" + echo -e "${green}2. Vless${plain}" + echo -e "${green}3. Vmess${plain}" + echo -e "${green}4. Hysteria${plain}" + echo -e "${green}5. Hysteria2${plain}" + echo -e "${green}6. Tuic${plain}" + echo -e "${green}7. Trojan${plain}" + read -rp "请输入:" NodeType + case "$NodeType" in + 1 ) NodeType="shadowsocks" ;; + 2 ) NodeType="vless" ;; + 3 ) NodeType="vmess" ;; + 4 ) NodeType="hysteria" ;; + 5 ) NodeType="hysteria2" ;; + 6 ) NodeType="tuic" ;; + 7 ) NodeType="trojan" ;; + * ) NodeType="shadowsocks" ;; + esac + + nodes_config+=( + { + \"Core\": \"$core\", + \"ApiHost\": \"$ApiHost\", + \"ApiKey\": \"$ApiKey\", + \"NodeID\": $NodeID, + \"NodeType\": \"$NodeType\", + \"Timeout\": 4, + \"ListenIP\": \"0.0.0.0\", + \"SendIP\": \"0.0.0.0\", + \"EnableProxyProtocol\": false, + \"EnableUot\": true, + \"EnableTFO\": true, + \"DNSType\": \"UseIPv4\" + } + ) + nodes_config+=(",") +} + + +generate_config_file() { + echo -e "${yellow}V2bX 配置文件生成向导${plain}" + echo -e "${red}请阅读以下注意事项:${plain}" + echo -e "${red}1. 目前该功能正处测试阶段${plain}" + echo -e "${red}2. 生成的配置文件会保存到 /etc/V2bX/config.json${plain}" + echo -e "${red}3. 原来的配置文件会保存到 /etc/V2bX/config.json.bak${plain}" + echo -e "${red}4. 目前不支持TLS${plain}" + echo -e "${red}5. 使用此功能生成的配置文件会自带审计,确定继续?(y/n)${plain}" + read -rp "请输入:" continue_prompt + if [[ "$continue_prompt" =~ ^[Nn][Oo]? ]]; then + exit 0 + fi + + nodes_config=() + first_node=true + core_xray=false + core_sing=false + fixed_api_info=false + check_api=false + + while true; do + if [ "$first_node" = true ]; then + read -rp "请输入机场网址:" ApiHost + read -rp "请输入面板对接API Key:" ApiKey + read -rp "是否设置固定的机场网址和API Key?(y/n)" fixed_api + if [ "$fixed_api" = "y" ] || [ "$fixed_api" = "Y" ]; then + fixed_api_info=true + echo -e "${red}成功固定地址${plain}" + fi + first_node=false + add_node_config + else + read -rp "是否继续添加节点配置?(回车继续,输入n或no退出)" continue_adding_node + if [[ "$continue_adding_node" =~ ^[Nn][Oo]? ]]; then + break + elif [ "$fixed_api_info" = false ]; then + read -rp "请输入机场网址:" ApiHost + read -rp "请输入面板对接API Key:" ApiKey + fi + add_node_config + fi + done + + # 根据核心类型生成 Cores + if [ "$core_xray" = true ] && [ "$core_sing" = true ]; then + cores_config="[ + { + \"Type\": \"xray\", + \"Log\": { + \"Level\": \"error\", + \"ErrorPath\": \"/etc/V2bX/error.log\" + }, + \"OutboundConfigPath\": \"/etc/V2bX/custom_outbound.json\", + \"RouteConfigPath\": \"/etc/V2bX/route.json\" + }, + { + \"Type\": \"sing\", + \"Log\": { + \"Level\": \"error\", + \"Timestamp\": true + }, + \"NTP\": { + \"Enable\": true, + \"Server\": \"time.apple.com\", + \"ServerPort\": 0 + } + } + ]" + elif [ "$core_xray" = true ]; then + cores_config="[ + { + \"Type\": \"xray\", + \"Log\": { + \"Level\": \"error\", + \"ErrorPath\": \"/etc/V2bX/error.log\" + }, + \"OutboundConfigPath\": \"/etc/V2bX/custom_outbound.json\", + \"RouteConfigPath\": \"/etc/V2bX/route.json\" + } + ]" + elif [ "$core_sing" = true ]; then + cores_config="[ + { + \"Type\": \"sing\", + \"Log\": { + \"Level\": \"error\", + \"Timestamp\": true + }, + \"NTP\": { + \"Enable\": true, + \"Server\": \"time.apple.com\", + \"ServerPort\": 0 + } + } + ]" + fi + + # 切换到配置文件目录 + cd /etc/V2bX + + # 备份旧的配置文件 + mv config.json config.json.bak + formatted_nodes_config=$(echo "${nodes_config[*]}" | sed 's/,\s*$//') + + # 创建 config.json 文件 + cat < /etc/V2bX/config.json + { + "Log": { + "Level": "error", + "Output": "" + }, + "Cores": $cores_config, + "Nodes": [$formatted_nodes_config] + } +EOF + + # 创建 custom_outbound.json 文件 + cat < /etc/V2bX/custom_outbound.json + [ + { + "tag": "IPv4_out", + "protocol": "freedom", + "settings": { + "domainStrategy": "UseIPv4" + } + }, + { + "tag": "IPv6_out", + "protocol": "freedom", + "settings": { + "domainStrategy": "UseIPv6" + } + }, + { + "tag": "direct", + "protocol": "freedom" + }, + { + "protocol": "blackhole", + "tag": "block" + } + ] +EOF + + # 创建 route.json 文件 + cat < /etc/V2bX/route.json + { + "domainStrategy": "AsIs", + "rules": [ + { + "type": "field", + "outboundTag": "block", + "ip": [ + "geoip:private", + "58.87.70.69" + ] + }, + { + "type": "field", + "outboundTag": "direct", + "domain": [ + "domain:zgovps.com" + ] + }, + { + "type": "field", + "outboundTag": "block", + "domain": [ + "regexp:(api|ps|sv|offnavi|newvector|ulog.imap|newloc)(.map|).(baidu|n.shifen).com", + "regexp:(.+.|^)(360|so).(cn|com)", + "regexp:(Subject|HELO|SMTP)", + "regexp:(torrent|.torrent|peer_id=|info_hash|get_peers|find_node|BitTorrent|announce_peer|announce.php?passkey=)", + "regexp:(^.@)(guerrillamail|guerrillamailblock|sharklasers|grr|pokemail|spam4|bccto|chacuo|027168).(info|biz|com|de|net|org|me|la)", + "regexp:(.?)(xunlei|sandai|Thunder|XLLiveUD)(.)", + "regexp:(..||)(dafahao|mingjinglive|botanwang|minghui|dongtaiwang|falunaz|epochtimes|ntdtv|falundafa|falungong|wujieliulan|zhengjian).(org|com|net)", + "regexp:(ed2k|.torrent|peer_id=|announce|info_hash|get_peers|find_node|BitTorrent|announce_peer|announce.php?passkey=|magnet:|xunlei|sandai|Thunder|XLLiveUD|bt_key)", + "regexp:(.+.|^)(360|speedtest|fast).(cn|com|net)", + "regexp:(.*.||)(guanjia.qq.com|qqpcmgr|QQPCMGR)", + "regexp:(.*.||)(rising|kingsoft|duba|xindubawukong|jinshanduba).(com|net|org)", + "regexp:(.*.||)(netvigator|torproject).(com|cn|net|org)", + "regexp:(..||)(visa|mycard|gov|gash|beanfun|bank).", + "regexp:(.*.||)(gov|12377|12315|talk.news.pts.org|creaders|zhuichaguoji|efcc.org|cyberpolice|aboluowang|tuidang|epochtimes|nytimes|zhengjian|110.qq|mingjingnews|inmediahk|xinsheng|breakgfw|chengmingmag|jinpianwang|qi-gong|mhradio|edoors|renminbao|soundofhope|xizang-zhiye|bannedbook|ntdtv|12321|secretchina|dajiyuan|boxun|chinadigitaltimes|dwnews|huaglad|oneplusnews|epochweekly|cn.rfi).(cn|com|org|net|club|net|fr|tw|hk|eu|info|me)", + "regexp:(.*.||)(miaozhen|cnzz|talkingdata|umeng).(cn|com)", + "regexp:(.*.||)(mycard).(com|tw)", + "regexp:(.*.||)(gash).(com|tw)", + "regexp:(.bank.)", + "regexp:(.*.||)(pincong).(rocks)", + "regexp:(.*.||)(taobao).(com)", + "regexp:(.*.||)(laomoe|jiyou|ssss|lolicp|vv1234|0z|4321q|868123|ksweb|mm126).(com|cloud|fun|cn|gs|xyz|cc)", + "regexp:(flows|miaoko).(pages).(dev)" + ] + }, + { + "type": "field", + "outboundTag": "block", + "ip": [ + "127.0.0.1/32", + "10.0.0.0/8", + "fc00::/7", + "fe80::/10", + "172.16.0.0/12" + ] + }, + { + "type": "field", + "outboundTag": "block", + "protocol": [ + "bittorrent" + ] + }, + { + "type": "field", + "outboundTag": "block", + "port": "23,24,25,107,194,445,465,587,992,3389,6665-6669,6679,6697,6881-6999,7000" + } + ] + } +EOF + + + echo -e "${green}V2bX 配置文件生成完成,正在重新启动服务${plain}" + v2bx restart +} + +install_bbr() { + bash <(curl -L -s https://github.com/ylx2016/Linux-NetSpeed/raw/master/tcpx.sh) +} \ No newline at end of file diff --git a/install.sh b/install.sh index 3d5ebf6..3994ad6 100644 --- a/install.sh +++ b/install.sh @@ -75,9 +75,13 @@ install_base() { if [[ x"${release}" == x"centos" ]]; then yum install epel-release -y yum install wget curl unzip tar crontabs socat -y + yum install ca-certificates wget -y + update-ca-trust force-enable else apt-get update -y apt install wget curl unzip tar cron socat -y + apt-get install ca-certificates wget -y + update-ca-certificates fi } @@ -117,10 +121,10 @@ install_V2bX() { else last_version=$1 url="https://github.com/InazumaV/V2bX/releases/download/${last_version}/V2bX-linux-${arch}.zip" - echo -e "开始安装 V2bX v$1" + echo -e "开始安装 V2bX $1" wget -q -N --no-check-certificate -O /usr/local/V2bX/V2bX-linux.zip ${url} if [[ $? -ne 0 ]]; then - echo -e "${red}下载 V2bX v$1 失败,请确保此版本存在${plain}" + echo -e "${red}下载 V2bX $1 失败,请确保此版本存在${plain}" exit 1 fi fi @@ -140,10 +144,11 @@ install_V2bX() { cp geoip.dat /etc/V2bX/ cp geosite.dat /etc/V2bX/ - if [[ ! -f /etc/V2bX/config.yml ]]; then - cp config.yml /etc/V2bX/ + if [[ ! -f /etc/V2bX/config.json ]]; then + cp config.json /etc/V2bX/ echo -e "" - echo -e "全新安装,请先参看教程:https://github.com/InazumaV/V2bX,配置必要的内容" + echo -e "全新安装,请先参看教程:https://github.com/InazumaV/V2bX/tree/master/example,配置必要的内容" + first_install=true else systemctl start V2bX sleep 2 @@ -154,6 +159,7 @@ install_V2bX() { else echo -e "${red}V2bX 可能启动失败,请稍后使用 V2bX log 查看日志信息,若无法启动,则可能更改了配置格式,请前往 wiki 查看:https://github.com/V2bX-project/V2bX/wiki${plain}" fi + first_install=false fi if [[ ! -f /etc/V2bX/dns.json ]]; then @@ -168,14 +174,12 @@ install_V2bX() { if [[ ! -f /etc/V2bX/custom_inbound.json ]]; then cp custom_inbound.json /etc/V2bX/ fi - if [[ ! -f /etc/V2bX/config.json ]]; then - cp config.json /etc/V2bX/ - fi curl -o /usr/bin/V2bX -Ls https://raw.githubusercontent.com/InazumaV/V2bX-script/master/V2bX.sh chmod +x /usr/bin/V2bX - ln -s /usr/bin/V2bX /usr/bin/v2bx - chmod +x /usr/bin/v2bx - ln -s /usr/bin/V2bX /usr/bin/v2bx # 小写兼容 + if [ ! -L /usr/bin/v2bx ]; then + ln -s /usr/bin/V2bX /usr/bin/v2bx + chmod +x /usr/bin/v2bx + fi cd $cur_dir rm -f install.sh echo -e "" @@ -189,6 +193,7 @@ install_V2bX() { echo "V2bX enable - 设置 V2bX 开机自启" echo "V2bX disable - 取消 V2bX 开机自启" echo "V2bX log - 查看 V2bX 日志" + echo "V2bX x25519 - 生成 x25519 密钥" echo "V2bX generate - 生成 V2bX 配置文件" echo "V2bX update - 更新 V2bX" echo "V2bX update x.x.x - 更新 V2bX 指定版本" @@ -196,6 +201,20 @@ install_V2bX() { echo "V2bX uninstall - 卸载 V2bX" echo "V2bX version - 查看 V2bX 版本" echo "------------------------------------------" + # 首次安装询问是否生成配置文件 + if [[ $first_install == true ]]; then + read -rp "检测到你为第一次安装V2bX,是否自动直接生成配置文件?(y/n): " if_generate + if [[ $if_generate == [Yy] ]]; then + curl -o ./initconfig.sh -Ls https://raw.githubusercontent.com/InazumaV/V2bX-script/master/initconfig.sh + source initconfig.sh + rm initconfig.sh -f + generate_config_file + read -rp "是否安装bbr内核 ?(y/n): " if_install_bbr + if [[ $if_install_bbr == [Yy] ]]; then + install_bbr + fi + fi + fi } echo -e "${green}开始安装${plain}"