mirror of
https://github.com/mitmproxy/mitmproxy.git
synced 2024-11-27 15:20:51 +00:00
Store timestamps on flow components as a UTC time tuple.
Format is: (tm_year,tm_mon,tm_mday,tm_hour,tm_min, tm_sec,tm_wday,tm_yday,tm_isdst)
This commit is contained in:
parent
64cce94238
commit
765871bd11
@ -5,7 +5,7 @@
|
||||
|
||||
Development started from Neil Schemenauer's munchy.py
|
||||
"""
|
||||
import sys, os, time, string, socket, urlparse, re, select, copy, base64
|
||||
import sys, os, string, socket, urlparse, re, select, copy, base64
|
||||
import shutil, tempfile
|
||||
import optparse, SocketServer, ssl
|
||||
import utils, controller
|
||||
@ -132,7 +132,7 @@ class Request(controller.Msg):
|
||||
self.client_conn = client_conn
|
||||
self.host, self.port, self.scheme = host, port, scheme
|
||||
self.method, self.path, self.headers, self.content = method, path, headers, content
|
||||
self.timestamp = timestamp or time.time()
|
||||
self.timestamp = timestamp or utils.timestamp()
|
||||
self.close = False
|
||||
controller.Msg.__init__(self)
|
||||
|
||||
@ -262,7 +262,7 @@ class Response(controller.Msg):
|
||||
self.request = request
|
||||
self.code, self.msg = code, msg
|
||||
self.headers, self.content = headers, content
|
||||
self.timestamp = timestamp or time.time()
|
||||
self.timestamp = timestamp or utils.timestamp()
|
||||
self.cached = False
|
||||
controller.Msg.__init__(self)
|
||||
self.replay = False
|
||||
@ -376,7 +376,7 @@ class ClientConnect(controller.Msg):
|
||||
class Error(controller.Msg):
|
||||
def __init__(self, request, msg, timestamp=None):
|
||||
self.request, self.msg = request, msg
|
||||
self.timestamp = timestamp or time.time()
|
||||
self.timestamp = timestamp or utils.timestamp()
|
||||
controller.Msg.__init__(self)
|
||||
|
||||
def load_state(self, state):
|
||||
|
@ -12,10 +12,18 @@
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
import re, os, subprocess, datetime, textwrap, errno, sys
|
||||
import re, os, subprocess, datetime, textwrap, errno, sys, time, pytz
|
||||
|
||||
|
||||
def timestamp():
|
||||
d = datetime.datetime.utcnow()
|
||||
return list(d.timetuple())
|
||||
|
||||
|
||||
def format_timestamp(s):
|
||||
d = datetime.datetime.fromtimestamp(s)
|
||||
s = time.struct_time(s)
|
||||
d = datetime.datetime.fromtimestamp(time.mktime(s))
|
||||
d = d - datetime.timedelta(seconds=time.altzone)
|
||||
return d.strftime("%Y-%m-%d %H:%M:%S")
|
||||
|
||||
|
||||
|
@ -5,7 +5,7 @@ from libmproxy import utils
|
||||
|
||||
class uformat_timestamp(libpry.AutoTree):
|
||||
def test_simple(self):
|
||||
assert utils.format_timestamp(time.time())
|
||||
assert utils.format_timestamp(utils.timestamp())
|
||||
|
||||
|
||||
class uisBin(libpry.AutoTree):
|
||||
|
Loading…
Reference in New Issue
Block a user