Add attribution and license for tnetstring.py

This commit is contained in:
Aldo Cortesi 2011-08-19 21:38:05 +12:00
parent a566684e32
commit 45f4768a5c
3 changed files with 26 additions and 20 deletions

View File

@ -2,9 +2,9 @@
This module provides more sophisticated flow tracking. These match requests
with their responses, and provide filtering and interception facilities.
"""
import json, hashlib, Cookie, cookielib, base64, copy, re
import hashlib, Cookie, cookielib, copy, re
import time
import netstring, filt, script, utils, encoding, proxy
import tnetstring, filt, script, utils, encoding, proxy
from email.utils import parsedate_tz, formatdate, mktime_tz
import controller, version
@ -1319,7 +1319,7 @@ class FlowWriter:
def add(self, flow):
d = flow._get_state()
netstring.dump(d, self.fo)
tnetstring.dump(d, self.fo)
class FlowReadError(Exception):
@ -1339,7 +1339,7 @@ class FlowReader:
off = 0
try:
while 1:
data = netstring.load(self.fo)
data = tnetstring.load(self.fo)
off = self.fo.tell()
yield Flow._from_state(data)
except ValueError, v:

View File

@ -1,5 +1,25 @@
# imported from the tnetstring project: https://github.com/rfk/tnetstring
#
# Copyright (c) 2011 Ryan Kelly
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
"""
tnetstring: data serialization using typed netstrings
======================================================
@ -376,18 +396,3 @@ def pop(string,encoding=None):
d[key] = val
return (d,remain)
raise ValueError("unknown type tag")
# Use the c-extension version if available
try:
import _tnetstring
except ImportError:
pass
else:
dumps = _tnetstring.dumps
load = _tnetstring.load
loads = _tnetstring.loads
pop = _tnetstring.pop

View File

@ -2,4 +2,5 @@ base = ..
coverage = ../libmproxy
exclude = .
../libmproxy/contrib
../libmproxy/tnetstring.py