xref: /aosp_15_r20/external/curl/docs/cmdline-opts/connect-to.md (revision 6236dae45794135f37c4eb022389c904c8b0090d)
1*6236dae4SAndroid Build Coastguard Worker---
2*6236dae4SAndroid Build Coastguard Workerc: Copyright (C) Daniel Stenberg, <[email protected]>, et al.
3*6236dae4SAndroid Build Coastguard WorkerSPDX-License-Identifier: curl
4*6236dae4SAndroid Build Coastguard WorkerLong: connect-to
5*6236dae4SAndroid Build Coastguard WorkerArg: <HOST1:PORT1:HOST2:PORT2>
6*6236dae4SAndroid Build Coastguard WorkerHelp: Connect to host2 instead of host1
7*6236dae4SAndroid Build Coastguard WorkerAdded: 7.49.0
8*6236dae4SAndroid Build Coastguard WorkerCategory: connection dns
9*6236dae4SAndroid Build Coastguard WorkerMulti: append
10*6236dae4SAndroid Build Coastguard WorkerSee-also:
11*6236dae4SAndroid Build Coastguard Worker  - resolve
12*6236dae4SAndroid Build Coastguard Worker  - header
13*6236dae4SAndroid Build Coastguard WorkerExample:
14*6236dae4SAndroid Build Coastguard Worker  - --connect-to example.com:443:example.net:8443 $URL
15*6236dae4SAndroid Build Coastguard Worker---
16*6236dae4SAndroid Build Coastguard Worker
17*6236dae4SAndroid Build Coastguard Worker# `--connect-to`
18*6236dae4SAndroid Build Coastguard Worker
19*6236dae4SAndroid Build Coastguard WorkerFor a request intended for the `HOST1:PORT1` pair, connect to `HOST2:PORT2`
20*6236dae4SAndroid Build Coastguard Workerinstead. This option is only used to establish the network connection. It does
21*6236dae4SAndroid Build Coastguard WorkerNOT affect the hostname/port number that is used for TLS/SSL (e.g. SNI,
22*6236dae4SAndroid Build Coastguard Workercertificate verification) or for the application protocols.
23*6236dae4SAndroid Build Coastguard Worker
24*6236dae4SAndroid Build Coastguard Worker`HOST1` and `PORT1` may be empty strings, meaning any host or any port number.
25*6236dae4SAndroid Build Coastguard Worker`HOST2` and `PORT2` may also be empty strings, meaning use the request's
26*6236dae4SAndroid Build Coastguard Workeroriginal hostname and port number.
27*6236dae4SAndroid Build Coastguard Worker
28*6236dae4SAndroid Build Coastguard WorkerA hostname specified to this option is compared as a string, so it needs to
29*6236dae4SAndroid Build Coastguard Workermatch the name used in request URL. It can be either numerical such as
30*6236dae4SAndroid Build Coastguard Worker`127.0.0.1` or the full host name such as `example.org`.
31*6236dae4SAndroid Build Coastguard Worker
32*6236dae4SAndroid Build Coastguard WorkerExample: redirect connects from the example.com hostname to 127.0.0.1
33*6236dae4SAndroid Build Coastguard Workerindependently of port number:
34*6236dae4SAndroid Build Coastguard Worker
35*6236dae4SAndroid Build Coastguard Worker    curl --connect-to example.com::127.0.0.1: https://example.com/
36*6236dae4SAndroid Build Coastguard Worker
37*6236dae4SAndroid Build Coastguard WorkerExample: redirect connects from all hostnames to 127.0.0.1 independently of
38*6236dae4SAndroid Build Coastguard Workerport number:
39*6236dae4SAndroid Build Coastguard Worker
40*6236dae4SAndroid Build Coastguard Worker    curl --connect-to ::127.0.0.1: http://example.com/
41