[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [tor-bugs] #12087 [Pluggable transport]: goptlib could provide IsClient()/IsServer().



#12087: goptlib could provide IsClient()/IsServer().
-------------------------------------+------------------------------
     Reporter:  yawning              |      Owner:  asn
         Type:  enhancement          |     Status:  needs_review
     Priority:  minor                |  Milestone:
    Component:  Pluggable transport  |    Version:
   Resolution:                       |   Keywords:  goptlib, library
Actual Points:                       |  Parent ID:
       Points:                       |
-------------------------------------+------------------------------

Comment (by asn):

 Replying to [comment:2 dcf]:
 > Replying to [comment:1 dcf]:
 > > Proposed patch:
 > >  * https://gitweb.torproject.org/pluggable-
 transports/goptlib.git/commitdiff/c1482145a738b9378ee6a5f7067544bea7414f34
 >
 > I'm fine with applications having to peek at environment variables if
 they need this functionality, at least in the short term.
 >
 > I'm thinking about the application's interface to these functions. I
 guess it would have to look like this?
 > {{{
 > if pt.IsClient() {
 >         // do client stuff
 > } else if pt.IsServer() {
 >         // do server stuff
 > } else {
 >         // handle error? pt.EnvError?
 > }
 > }}}
 > Since "client mode" and "server mode" are the only two possibilities,
 maybe it makes sense to have only one function to test the mode, rather
 than two, so that there can be no ambiguity or disagreement between the
 two functions? In other words,
 > {{{
 > if pt.IsClient() {
 >         // do client stuff
 > } else {
 >         // do server stuff
 > }
 > }}}

 Yes. I think having one function instead of two is a reasonable idea. It
 might be simpler for the people who use the library too, since they won't
 have to think of what to do in the `pt.IsClient() && pt.IsServer()` case.

 (API nitpicking:

 FWIW, I never really liked the `isClient()` method of pyptlib (called
 `checkClientMode()`). blanu added it in the first version of pyptlib and
 it has been around since then. However it always seemed to me a bit
 unecessary.

 If I were to write pyptlib today, I would perhaps make the pyptlib
 `init()` function return a boolean `is_client` and a pyptlib object of the
 proper type. Since the `init` function signature is the same for client
 and the server (it takes as input a list of the names of the transports)
 that seems possible.
 )

--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/12087#comment:4>
Tor Bug Tracker & Wiki <https://trac.torproject.org/>
The Tor Project: anonymity online
_______________________________________________
tor-bugs mailing list
tor-bugs@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-bugs