Files
unshackle/docs/reference/configuration/network.md
T

252 lines
13 KiB
Markdown

# Network & Proxy { #network-proxy }
Keys that control the HTTP client, the headers that it sends and the proxy providers. For how
`--proxy` picks a proxy, see the [Proxies & VPN guide](../../guide/proxies-and-vpn.md).
## `network`
- **Type:** `dict`  ·  **Default:** `{}`
TLS-fingerprinting and HTTP client settings for the rnet-based HTTP session.
| Sub-key | Type | Default | Description |
|---------|------|---------|-------------|
| `browser` | str | `"Chrome131"` | Impersonation preset. Must be an exact preset name (e.g. `Chrome131`, `Firefox135`, `Edge101`, `Safari18`, `OkHttp4_12`, `OkHttp5`, `Opera118`); unknown names raise an error. |
| `http1_only` | bool | *(unset)* | Force HTTP/1.1. |
| `http2_only` | bool | *(unset)* | Force HTTP/2. |
| `connect_timeout` | int | `10` | Connect timeout in seconds. |
| `read_timeout` | int | `30` | Read timeout in seconds (max gap between response chunks). Applies to every request of an rnet session, segment downloads included. |
| `timeout` | int | *(unset)* | Total request timeout in seconds. |
| `allow_redirects` | bool | *(unset)* | Follow redirects automatically (rnet client default when unset). |
| `pool_idle_timeout` | int | `55` | Seconds an idle pooled connection is kept (default stays under typical ~60s CDN idle kills). |
| `pool_max_idle_per_host` | int | `64` | Max idle connections kept per host. |
| `pool_max_size` | int | *(unset)* | Max total connections in the pool. |
| `tcp_keepalive` | int | `30` | TCP keepalive time in seconds. |
| `tcp_keepalive_interval` | int | *(unset)* | TCP keepalive probe interval in seconds. |
| `tcp_keepalive_retries` | int | *(unset)* | TCP keepalive probe retry count. |
| `tcp_nodelay` | bool | *(unset)* | Disable Nagle's algorithm. |
```yaml
network:
browser: Firefox135
http2_only: true
```
!!! note "Measured effect of `http1_only`"
Both `http1_only` and `http2_only` are unset by default. In benchmarks, forcing HTTP/1.1
gained 30 to 50% on hosts that throttle per-connection or stall behind HTTP/2 flow control,
and **cost up to 27% on fast CDNs**.
!!! warning "Renamed from `curl_impersonate`"
The old `curl_impersonate` section is a deprecated alias. If you still use it, unshackle
honours it (only when `network` is absent) but emits a `DeprecationWarning`. Rename it to
`network`.
## `headers`
- **Type:** `dict`  ·  **Default:** `{}`
Default HTTP headers merged into every HTTP session unshackle makes.
```yaml
headers:
Accept-Language: en-US,en;q=0.9
```
!!! warning "Don't set `Accept-Encoding` (and similar) here"
Compatibility headers such as `Accept-Encoding` are set by the rnet HTTP backend as part of
its browser-impersonation profile. If you override them, you break the impersonation
fingerprint. This block is for cross-service defaults only (for example `Accept-Language`,
`User-Agent`). Per-service headers belong in that service's own config.
## `proxy_providers`
- **Type:** `dict`  ·  **Default:** `{}`
Proxy provider configuration. Each sub-key names a proxy provider, and unshackle passes its
block to the constructor of that proxy provider, so each config key below is a constructor
argument. Except for `basic` and `gluetun`, a config key that the proxy provider does not know
stops it from loading. The order of the sub-keys sets the order of a bare `--proxy` query (see
[Provider load order](../../guide/proxies-and-vpn.md#provider-load-order)). How to set up each
proxy provider and the queries it accepts are in [Proxies & VPN](../../guide/proxies-and-vpn.md).
Recognised proxy providers and their exit ports:
| Provider | Config key | Credentials | Proxy scheme/port |
|----------|-----------|-------------|-------------------|
| Basic (static) | [`basic`](#basic) | country → URI(s) | as specified |
| Control D | [`controld`](#controld) | Write API token (profile/resolver pairs optional) | `http://127.0.0.1:{port}` (local forwarder) |
| NordVPN | [`nordvpn`](#nordvpn) | **service** credentials (48 chars combined) | `https://...:89` |
| Surfshark | [`surfsharkvpn`](#surfsharkvpn) | **service** credentials (48 chars combined) | `https://...:443` |
| Windscribe | [`windscribevpn`](#windscribevpn) | service credentials | `https://...:443` |
| ExpressVPN | [`expressvpn`](#expressvpn) | device login (`enable: true`) / token cache | `https://cat:...@...:443` |
| ProtonVPN | [`protonvpn`](#protonvpn) | TV login or exported cookies | `https://...:4443` (or `:443` Secure Core) |
| Gluetun | [`gluetun`](#gluetun) | per-VPN keys/creds | `http://localhost:{port}` (local Docker) |
| Hola | *(none, auto)* | none | `http://...:{peer}` |
```yaml
proxy_providers:
basic:
us: http://user:pass@1.2.3.4:8080
de:
- http://a.example:8080
- socks5://b.example:1080
nordvpn:
username: <service username>
password: <service password>
```
### `basic` { #basic }
Each config key is a two-letter country code, and its value is one proxy URI or a list of
proxy URIs. unshackle adds `http://` to a URI with no scheme. A URI with no host fails when a
query picks it, before the download starts. See [Basic](../../guide/proxies-and-vpn.md#basic-static-proxies)
for the queries.
```yaml
proxy_providers:
basic:
us: http://user:pass@1.2.3.4:8080
de:
- http://a.example:8080
- socks5://b.example:1080
```
### `controld` { #controld }
Config keys of the Control D proxy provider. See
[Control D](../../guide/proxies-and-vpn.md#control-d) for how unshackle uses them.
| Key | Type | Default | Meaning |
|---|---|---|---|
| `token` | `str` | required | A Control D API token of type *Write*. |
| `profile` | `str` | none | Optional. The ID of a profile you made for unshackle. Give it together with `resolver`. Without it, unshackle creates `unshackle-<region>` profiles itself. |
| `resolver` | `str` | none | Optional. The resolver ID of an endpoint that uses `profile`, or its DoH URL `https://dns.controld.com/<resolver>`. |
| `profiles` | `list` | `[]` | Optional. More pairs, each a mapping with `profile` and `resolver`. |
| `max_profiles` | `int` | `4` | The most profiles unshackle uses: your pairs plus the `unshackle-*` endpoints on the account. It must be 1 or more. unshackle creates an `unshackle-<region>` profile and endpoint only while the total is lower. |
### `expressvpn` { #expressvpn }
| Key | Type | Default | Meaning |
|---|---|---|---|
| `enable` | `bool` | `false` | Do the one-time interactive device login when no login session exists. |
| `region_map` | `dict` | `{}` | A country code to a city or server preset (`us: ny-02`), used when the query names only the country. An empty value gives a smart random location. |
| `server_map` | `dict` | `{}` | An alias to a location slug (`usny-newyork-2`) or a `.expressprovider.com` hostname. |
| `cache_path` | `str` | `{cache}/vpn/expressvpn_tokens.json` | The token cache. unshackle writes it with `0600` permissions. |
| `refresh_token`, `access_token`, `connection_token` | `str` | none | Tokens to use in place of the token cache. |
| `account_json` | `str` | none | A JSON file to read the tokens from when there is no token cache. |
| `timeout` | `float` | `10.0` | The request timeout in seconds. |
`{cache}` is [`directories.cache`](directories.md). ExpressVPN also loads with no config block
when its token cache exists.
### `gluetun` { #gluetun }
```yaml
proxy_providers:
gluetun:
providers:
windscribe:
vpn_type: wireguard
credentials:
private_key: YOUR_WIREGUARD_PRIVATE_KEY
addresses: YOUR_WIREGUARD_ADDRESS
preshared_key: YOUR_PRESHARED_KEY
server_countries:
us: US
uk: GB
server_cities: {}
server_hostnames: {}
extra_env: {}
base_port: 8888
auto_cleanup: true
container_prefix: unshackle-gluetun
auth_user: null
auth_password: null
verify_ip: true
```
Global keys:
| Key | Type | Default | Meaning |
|---|---|---|---|
| `providers` | `dict` | `{}` | One entry for each VPN provider, keyed by its name in the query (`gluetun:<vpn-provider>:<region>`). |
| `base_port` | `int` | `8888` | The first local port for a proxy. Other containers take the next free ports. |
| `auto_cleanup` | `bool` | `true` | Remove the containers on exit. With `false`, unshackle only stops them. |
| `container_prefix` | `str` | `unshackle-gluetun` | The prefix of the Docker container names. |
| `auth_user`, `auth_password` | `str` | `null` | HTTP proxy credentials. When set, the local proxy asks for them, and the proxy URI holds them. |
| `verify_ip` | `bool` | `true` | After the connection, check the exit IP and its country. |
Keys of each entry under `providers`:
| Key | Type | Default | Meaning |
|---|---|---|---|
| `vpn_type` | `str` | `wireguard` | `wireguard` or `openvpn`. |
| `credentials` | `dict` | `{}` | The secrets of the tunnel; see the rules below. |
| `server_countries` | `dict` | `{}` | Your region alias (`us`) to Gluetun's country value (`US`). |
| `server_cities` | `dict` | `{}` | An alias to a Gluetun city. |
| `server_hostnames` | `dict` | `{}` | An alias to one server hostname. |
| `extra_env` | `dict` | `{}` | Environment variables that go into the container last, for a Gluetun setting that the keys above do not cover. |
Credentials that each `vpn_type` needs (unshackle checks them when it loads):
- **`wireguard`:** `private_key` always. `surfshark`, `mullvad` and `ivpn` also need
`addresses`. `windscribe` needs `addresses` and `preshared_key`; `preshared_key` can be an
empty string, but the config key must be there. NordVPN and Proton VPN need only `private_key`.
- **`openvpn`:** `username` and `password`.
### `nordvpn` { #nordvpn }
| Key | Type | Default | Meaning |
|---|---|---|---|
| `username` | `str` | required | The NordVPN *Service Credentials* username. |
| `password` | `str` | required | The *Service Credentials* password. |
| `server_map` | `dict` | `{}` | A region (`us`) or `code:city` (`us:seattle`) to a NordVPN server ID, or to an `@` selector (see [Choose a server network](../../guide/proxies-and-vpn.md#choose-a-server-network)). |
The username and the password together must be 48 letters and digits, and the username must not
contain `@`. Login credentials fail this check.
### `protonvpn` { #protonvpn }
| Key | Type | Default | Meaning |
|---|---|---|---|
| `enable` | `bool` | `false` | Do the one-time interactive TV login when no login session exists. |
| `server_map` | `dict` | `{}` | An alias to a server query. |
| `cookie_path` | `str` | `{cookies}/vpn/protonvpn.txt` | The exported `account.proton.me` cookies. |
| `cache_path` | `str` | `{cache}/vpn/protonvpn.json` | The TV login cache. unshackle writes it with `0600` permissions. |
| `timeout` | `float` | `10.0` | The request timeout in seconds. |
`{cookies}` and `{cache}` are [`directories.cookies`](directories.md) and
`directories.cache`. unshackle also finds the cookie file as `proton.txt`, and in a `vpns`
folder. Proton VPN also loads with no config block when the cookie file exists. A TV login cache
alone does not load it, so keep the `protonvpn` block for a TV login.
### `surfsharkvpn` { #surfsharkvpn }
| Key | Type | Default | Meaning |
|---|---|---|---|
| `username` | `str` | required | The Surfshark *Service Credentials* username. |
| `password` | `str` | required | The *Service Credentials* password. |
| `server_map` | `dict` | `{}` | A region (`us`) or `code:city` (`us:seattle`) to a Surfshark server name (`us-dal`, or the full hostname `us-dal.prod.surfshark.com`), or to an `@` selector. unshackle ignores a numeric or empty value with a warning. A city query uses only its `code:city` entry, never the country entry. |
The username and the password must pass the same 48-character check as `nordvpn`.
### `windscribevpn` { #windscribevpn }
| Key | Type | Default | Meaning |
|---|---|---|---|
| `username` | `str` | required | The username of the Windscribe proxy *Service Credentials*. |
| `password` | `str` | required | The password of the proxy *Service Credentials*. |
| `server_map` | `dict` | `{}` | A region (`us`) or `region:city` (`us:seattle`) to a hostname, or to an `@` selector. |
There is no 48-character check.
### Hola { #hola }
Hola has no config key. It loads when unshackle finds the `hola-proxy` binary, in its binaries folders or on your `PATH`.
!!! note "Provider loading differs between CLI and REST server"
The `dl` and `search` commands load all providers, including `gluetun`. A server (REST API
requests, download jobs and remote sessions) and the remote client do **not** load `gluetun`,
because it starts a local Docker container. ExpressVPN, Proton VPN and Hola can also load with no config block
(see [`expressvpn`](#expressvpn), [`protonvpn`](#protonvpn) and [Hola](#hola)).