~ubuntu-branches/ubuntu/saucy/juju-core/saucy

« back to all changes in this revision

Viewing changes to src/launchpad.net/gwacl/fork/tls/parse-gnutls-cli-debug-log.py

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-07-23 08:51:44 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20130723085144-0oty5omapea7t8xt
Tags: 1.11.4-0ubuntu1
* New upstream release:
  - d/copyright: Drop section for go-curl.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2010 The Go Authors. All rights reserved.
 
2
# Use of this source code is governed by a BSD-style
 
3
# license that can be found in the LICENSE file.
 
4
 
 
5
# This code is used to parse the debug log from gnutls-cli and generate a
 
6
# script of the handshake. This script is included in handshake_server_test.go.
 
7
# See the comments there for details.
 
8
 
 
9
import sys
 
10
 
 
11
blocks = []
 
12
 
 
13
READ = 1
 
14
WRITE = 2
 
15
 
 
16
currentBlockType = 0
 
17
currentBlock = []
 
18
for line in sys.stdin.readlines():
 
19
        line = line[:-1]
 
20
        if line.startswith("|<7>| WRITE: "):
 
21
                if currentBlockType != WRITE:
 
22
                        if len(currentBlock) > 0:
 
23
                                blocks.append(currentBlock)
 
24
                        currentBlock = []
 
25
                        currentBlockType = WRITE
 
26
        elif line.startswith("|<7>| READ: "):
 
27
                if currentBlockType != READ:
 
28
                        if len(currentBlock) > 0:
 
29
                                blocks.append(currentBlock)
 
30
                        currentBlock = []
 
31
                        currentBlockType = READ
 
32
        elif line.startswith("|<7>| 0"):
 
33
                line = line[13:]
 
34
                line = line.strip()
 
35
                bs = line.split()
 
36
                for b in bs:
 
37
                        currentBlock.append(int(b, 16))
 
38
        elif line.startswith("|<7>| RB-PEEK: Read 1 bytes"):
 
39
                currentBlock = currentBlock[:-1]
 
40
 
 
41
if len(currentBlock) > 0:
 
42
        blocks.append(currentBlock)
 
43
 
 
44
for block in blocks:
 
45
        sys.stdout.write("\t{\n")
 
46
 
 
47
        i = 0
 
48
        for b in block:
 
49
                if i % 8 == 0:
 
50
                        sys.stdout.write("\t\t")
 
51
                sys.stdout.write("0x%02x," % b)
 
52
                if i % 8 == 7:
 
53
                        sys.stdout.write("\n")
 
54
                else:
 
55
                        sys.stdout.write(" ")
 
56
                i += 1
 
57
        sys.stdout.write("\n\t},\n\n")