diff --git a/CHANGELOG.md b/CHANGELOG.md index 74c4d50b..1401214a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## Unreleased +## [0.20.0] - 2023-11-19 ### Features - Add `--resolve` for overriding DNS resolution, see #327 (@ducaale) diff --git a/Cargo.lock b/Cargo.lock index f4b765b6..ddbe2469 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2306,7 +2306,7 @@ dependencies = [ [[package]] name = "xh" -version = "0.19.4" +version = "0.20.0" dependencies = [ "anyhow", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index 55ea6822..545d8440 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "xh" -version = "0.19.4" +version = "0.20.0" authors = ["ducaale "] edition = "2021" rust-version = "1.64.0" diff --git a/completions/_xh b/completions/_xh index 4b57bcd9..6381b198 100644 --- a/completions/_xh +++ b/completions/_xh @@ -47,6 +47,7 @@ none\:"Disable both coloring and formatting"))' \ '--ssl=[Force a particular TLS version]:VERSION:(auto tls1 tls1.1 tls1.2 tls1.3)' \ '--default-scheme=[The default scheme to use if not specified in the URL]:SCHEME: ' \ '--http-version=[HTTP version to use]:VERSION:(1.0 1.1 2)' \ +'*--resolve=[Override DNS resolution for specific domain to a custom IP]:HOST:ADDRESS: ' \ '--interface=[Bind to a network interface or local IP address]:NAME: ' \ '-j[(default) Serialize data items from the command line as a JSON object]' \ '--json[(default) Serialize data items from the command line as a JSON object]' \ @@ -127,6 +128,7 @@ none\:"Disable both coloring and formatting"))' \ '--no-default-scheme[]' \ '--no-https[]' \ '--no-http-version[]' \ +'--no-resolve[]' \ '--no-interface[]' \ '--no-ipv4[]' \ '--no-ipv6[]' \ diff --git a/completions/_xh.ps1 b/completions/_xh.ps1 index 2154bf89..3bd6e4d1 100644 --- a/completions/_xh.ps1 +++ b/completions/_xh.ps1 @@ -50,6 +50,7 @@ Register-ArgumentCompleter -Native -CommandName 'xh' -ScriptBlock { [CompletionResult]::new('--ssl', 'ssl', [CompletionResultType]::ParameterName, 'Force a particular TLS version') [CompletionResult]::new('--default-scheme', 'default-scheme', [CompletionResultType]::ParameterName, 'The default scheme to use if not specified in the URL') [CompletionResult]::new('--http-version', 'http-version', [CompletionResultType]::ParameterName, 'HTTP version to use') + [CompletionResult]::new('--resolve', 'resolve', [CompletionResultType]::ParameterName, 'Override DNS resolution for specific domain to a custom IP') [CompletionResult]::new('--interface', 'interface', [CompletionResultType]::ParameterName, 'Bind to a network interface or local IP address') [CompletionResult]::new('-j', 'j', [CompletionResultType]::ParameterName, '(default) Serialize data items from the command line as a JSON object') [CompletionResult]::new('--json', 'json', [CompletionResultType]::ParameterName, '(default) Serialize data items from the command line as a JSON object') @@ -130,6 +131,7 @@ Register-ArgumentCompleter -Native -CommandName 'xh' -ScriptBlock { [CompletionResult]::new('--no-default-scheme', 'no-default-scheme', [CompletionResultType]::ParameterName, 'no-default-scheme') [CompletionResult]::new('--no-https', 'no-https', [CompletionResultType]::ParameterName, 'no-https') [CompletionResult]::new('--no-http-version', 'no-http-version', [CompletionResultType]::ParameterName, 'no-http-version') + [CompletionResult]::new('--no-resolve', 'no-resolve', [CompletionResultType]::ParameterName, 'no-resolve') [CompletionResult]::new('--no-interface', 'no-interface', [CompletionResultType]::ParameterName, 'no-interface') [CompletionResult]::new('--no-ipv4', 'no-ipv4', [CompletionResultType]::ParameterName, 'no-ipv4') [CompletionResult]::new('--no-ipv6', 'no-ipv6', [CompletionResultType]::ParameterName, 'no-ipv6') diff --git a/completions/xh.bash b/completions/xh.bash index ac255a29..fd82966a 100644 --- a/completions/xh.bash +++ b/completions/xh.bash @@ -19,7 +19,7 @@ _xh() { case "${cmd}" in xh) - opts="-j -f -s -p -h -b -m -v -P -q -S -o -d -c -A -a -F -4 -6 -I -V --json --form --multipart --raw --pretty --format-options --style --response-charset --response-mime --print --headers --body --meta --verbose --all --history-print --quiet --stream --output --download --continue --session --session-read-only --auth-type --auth --bearer --ignore-netrc --offline --check-status --follow --max-redirects --timeout --proxy --verify --cert --cert-key --ssl --native-tls --default-scheme --https --http-version --interface --ipv4 --ipv6 --ignore-stdin --curl --curl-long --help --no-json --no-form --no-multipart --no-raw --no-pretty --no-format-options --no-style --no-response-charset --no-response-mime --no-print --no-headers --no-body --no-meta --no-verbose --no-all --no-history-print --no-quiet --no-stream --no-output --no-download --no-continue --no-session --no-session-read-only --no-auth-type --no-auth --no-bearer --no-ignore-netrc --no-offline --no-check-status --no-follow --no-max-redirects --no-timeout --no-proxy --no-verify --no-cert --no-cert-key --no-ssl --no-native-tls --no-default-scheme --no-https --no-http-version --no-interface --no-ipv4 --no-ipv6 --no-ignore-stdin --no-curl --no-curl-long --no-help --version <[METHOD] URL> [REQUEST_ITEM]..." + opts="-j -f -s -p -h -b -m -v -P -q -S -o -d -c -A -a -F -4 -6 -I -V --json --form --multipart --raw --pretty --format-options --style --response-charset --response-mime --print --headers --body --meta --verbose --all --history-print --quiet --stream --output --download --continue --session --session-read-only --auth-type --auth --bearer --ignore-netrc --offline --check-status --follow --max-redirects --timeout --proxy --verify --cert --cert-key --ssl --native-tls --default-scheme --https --http-version --resolve --interface --ipv4 --ipv6 --ignore-stdin --curl --curl-long --help --no-json --no-form --no-multipart --no-raw --no-pretty --no-format-options --no-style --no-response-charset --no-response-mime --no-print --no-headers --no-body --no-meta --no-verbose --no-all --no-history-print --no-quiet --no-stream --no-output --no-download --no-continue --no-session --no-session-read-only --no-auth-type --no-auth --no-bearer --no-ignore-netrc --no-offline --no-check-status --no-follow --no-max-redirects --no-timeout --no-proxy --no-verify --no-cert --no-cert-key --no-ssl --no-native-tls --no-default-scheme --no-https --no-http-version --no-resolve --no-interface --no-ipv4 --no-ipv6 --no-ignore-stdin --no-curl --no-curl-long --no-help --version <[METHOD] URL> [REQUEST_ITEM]..." if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -141,6 +141,10 @@ _xh() { COMPREPLY=($(compgen -W "1.0 1.1 2" -- "${cur}")) return 0 ;; + --resolve) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; --interface) COMPREPLY=($(compgen -f "${cur}")) return 0 diff --git a/completions/xh.fish b/completions/xh.fish index 57758f80..6e982fce 100644 --- a/completions/xh.fish +++ b/completions/xh.fish @@ -21,6 +21,7 @@ complete -c xh -l cert-key -d 'A private key file to use with --cert' -r -F complete -c xh -l ssl -d 'Force a particular TLS version' -r -f -a "{auto ,tls1 ,tls1.1 ,tls1.2 ,tls1.3 }" complete -c xh -l default-scheme -d 'The default scheme to use if not specified in the URL' -r complete -c xh -l http-version -d 'HTTP version to use' -r -f -a "{1.0 ,1.1 ,2 }" +complete -c xh -l resolve -d 'Override DNS resolution for specific domain to a custom IP' -r complete -c xh -l interface -d 'Bind to a network interface or local IP address' -r complete -c xh -s j -l json -d '(default) Serialize data items from the command line as a JSON object' complete -c xh -s f -l form -d 'Serialize data items from the command line as form fields' @@ -87,6 +88,7 @@ complete -c xh -l no-native-tls complete -c xh -l no-default-scheme complete -c xh -l no-https complete -c xh -l no-http-version +complete -c xh -l no-resolve complete -c xh -l no-interface complete -c xh -l no-ipv4 complete -c xh -l no-ipv6 diff --git a/doc/xh.1 b/doc/xh.1 index b01e0f0b..9b5d22a2 100644 --- a/doc/xh.1 +++ b/doc/xh.1 @@ -1,4 +1,4 @@ -.TH XH 1 2023-10-22 0.19.4 "User Commands" +.TH XH 1 2023-11-19 0.20.0 "User Commands" .SH NAME xh \- Friendly and fast tool for sending HTTP requests @@ -280,6 +280,13 @@ HTTP version to use. [possible values: 1.0, 1.1, 2] .TP 4 +\fB\-\-resolve\fR=\fIHOST:ADDRESS\fR +Override DNS resolution for specific domain to a custom IP. + +You can override multiple domains by repeating this option. + +Example: \-\-resolve=example.com:127.0.0.1. +.TP 4 \fB\-\-interface\fR=\fINAME\fR Bind to a network interface or local IP address.