Closed2

Tor クライアントを複数起動する

nakasyounakasyou
tor -f .torrc

のようにして構成ファイルを指定できる
なので、超簡単に

import { join } from '@std/path'

await Deno.mkdir('.tor', { recursive: true })
await Deno.mkdir('.tor/torrc', { recursive: true })
await Deno.mkdir('.tor/data', { recursive: true })

// kill current tor process
await new Deno.Command('pkill', {
  args: [
    '-9',
    'tor',
  ],
}).output()

for (let i = 0; i < 16; i++) {
  const torrcPath = join(Deno.cwd(), `.tor/torrc/torrc-${i}`)
  const torrc = `SocksPort ${9000 + i}\nDataDirectory ${
    join(Deno.cwd(), '.tor/data', i.toString())
  }`
  await Deno.writeTextFile(torrcPath, torrc)
  const command = new Deno.Command('tor', {
    args: [
      '-f',
      torrcPath,
    ],
    stdout: 'null'
  })
  console.log(command.spawn())
}
Deno.exit(0)

でいける

このスクラップは3ヶ月前にクローズされました