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
19 changes: 18 additions & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,8 @@ docker/ # Docker image of `ketch server` (Dockerfile, entrypoint, compose
- HTTP requests can be spread round-robin over selected network interfaces
(`KetchApi.selectNetworkInterfaces`, `MultiNetworkHttpEngine`); see
[multiple networks](docs/multiple-networks.md)
- Proxies for HTTP(S), HLS and DASH downloads (not FTP or BitTorrent; Discover never proxies):
- Proxies for HTTP(S), HLS and DASH downloads (not FTP; BitTorrent only with
`[torrent] useProxy`, see the torrent section; Discover never proxies):
`DownloadConfig.proxy` (`[download.proxy]`), replaced per task by `DownloadRequest.proxy`, which
`DownloadCoordinator` folds into the run's `DownloadContext.config` (`forRequest`); `resolve`
uses the global one. `Proxy` is sealed: `System` (default), `Direct` or `Manual` with a
Expand Down Expand Up @@ -1418,6 +1419,22 @@ docker/ # Docker image of `ketch server` (Dockerfile, entrypoint, compose
`sequential`, `TorrentSnapshot.sequential`), saved in `TorrentSourceState.sequential`, read live
by `TorrentPieceScheduler` and the v2 loop (`TorrentV2RarityPicker.lowest`); the inspector's
`SequentialControl` switches it. It orders pieces; file priorities choose which files first
- Proxy: `TorrentConfig.proxy` (a `ProxyAddress`, read as the engine starts) sends every
torrent through a SOCKS5 or HTTP proxy. `TorrentDownloadSource`'s engine factory then builds
the engine over `ProxiedTorrentNetwork` (`net`), whose `connect` tunnels through the proxy
(SOCKS5 `CONNECT` with user name and password, host names left to the proxy; or HTTP
`CONNECT` with Basic credentials), whose `bindUdp` sockets send and receive nothing and whose
`listen` binds loopback, with DHT, uTP, port mapping and local discovery off in its config
whatever the settings say, and no port mapper or LSD transport at all. The engine is built
`proxied`: a peer named by host (`x.pe`, a tracker's list) is dialed by that name
(`resolveEndpoint(resolve = false)`, `TorrentPeerEncryption(resolveNames = false)`, so the IP
filter checks addresses only), and UDP trackers fail at once instead of timing out; trackers, web seeds,
metainfo and tracker lists go through `HttpEngine.withProxy` (an engine that cannot use one
fails them, `TorrentHttp.default(proxy)` without an injected engine). Hosts pass
`KetchConfig.torrentProxy`: the manual proxy of `[download.proxy]` while `[torrent] useProxy`
is on (off by default; Settings → BitTorrent → Connections → Use the proxy, this device
only), in the desktop, Android and iOS apps and the CLI; a change applies at the next start.
Tests: `ProxiedTorrentNetworkTest` (scripted SOCKS5 and HTTP proxies on loopback)
- IP filter (capability `ip-filter`): `TorrentConfig.blockedAddresses` / `[torrent] blocklist`
/ `TorrentEngineSettings.blockedAddresses` (live through `setBlockedAddresses` and
`updateSettings`, which refuses entries that are none with `INVALID_INPUT`) lists addresses,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ class KetchService : Service() {
val instanceId = DeviceStore(File(filesDir, DEVICE_FILE_NAME).path).instanceId()
val torrentSource = TorrentDownloadSource(
TorrentConfig(stateDirectory = filesDir.resolve("torrent-state").absolutePath)
.withSettings(config.torrent.engineSettings),
.withSettings(config.torrent.engineSettings)
.copy(proxy = config.torrentProxy),
// Wi-Fi drivers drop multicast to save power unless an app holds a lock; LAN discovery
// holds it only while a public torrent runs.
multicastLock = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,8 @@ private fun createInstanceManager(
val taskStore = createSqliteTaskStore(driverFactory)
val torrentSource = TorrentDownloadSource(
TorrentConfig(stateDirectory = File(configDir, "torrent-state").path)
.withSettings(config.torrent.engineSettings),
.withSettings(config.torrent.engineSettings)
.copy(proxy = config.torrentProxy),
)
return InstanceManager(
factory = InstanceFactory(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,8 @@
<string name="settings_torrent_port_mapping_hint">Bittet deinen Router (UPnP oder NAT-PMP), einen Port weiterzuleiten, damit sich mehr Peers mit diesem Gerät verbinden können.</string>
<string name="settings_torrent_local_discovery">Lokale Peer-Suche</string>
<string name="settings_torrent_local_discovery_hint">Findet Geräte in deinem lokalen Netzwerk, die dieselben öffentlichen Torrents herunterladen oder teilen, damit sie Teile direkt austauschen.</string>
<string name="settings_torrent_use_proxy">Proxy verwenden</string>
<string name="settings_torrent_use_proxy_hint">Erreicht Peers, HTTP-Tracker und Web-Seeds über den unter „Netzwerk“ eingestellten Proxy. DHT, uTP, UDP-Tracker und Portweiterleitung sind über einen Proxy aus, und Peers können keine Verbindung zu dir aufbauen. Gilt nach einem Neustart von Ketch.</string>
<string name="settings_torrent_connections_footer">Verschlüsselung verbirgt, welche Art von Datenverkehr es ist, nicht, mit wem du dich verbindest.</string>
<string name="settings_torrent_trackers">Zusätzliche Tracker</string>
<string name="settings_torrent_no_trackers">Keine zusätzlichen Tracker</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,8 @@
<string name="settings_torrent_port_mapping_hint">Pide a tu router (UPnP o NAT-PMP) que reenvíe un puerto, para que más pares puedan conectarse a este dispositivo.</string>
<string name="settings_torrent_local_discovery">Descubrimiento de pares locales</string>
<string name="settings_torrent_local_discovery_hint">Encuentra dispositivos de tu red local que descargan o comparten los mismos torrents públicos, para que intercambien partes directamente.</string>
<string name="settings_torrent_use_proxy">Usar el proxy</string>
<string name="settings_torrent_use_proxy_hint">Llega a los pares, los trackers HTTP y las semillas web a través del proxy configurado en Red. DHT, uTP, los trackers UDP y el reenvío de puertos se desactivan con un proxy, y los pares no pueden conectarse a ti. Se aplica al reiniciar Ketch.</string>
<string name="settings_torrent_connections_footer">El cifrado oculta qué tipo de tráfico es, no con quién te conectas.</string>
<string name="settings_torrent_trackers">Trackers adicionales</string>
<string name="settings_torrent_no_trackers">Sin trackers adicionales</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,8 @@
<string name="settings_torrent_port_mapping_hint">Demande à votre routeur (UPnP ou NAT-PMP) de rediriger un port, pour que davantage de pairs puissent se connecter à cet appareil.</string>
<string name="settings_torrent_local_discovery">Découverte de pairs locaux</string>
<string name="settings_torrent_local_discovery_hint">Trouve les appareils de votre réseau local qui téléchargent ou partagent les mêmes torrents publics, pour qu'ils échangent des morceaux directement.</string>
<string name="settings_torrent_use_proxy">Utiliser le proxy</string>
<string name="settings_torrent_use_proxy_hint">Joint les pairs, les trackers HTTP et les sources web via le proxy défini dans Réseau. DHT, uTP, trackers UDP et redirection de port sont désactivés via un proxy, et les pairs ne peuvent pas se connecter à vous. Prend effet au redémarrage de Ketch.</string>
<string name="settings_torrent_connections_footer">Le chiffrement cache la nature du trafic, pas les pairs auxquels vous vous connectez.</string>
<string name="settings_torrent_trackers">Trackers supplémentaires</string>
<string name="settings_torrent_no_trackers">Aucun tracker supplémentaire</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@
<string name="settings_torrent_port_mapping_hint">ルーター(UPnPまたはNAT-PMP)にポート転送を依頼し、より多くのピアがこのデバイスに接続できるようにします。</string>
<string name="settings_torrent_local_discovery">ローカルピア検出</string>
<string name="settings_torrent_local_discovery_hint">同じ公開トレントをダウンロードまたは共有しているローカルネットワーク上のデバイスを見つけ、ピースを直接やり取りします。</string>
<string name="settings_torrent_use_proxy">プロキシを使用</string>
<string name="settings_torrent_use_proxy_hint">「ネットワーク」で設定したプロキシ経由でピア、HTTP トラッカー、ウェブシードに接続します。プロキシ経由では DHT、uTP、UDP トラッカー、ポート転送は無効になり、ピアからの接続も受けられません。Ketch の再起動後に有効になります。</string>
<string name="settings_torrent_connections_footer">暗号化で隠れるのは通信の種類で、接続相手は隠れません。</string>
<string name="settings_torrent_trackers">追加トラッカー</string>
<string name="settings_torrent_no_trackers">追加トラッカーはありません</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@
<string name="settings_torrent_port_mapping_hint">라우터(UPnP 또는 NAT-PMP)에 포트 포워딩을 요청해 더 많은 피어가 이 기기에 연결할 수 있게 합니다.</string>
<string name="settings_torrent_local_discovery">로컬 피어 검색</string>
<string name="settings_torrent_local_discovery_hint">같은 공개 토렌트를 다운로드하거나 공유하는 로컬 네트워크의 기기를 찾아 조각을 직접 주고받습니다.</string>
<string name="settings_torrent_use_proxy">프록시 사용</string>
<string name="settings_torrent_use_proxy_hint">네트워크에서 설정한 프록시를 통해 피어, HTTP 트래커, 웹 시드에 연결합니다. 프록시를 사용하면 DHT, uTP, UDP 트래커, 포트 포워딩이 꺼지고 피어가 연결해 올 수 없습니다. Ketch를 다시 시작하면 적용됩니다.</string>
<string name="settings_torrent_connections_footer">암호화는 트래픽의 종류를 숨길 뿐, 누구와 연결하는지는 숨기지 않습니다.</string>
<string name="settings_torrent_trackers">추가 트래커</string>
<string name="settings_torrent_no_trackers">추가 트래커 없음</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,8 @@
<string name="settings_torrent_port_mapping_hint">Pede ao seu roteador (UPnP ou NAT-PMP) para redirecionar uma porta, para que mais peers possam se conectar a este dispositivo.</string>
<string name="settings_torrent_local_discovery">Descoberta de peers locais</string>
<string name="settings_torrent_local_discovery_hint">Encontra dispositivos na sua rede local que baixam ou compartilham os mesmos torrents públicos, para que troquem partes diretamente.</string>
<string name="settings_torrent_use_proxy">Usar o proxy</string>
<string name="settings_torrent_use_proxy_hint">Alcança pares, trackers HTTP e sementes web pelo proxy definido em Rede. DHT, uTP, trackers UDP e encaminhamento de portas ficam desativados com um proxy, e os pares não conseguem se conectar a você. Vale depois de reiniciar o Ketch.</string>
<string name="settings_torrent_connections_footer">A criptografia esconde que tipo de tráfego é, não com quem você se conecta.</string>
<string name="settings_torrent_trackers">Trackers extras</string>
<string name="settings_torrent_no_trackers">Nenhum tracker extra</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,8 @@
<string name="settings_torrent_port_mapping_hint">Просит роутер (UPnP или NAT-PMP) пробросить порт, чтобы к этому устройству могло подключиться больше пиров.</string>
<string name="settings_torrent_local_discovery">Поиск пиров в локальной сети</string>
<string name="settings_torrent_local_discovery_hint">Находит устройства в вашей локальной сети, которые скачивают или раздают те же публичные торренты, чтобы они обменивались частями напрямую.</string>
<string name="settings_torrent_use_proxy">Использовать прокси</string>
<string name="settings_torrent_use_proxy_hint">Пиры, HTTP-трекеры и веб-сиды доступны через прокси, заданный в разделе «Сеть». Через прокси не работают DHT, uTP, UDP-трекеры и проброс порта, а пиры не могут подключаться к вам. Вступает в силу после перезапуска Ketch.</string>
<string name="settings_torrent_connections_footer">Шифрование скрывает, что это за трафик, но не то, с кем вы соединяетесь.</string>
<string name="settings_torrent_trackers">Дополнительные трекеры</string>
<string name="settings_torrent_no_trackers">Нет дополнительных трекеров</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@
<string name="settings_torrent_port_mapping_hint">請求路由器(UPnP 或 NAT-PMP)轉送一個連接埠,讓更多對等端能連線至此裝置。</string>
<string name="settings_torrent_local_discovery">本機對等端探索</string>
<string name="settings_torrent_local_discovery_hint">尋找區域網路中下載或分享相同公開種子的裝置,讓它們直接交換資料塊。</string>
<string name="settings_torrent_use_proxy">使用代理</string>
<string name="settings_torrent_use_proxy_hint">透過「網路」中設定的代理連線節點、HTTP Tracker 和網頁種子。使用代理時 DHT、uTP、UDP Tracker 和連接埠轉送皆關閉,其他節點也無法連入。重新啟動 Ketch 後生效。</string>
<string name="settings_torrent_connections_footer">加密隱藏的是流量類型,而不是連線的對象。</string>
<string name="settings_torrent_trackers">額外的 Tracker</string>
<string name="settings_torrent_no_trackers">沒有額外的 Tracker</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,8 @@
<string name="settings_torrent_port_mapping_hint">请求路由器(UPnP 或 NAT-PMP)转发一个端口,让更多节点能连接到此设备。</string>
<string name="settings_torrent_local_discovery">本地节点发现</string>
<string name="settings_torrent_local_discovery_hint">查找本地网络中下载或分享相同公开种子的设备,让它们直接交换数据块。</string>
<string name="settings_torrent_use_proxy">使用代理</string>
<string name="settings_torrent_use_proxy_hint">通过“网络”中设置的代理连接节点、HTTP Tracker 和网页种子。使用代理时 DHT、uTP、UDP Tracker 和端口转发均关闭,其他节点也无法连入。重启 Ketch 后生效。</string>
<string name="settings_torrent_connections_footer">加密隐藏的是流量类型,而不是连接的对象。</string>
<string name="settings_torrent_trackers">额外的 Tracker</string>
<string name="settings_torrent_no_trackers">没有额外的 Tracker</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,8 @@
<string name="settings_torrent_port_mapping_hint">Asks your router (UPnP or NAT-PMP) to forward a port, so more peers can connect to this device.</string>
<string name="settings_torrent_local_discovery">Local peer discovery</string>
<string name="settings_torrent_local_discovery_hint">Finds devices on your local network that download or share the same public torrents, so they exchange pieces directly.</string>
<string name="settings_torrent_use_proxy">Use the proxy</string>
<string name="settings_torrent_use_proxy_hint">Reaches peers, HTTP trackers and web seeds through the proxy set under Network. DHT, uTP, UDP trackers and port forwarding are off through a proxy, and peers can't connect in. Takes effect when Ketch restarts.</string>
<string name="settings_torrent_connections_footer">Encryption hides what the traffic is, not who you connect to.</string>
<string name="settings_torrent_trackers">Extra trackers</string>
<string name="settings_torrent_no_trackers">No extra trackers</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ import ketch.app.shared.generated.resources.settings_torrent_upload_while_downlo
import ketch.app.shared.generated.resources.settings_torrent_upload_while_downloading_hint
import ketch.app.shared.generated.resources.settings_torrent_upload_wifi_only
import ketch.app.shared.generated.resources.settings_torrent_upload_wifi_only_hint
import ketch.app.shared.generated.resources.settings_torrent_use_proxy
import ketch.app.shared.generated.resources.settings_torrent_use_proxy_hint
import ketch.app.shared.generated.resources.settings_torrent_utp
import ketch.app.shared.generated.resources.settings_torrent_utp_hint
import org.jetbrains.compose.resources.StringResource
Expand Down Expand Up @@ -502,6 +504,15 @@ private fun ConnectionsGroup(
},
)
}
// The host builds the engine with it, so only this device's, and only from its next start.
if (onThisDevice) {
SettingsSwitchRow(
title = stringResource(Res.string.settings_torrent_use_proxy),
description = stringResource(Res.string.settings_torrent_use_proxy_hint),
checked = settings.useProxy,
onCheckedChange = { onChange(settings.copy(useProxy = it)) },
)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ private fun createInstanceManager(unreadableFiles: UnreadableFiles): InstanceMan
val instanceId = DeviceStore("$supportDir/$DEVICE_FILE_NAME").instanceId()
val torrentSource = TorrentDownloadSource(
TorrentConfig(stateDirectory = "$supportDir/torrent-state")
.withSettings(config.torrent.engineSettings),
.withSettings(config.torrent.engineSettings)
.copy(proxy = config.torrentProxy),
// Paused until the path monitor reports the network, moments after launch.
uploadsPaused = config.torrent.uploadWifiOnly,
)
Expand Down
1 change: 1 addition & 0 deletions cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,7 @@ on a server, changes made there, like the other download settings, last until it
| `trackers` | string[] | `[]` | Extra `http`, `https` or `udp` trackers that public torrents also announce to |
| `trackerList` | bool | `true` | Subscribe to the tracker lists at `trackerListUrls`, downloaded daily; their trackers are used after `trackers` |
| `trackerListUrls` | string[] | ngosang's [`trackers_best.txt`](https://github.com/ngosang/trackerslist) and XIU2's [`best.txt`](https://github.com/XIU2/TrackersListCollection) | `http` or `https` URLs of plain-text lists, one announce URL per line |
| `useProxy` | bool | `false` | Send torrents through the manual proxy of `[download.proxy]`; without DHT, uTP, UDP trackers, local discovery or port forwarding. Read at start |
| `listenPort` | int | `0` | Port `ketch server` accepts peers on (TCP) and runs DHT on (UDP), 0-65535; `0` picks a free one at every start. The apps and the other commands always pick one, so they never compete for it |
| `upload` | string | `"while-downloading"` | What torrents upload to peers: `while-downloading` (verified pieces, until each torrent finishes), `off` or `seed` (finished torrents too, also after `ketch server` restarts). Peers you upload to see your IP address. Unknown values load as `off`, so a typo never turns uploading on. `ketch server` also takes it from `--torrent-upload` and `KETCH_TORRENT_UPLOAD` |
| `uploadLimit` | string | `"unlimited"` | Upload cap shared by all torrents, in the [speed limit format](#speed-limit-format); a value that cannot be read loads as unlimited |
Expand Down
Loading
Loading