Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 113 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/primp-python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pyo3-log = "0.13.2"
primp = { version = "1.2", path = "../primp", features = [
"impersonate",
"socks",
"hickory-dns",
] }
bytes = "1"
encoding_rs = { version = "0.8.35" }
Expand Down
1 change: 1 addition & 0 deletions crates/primp-python/docs/async_client.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ primp.AsyncClient(
ca_cert_file=None,
https_only=False,
http2_only=False,
dns_resolver=None,
base_url=None,
cookies=None,
)
Expand Down
1 change: 1 addition & 0 deletions crates/primp-python/docs/client.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ primp.Client(
ca_cert_file=None, # Path to CA certificate
https_only=False, # HTTPS only mode
http2_only=False, # HTTP/2 only mode
dns_resolver=None, # DNS resolver: str, list[str], or None (see docs/dns.md)
base_url=None, # Base URL for relative paths
cookies=None, # Initial cookies to send with all requests
)
Expand Down
73 changes: 73 additions & 0 deletions crates/primp-python/docs/dns.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# DNS Resolution

Control how DNS lookups are performed by passing `dns_resolver` to `Client()` or `AsyncClient()`.

## Quick Reference

| Value | Behavior |
|-------|----------|
| `None` (default) | System resolver |
| `"system"` | System resolver |
| `"doh://.../dns-query"` | DNS-over-HTTPS |
| `"dot://1.1.1.1"` | DNS-over-TLS |
| `"dns://1.1.1.1"` | Plain DNS on port 53 |
| `"1.1.1.1"` | Plain DNS on port 53 (shorthand) |
| `["doh://...", "dot://..."]` | Fallback chain (first success wins) |

## Examples

**System resolver (default):**
```python
client = primp.Client()
```

**DNS-over-HTTPS via Cloudflare:**
```python
client = primp.Client(dns_resolver="doh://cloudflare-dns.com/dns-query")
```

**DNS-over-TLS:**
```python
client = primp.Client(dns_resolver="dot://1.1.1.1")
```

**Plain DNS:**
```python
client = primp.Client(dns_resolver="1.1.1.1")
# or explicitly:
client = primp.Client(dns_resolver="dns://1.1.1.1")
```

**Fallback chain: try DoH first, fall back to plain DNS:**
```python
client = primp.Client(dns_resolver=["doh://cloudflare-dns.com/dns-query", "1.1.1.1"])
```

**Fallback chain including system resolver:**
```python
client = primp.Client(dns_resolver=["doh://cloudflare-dns.com/dns-query", "system", "1.1.1.1"])
```

**Async:**
```python
client = primp.AsyncClient(dns_resolver="dot://dns.google")
```

## Order Matters

Resolvers in a list are tried in order. The first one that succeeds wins.

```python
# Try DoH first, fall back to system
client = primp.Client(dns_resolver=["doh://cloudflare-dns.com/dns-query", "system"])
```

## Scheme Reference

| Scheme | Protocol | Default Port | Example |
|--------|----------|-------------|---------|
| `doh://` | HTTPS (DoH) | 443 | `doh://cloudflare-dns.com/dns-query` |
| `dot://` | TLS (DoT) | 853 | `dot://1.1.1.1` |
| `dns://` | UDP/TCP | 53 | `dns://8.8.8.8` |
| *(none)* | UDP/TCP (plain) | 53 | `1.1.1.1` |
| `system` | OS `getaddrinfo` | — | `system` |
Loading
Loading