> For the complete documentation index, see [llms.txt](https://docs.ipdunar.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ipdunar.com/zh/chan-pin/overview-2/protocols.md).

# 协议

每个 ISP IP 在同一端口（`8000`）上支持 HTTP、HTTPS、SOCKS5，由客户端握手自动识别——无需逐 IP 配置。

## HTTP / HTTPS

```bash
# HTTP 目标
curl -x http://ipdunar_s1a2b3c4d5e:PASSWORD@198.51.100.42:8000 http://example.com

# HTTPS 目标（端到端 TLS）
curl -x http://ipdunar_s1a2b3c4d5e:PASSWORD@198.51.100.42:8000 https://example.com
```

HTTPS 目标时，客户端向代理发送 `CONNECT example.com:443` 打通 TCP 隧道，ipdunar 看不到请求体。

## SOCKS5

```bash
curl --socks5-hostname ipdunar_s1a2b3c4d5e:PASSWORD@198.51.100.42:8000 \
     https://ipv4.icanhazip.com
```

使用 `--socks5-hostname`（curl）或 `socks5h://`（Python `requests` 等）让代理做 DNS——否则本地解析会泄露 DNS，地理服务也会出错。

### Python

```python
import requests
proxy = "socks5h://ipdunar_s1a2b3c4d5e:PASSWORD@198.51.100.42:8000"
r = requests.get("https://ipv4.icanhazip.com",
                 proxies={"http": proxy, "https": proxy}, timeout=30)
```

### Node.js

```js
import { SocksProxyAgent } from "socks-proxy-agent";
import fetch from "node-fetch";
const agent = new SocksProxyAgent("socks5://ipdunar_s1a2b3c4d5e:PASSWORD@198.51.100.42:8000");
const res = await fetch("https://ipv4.icanhazip.com", { agent });
```

## 如何选择

权衡同住宅，完整对照表见 [住宅协议](https://docs.ipdunar.com/pages/5vJUKmp3jGMFjRAoTr9Z#%E5%A6%82%E4%BD%95%E9%80%89%E6%8B%A9)。

## ISP 特有提示

* **到目标的 HTTP/2** 通过 `CONNECT` 隧道工作，ipdunar 不降级。
* **长连接特别划算** — ISP IP 稳定，连接池（HTTP keep-alive、HTTP/2 多路复用）回报丰厚。**保持连接，不要逐请求重连**。
* **WebSocket 与 gRPC** 可用，把 IP 当作普通 HTTP 代理即可。

## 不支持

* SOCKS4 / SOCKS4a — 请用 SOCKS5
* 把定位参数塞到用户名里（`-type-`、`-region-` 等） — ISP 凭证就是纯 `user:pass`。任何额外的字段会原样发到服务端并被 `407 auth-failed` 拒绝。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.ipdunar.com/zh/chan-pin/overview-2/protocols.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
