diff --git a/lsy-frpc/data/lsyfrpc/check_config.sh b/lsy-frpc/data/lsyfrpc/check_config.sh index 1d56178..9b333ab 100755 --- a/lsy-frpc/data/lsyfrpc/check_config.sh +++ b/lsy-frpc/data/lsyfrpc/check_config.sh @@ -36,23 +36,37 @@ function get_cloud_config() { fi done - cloud_mac_address="$mac_address-v1" - echo "Cloud MAC Address: $cloud_mac_address" - echo "Cloud Port: $cloud_port" + cloud_mac_address_v1="$mac_address-v1" + cloud_mac_address_v2="$mac_address-v2" + cloud_port_v2=$((cloud_port + 10000)) + + echo "Cloud MAC Address V1: $cloud_mac_address_v1" + echo "Cloud MAC Address V2: $cloud_mac_address_v2" + echo "Cloud Port V1 (22): $cloud_port" + echo "Cloud Port V2 (9100): $cloud_port_v2" } # 检查 FRPC 配置是否与云端一致 function check_config() { local cloud_port="$1" - local cloud_mac_address="$2" + local cloud_mac_address_v1="$2" + local cloud_mac_address_v2="$3" + local cloud_port_v2="$4" - current_mac_address=$(grep -Eo '^\[[a-f0-9:-]*-v1\]' "$CONFIG_FILE" | tr -d '[]') - current_port=$(grep -o 'remote_port = [0-9]*' "$CONFIG_FILE" | awk '{print $3}' | xargs) + current_port_v1=$(awk -v section="[$cloud_mac_address_v1]" ' + $0 ~ section { found=1 } + found && /remote_port = [0-9]+/ { print $3; exit } + ' "$CONFIG_FILE") - echo "Current MAC Address in frpc.ini: '$current_mac_address' '$cloud_mac_address'" - echo "Current Port in frpc.ini: '$current_port' '$cloud_port'" + current_port_v2=$(awk -v section="[$cloud_mac_address_v2]" ' + $0 ~ section { found=1 } + found && /remote_port = [0-9]+/ { print $3; exit } + ' "$CONFIG_FILE") - if [ "$current_mac_address" != "$cloud_mac_address" ] || [ "$current_port" != "$cloud_port" ]; then + echo "Current Port for $cloud_mac_address_v1 (22): '$current_port_v1' (Expected: '$cloud_port')" + echo "Current Port for $cloud_mac_address_v2 (9100): '$current_port_v2' (Expected: '$cloud_port_v2')" + + if [ "$current_port_v1" != "$cloud_port" ] || [ "$current_port_v2" != "$cloud_port_v2" ]; then echo "[INFO] Configuration mismatch detected. Updating frpc.ini..." cat > "$CONFIG_FILE" <