New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Persei to add sanity to our string handling ($25) #3

Closed
campadrenalin opened this Issue May 15, 2013 · 4 comments

Comments

Projects
None yet
1 participant
@campadrenalin
Copy link
Owner

campadrenalin commented May 15, 2013

The code is currently designed around the unicode clusterfuck that is Python 2, just barely tapped here and there into working in Python 3 in fairly fragile ways. Let's fix that before anything else.

I've factored out the code in ejtp.util.py2and3 into an external library, Persei, for use in Pymads and other projects.

@campadrenalin

This comment has been minimized.

Copy link
Owner

campadrenalin commented May 15, 2013

Bounty is $25.

http://www.freedomsponsors.org/core/issue/260/use-persei-to-add-sanity-to-our-string-handling


(Copied from acceptance criteria)

Add Persei as an external dependency in setup.py and tox.ini. Use persei.RawData and persei.String to make the interfaces between struct-y code and the rest of the codebase sane. You may ignore legacy files pymads.sources.pymadsfile and pymads.filters.pymadsrr.

campadrenalin added a commit that referenced this issue Jul 2, 2013

campadrenalin added a commit that referenced this issue Jul 2, 2013

@campadrenalin

This comment has been minimized.

Copy link
Owner

campadrenalin commented Jul 2, 2013

At this point, all tests pass, but I'm not super-confident in the infrastructure yet. I'd like to work out some standards for the borders and conversions, and then apply them rigorously.

Stored things

  • Record
    • domain_name : String
    • type : str
    • class : str
    • ttl : int
    • rdata : RawData
  • Packet
    • qid : int
    • flags : int
    • question : [String]
    • type : int
    • class : int
    • records : [Record]
  • Const
    • Use str for all labels, int for all codes.
  • Sources
    • Dict, JSON : str
    • DNS : Generally uses custom classes except get(str)

Transmission

  • Server
    • Let consumer do RawData conversion (for efficient piping)
    • No weird stuff in config
  • Consumer
    • Convert packet to RawData
  • DNS source
    • exchange() should pass a RawData into resp.unpack
    • Use regular (str, int) tuples for server addresses - should be able to plug right into socket.bind

Working this out has also made me realize some inconsistencies between packets and records (rtype and rclass are stored as str, qtype and qclass as int) that are not worth fixing as part of this already-invasive branch. I also have some ideas for reducing the argument length on both. That'll all be one issue, I just have to make it.

campadrenalin added a commit that referenced this issue Jul 3, 2013

@campadrenalin

This comment has been minimized.

Copy link
Owner

campadrenalin commented Jul 3, 2013

All the Storage section is done according to the above spec. Just need to do a few minor tweaks, and the Transmission section will be fulfilled as well.

@campadrenalin

This comment has been minimized.

Copy link
Owner

campadrenalin commented Jul 3, 2013

Actually, the relevant unpack functions already handle the conversion, so this is all good to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment