GithubHelp home page GithubHelp logo

Comments (9)

lukaslueg avatar lukaslueg commented on May 30, 2024

why is this still open?

from txtorcon.

meejah avatar meejah commented on May 30, 2024

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.

meejah avatar meejah commented on May 30, 2024

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.

lukaslueg avatar lukaslueg commented on May 30, 2024

**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.

meejah avatar meejah commented on May 30, 2024

...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.

lukaslueg avatar lukaslueg commented on May 30, 2024

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.

meejah avatar meejah commented on May 30, 2024

"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.

lukaslueg avatar lukaslueg commented on May 30, 2024

I'd consider circuit_closed(self, circuit, reason, **additional_flags) then

from txtorcon.

meejah avatar meejah commented on May 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.