Skip to content

Commit 7cfd49e

Browse files
committed
allow different rpc url for tor
1 parent 3ae7727 commit 7cfd49e

File tree

2 files changed

+20
-1
lines changed
  • site/pages/docs/clients/transports
  • src/clients/transports

2 files changed

+20
-1
lines changed

site/pages/docs/clients/transports/http.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,22 @@ Determines which requests should be routed through Tor:
316316
- If an array of strings: Only RPC methods matching these names will use Tor
317317
- If a function: Called for each request to determine if it should use Tor
318318

319+
### tor.url (optional)
320+
321+
- **Type:** `string`
322+
- **Default:** Same URL as non-Tor requests
323+
324+
The RPC URL to use when routing requests through Tor.
325+
319326
### tor.sharedClient (optional)
320327

321328
- **Type:** `TorClient`
322329

323330
A shared TorClient instance to reuse across multiple transports. If not provided, a new TorClient will be created using the other TorClientOptions.
331+
332+
### tor.timeout (optional)
333+
334+
- **Type:** `number`
335+
- **Default:** `max(60_000, config.timeout)`
336+
337+
The timeout (in ms) for the HTTP request over Tor.

src/clients/transports/http.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,11 @@ export type HttpTransportConfig<
7777
* - If a function: Called for each request to determine if it should use Tor
7878
*/
7979
filter: string[] | RpcRequestFilter
80+
/**
81+
* The RPC url to use when routing through tor.
82+
* Default: same url as non-tor requests.
83+
*/
84+
url?: string
8085
/**
8186
* A shared TorClient instance to reuse across multiple transports.
8287
* If not provided, a new TorClient will be created using the other TorClientOptions.
@@ -228,7 +233,7 @@ function makeTorTools(
228233
}
229234

230235
return {
231-
rpcClient: getHttpRpcClient(url, {
236+
rpcClient: getHttpRpcClient(torConfig.url ?? url, {
232237
...rpcClientOptions,
233238
fetchFn: (input, init) => tor.fetch(input.toString(), init),
234239
timeout: torConfig.timeout ?? Math.max(timeout, 60_000),

0 commit comments

Comments
 (0)