mirror of
https://github.com/vacp2p/nim-libp2p-experimental.git
synced 2025-02-11 09:36:50 +00:00
Adding private key with torswitch construtor
This commit is contained in:
parent
b751686b69
commit
bdadbd22ad
@ -272,6 +272,35 @@ proc new*(
|
||||
torSwitch.connManager.peerStore = switch.peerStore
|
||||
return torSwitch
|
||||
|
||||
proc new*(
|
||||
T: typedesc[TorSwitch],
|
||||
torServer: TransportAddress,
|
||||
rng: ref HmacDrbgContext,
|
||||
addresses: seq[MultiAddress] = @[],
|
||||
flags: set[ServerFlags] = {}
|
||||
seckey: PrivateKey ): TorSwitch
|
||||
{.raises: [LPError], public.} =
|
||||
var builder = SwitchBuilder.new()
|
||||
.withPrivateKey(seckey)
|
||||
.withRng(rng)
|
||||
.withTransport(proc(upgr: Upgrade): Transport = TorTransport.new(torServer, flags, upgr))
|
||||
if addresses.len != 0:
|
||||
builder = builder.withAddresses(addresses)
|
||||
let switch = builder.withMplex()
|
||||
.withNoise()
|
||||
.build()
|
||||
let torSwitch = T(
|
||||
peerInfo: switch.peerInfo,
|
||||
ms: switch.ms,
|
||||
transports: switch.transports,
|
||||
connManager: switch.connManager,
|
||||
peerStore: switch.peerStore,
|
||||
dialer: Dialer.new(switch.peerInfo.peerId, switch.connManager, switch.peerStore, switch.transports, nil),
|
||||
nameResolver: nil)
|
||||
|
||||
torSwitch.connManager.peerStore = switch.peerStore
|
||||
return torSwitch
|
||||
|
||||
method addTransport*(s: TorSwitch, t: Transport) =
|
||||
doAssert(false, "not implemented!")
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user