berty / go-libp2p-tor-transport

🚧 WIP: tor transport for libp2p
Apache License 2.0
53 stars 7 forks source link

Expose Dialer #10

Open cpacia opened 4 years ago

cpacia commented 4 years ago

Once the dialer has been created provide a way for the user to access it so they can use it for other connections (for example, http).

Not sure the best way here. Possibly by returning the dialer from NewBuilder() or maybe via an option where the user passes in a pointer to the dialer and the contructor sets it. Either way it's a little awkward, but useful functionality.

Jorropo commented 4 years ago

Once the dialer has been created provide a way for the user to access it so they can use it for other connections (for example, http).

Not sure the best way here. Possibly by returning the dialer from NewBuilder() or maybe via an option where the user passes in a pointer to the dialer and the contructor sets it. Either way it's a little awkward, but useful functionality.

Thx for pointing this. This is totally possible but would complicate a bit the life cycle of the tor node (it would need to probably have a ref counter or something of this kind because you don't want to loose your tor node when libp2p closes if you are using it elsewhere). I think the most simple way is to create a new NewBuilder, like NewBuilderWithDialer. I find using a call back or a pointer in an option not intuitive but it have a very strong point, wich is it's modular AF, in the future with more returns option (like resolver) more Builders could become a mess (I guess in this case there will be an easy NewBuilder and a FullNewBuilder with all returns options).