Last change
on this file since 9 was
3,
checked in by tim, 9 years ago
|
.
|
-
Property svn:executable set to
*
|
File size:
1.3 KB
|
Rev | Line | |
---|
[3] | 1 | #!/usr/bin/env python3 |
---|
| 2 | # |
---|
| 3 | # Copyright (C) 2015 Blindspot Security LLC |
---|
| 4 | # by Timothy D. Morgan |
---|
| 5 | # twits: @ecbftw |
---|
| 6 | |
---|
| 7 | import sys |
---|
| 8 | import time |
---|
| 9 | import hashlib |
---|
| 10 | import socketserver |
---|
| 11 | import http.server |
---|
| 12 | |
---|
| 13 | |
---|
| 14 | class HashHandler(http.server.BaseHTTPRequestHandler): |
---|
| 15 | """ |
---|
| 16 | """ |
---|
| 17 | |
---|
| 18 | def do_GET(self): |
---|
| 19 | resolution = time.clock_getres(time.CLOCK_MONOTONIC) |
---|
| 20 | |
---|
| 21 | do_parse = False |
---|
| 22 | if 't=' in self.path and self.path.split('t=', 1)[1] == '1': |
---|
| 23 | do_parse = True |
---|
| 24 | |
---|
| 25 | received = int(time.monotonic()/resolution) |
---|
| 26 | if do_parse: |
---|
| 27 | x = json.loads('[{"sampler_rtt": 58998274, "test_case": "short", "requests_rtt": 58528000, "sample": 32, "unix_time": 1425061969829780736, "local_port": 45387, "order": 0}, {"sampler_rtt": 59420191, "test_case": "long", "requests_rtt": 58036000, "sample": 32, "unix_time": 1425061969829780736, "local_port": 45386, "order": 1}]') |
---|
| 28 | now = int(time.monotonic()/resolution) |
---|
| 29 | |
---|
| 30 | self.send_response(200) |
---|
| 31 | self.send_header('Content-Type','text/plain; charset=UTF-8') |
---|
| 32 | self.end_headers() |
---|
| 33 | |
---|
| 34 | content = "waited: %d\n" % (now - received) |
---|
| 35 | self.wfile.write(content.encode('utf-8')) |
---|
| 36 | self.wfile.flush() |
---|
| 37 | |
---|
| 38 | |
---|
| 39 | if __name__ == "__main__": |
---|
| 40 | HOST, PORT = "0.0.0.0", 3240 |
---|
| 41 | server = socketserver.TCPServer((HOST, PORT), HashHandler) |
---|
| 42 | server.serve_forever() |
---|
Note: See
TracBrowser
for help on using the repository browser.