Comments (9)
why is this still open?
from txtorcon.
I was waffling on the API I really want to support for this, basically. Currently IStreamListener.stream_failed has a remote_reason argument; I'm thinking of changing this to just be a dict of any/all the flags passed from Tor but want to make sure that's a Good Idea so I don't have to change the API twice ;)
from txtorcon.
Do you think it's better to pass the additional flags as a single argument which is a dict, or as a **kwargs style thing? I'll push branch "issue-18" in a moment if anyone cares to comment.
from txtorcon.
**kwargs was made for "single argument which is a dict of some parameters"
For example: This allows you to "upgrade" a specific flag to a full function keyword by simply changing foo(arg1, *_kwargs) to foo(arg1, arg2, *_kwargs)
from txtorcon.
...the advantage of using **kwargs would be that you could declare an implementation like:
def circuit_closed(self, circuit, remote_reason=None, reason=None)
...if you only care about two of the possible flags. Contrasted with:
def circuit_closed(self, circuit, flags):
if 'remote_reason' in flags:
pass
from txtorcon.
It depends on wether or not you expect the signature of circuit_closed() to be stable and how important those flags are. If "remote_reason" is used all the time, I would consider it being a keyword to the function more intuitive:
def circuit_closed(self, circuit, remote_reason=None, **additional_flags):
if remote_reason == "smells":
if 'type_of_stink' in additional_flags:
...
from txtorcon.
"reason" is always present (for closed, failed circuits) and remote_reason "often" (only if the other Tor closed the connection). There are other flags, and the spec says they may add more whenever, so I would expect this list to keep growing (and, obviously, I don't want to change the API every time control-spec changes).
So, I will probably declare the methods with reason (and maybe remote_reason?) and leave the rest in **kwargs. Sorry I still haven't pushed the issue-18 branch, should get to that in the next couple hours.
from txtorcon.
I'd consider circuit_closed(self, circuit, reason, **additional_flags) then
from txtorcon.
One other thought: I could save any flags from the last update as "stream.flags" and the interested event handlers can still easily access them. It's not 100% clear to me from the control-spec, but it seems that the correct state of the stream is reflected by the union of all received flags for events on the stream.
from txtorcon.
Related Issues (20)
- attribute-error on python 3.9
- All of test.test_util is skipped HOT 1
- All of test.test_web skipped
- Many tests in test.test_endpoints.EndpointTests fail when calling `_tor_launcher` with incompatible arguments
- Hosting onion service log says .onion twice
- Three tests errors (test_attribute_access, test_other_bootstrap, and ProtocolIntegrationTests.test_with_arg) HOT 3
- v2 onion in repo metadata HOT 1
- update CI
- use unittest.mock instead of mock HOT 3
- Unable to install txsocksx with python 3 HOT 1
- There is a lingering ipaddress dependency declaration HOT 1
- 1 test fails: AttributeError: [...] does not have the attribute 'pwd'
- twisted.web Agent created by txtorcon should accept other Agent options
- Add support for Python 3.10 and 3.11
- Three unit tests are failing on Python 3.12
- When tor process exits unexpectedly tor.protocol.get_info hangs HOT 5
- Handle limits better HOT 1
- debian sid bug: 1060955
- cant gpg verefy 23.11.0 HOT 6
- Drop or declare dependency on six HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from txtorcon.