()
| 157 | let client: TorClient | undefined |
| 158 | |
| 159 | export const getTorClient = async () => { |
| 160 | if (!client) { |
| 161 | const config = createTorConfig() |
| 162 | logger('config: %o', config) |
| 163 | |
| 164 | if (config.host !== undefined) { |
| 165 | logger('connecting') |
| 166 | client = new TorClient(config) |
| 167 | try { |
| 168 | await client.connect() |
| 169 | } catch (_error) { |
| 170 | client = undefined |
| 171 | } |
| 172 | logger('connected') |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | return client |
| 177 | } |
| 178 | export const closeTorClient = async () => { |
| 179 | if (client) { |
| 180 | await client.quit() |
no test coverage detected