INNER CODE UNIT · Shell

server_int

bivlked/amneziawg-installer · awg_common.sh:3111

    local server_int=$(( net_int + 1 ))

    # Ассоциативный массив для O(1) lookup. Сервер (network+1) занят.
    declare -A used_set
    used_set["$(_int_to_ipv4 "$server_int")"]=1
    if [[ -f "$SERVER_CONF_FILE" ]]; then
        while IFS= read -r ip; do
            used_set["$ip"]=1
        done < <(grep -oP 'AllowedIPs\s*=\s*\K[0-9.]+' "$SERVER_CONF_FILE")
    fi

    local i candidate
    for (( i = net_int + 1; i <= bcast_int - 1; i++ )); do
        candidate=$(_int_to_ipv4 "$i")
        if [[ -z "${used_set[$candidate]+x}" ]]; then
            echo "$candidate"
            return 0
        fi

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…