[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 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
}
}}}
If there are two separate functions, then we should document and implement
one to be the inverse of the other, rather than having two separate
functions testing two different environment variables. I'm not such a fan
of that idea, because the second function amounts to a convenience
function. It would look like:
{{{
func IsServer() bool {
return !IsClient()
}
}}}
I'd like there to be additional test cases. The code should do something
reasonable in all of them.
1. TOR_PT_CLIENT_TRANSPORTS and TOR_PT_SERVER_TRANSPORTS both unset.
2. TOR_PT_CLIENT_TRANSPORTS unset, TOR_PT_SERVER_TRANSPORTS set.
3. TOR_PT_CLIENT_TRANSPORTS set, TOR_PT_SERVER_TRANSPORTS unset.
4. TOR_PT_CLIENT_TRANSPORTS and TOR_PT_SERVER_TRANSPORTS both set.
--
Ticket URL: <https://trac.torproject.org/projects/tor/ticket/12087#comment:2>
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