# shellcheck shell=dash disable=SC2154,SC2034
# https://geonet.shodan.io/docs#/default/ping_api_ping__ip__get
___x_cmd_shodan_ping(){
    local X_help_cmd='x help -m shodan geo ping';   help:arg-null:parse
    shodan:arg:format:raw:json2app:all

    local ip_or_hostname="$1"
    if [ -z "$ip_or_hostname" ]; then
        shodan:info "Fetch your public IP to ping"
        ip_or_hostname="$(x ip echo)"   || return
        [ -n "$ip_or_hostname" ]        || return 1
    fi

    shodan:info "Ping an IP or hostname=$ip_or_hostname"
    ___x_cmd_shodan_ping___"$format"
}

___x_cmd_shodan_ping___app(){
    local data; data=$( ___x_cmd_shodan_ping___raw ) || shodan:data:ret
    ___x_cmd_pipevar data   x j2y
}

___x_cmd_shodan_ping___json(){
    local data; data=$( ___x_cmd_shodan_ping___raw ) || shodan:data:ret
    ___x_cmd_pipevar data
}

___x_cmd_shodan_ping___raw(){
    x curl -sS "https://geonet.shodan.io/api/ping/${ip}"
}
