# shellcheck shell=dash disable=SC2154,SC2034

xrc:mod:lib     shodan      dns/domain  dns/resolve  dns/reverse

___x_cmd_shodan_dns(){
    [ $# -gt 0 ]   ||   set -- -h

    local op="$1";      shift
    case "$op" in
        d|domain)       ___x_cmd_shodan_dns_domain  "$@" ;;
        res|resolve)    ___x_cmd_shodan_dns_resolve "$@" ;;
        rev|reverse)    ___x_cmd_shodan_dns_reverse "$@" ;;

        -h|--help)      x help -m shodan dns ;;
        *)              ___x_cmd_shodan_dns___auto  "$@" ;;
    esac
}

___x_cmd_shodan_dns___auto(){
    case "$op" in
        *.*)
            if ___x_cmd is ip "$op"; then
                shodan:info "Executing 'x shodan dns reverse $op'"
                ___x_cmd_shodan_dns_reverse "$op" "$@"
            else
                shodan:info "Executing 'x shodan dns domain $op'"
                ___x_cmd_shodan_dns_domain  "$op" "$@"
            fi
            ;;
        *)
            N=shodan M="Unknown operation for 'x shodan dns' -> $op" log:ret:64
            ;;
    esac
}
