1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2017, NORDUnet A/S.
# See LICENSE for licensing information.
#
import sys
import json
import urllib2
import time
import requests
import base64
from base64 import b64encode
from mergetools import parse_args, get_nfetched, hexencode, hexdecode, \
get_logorder, get_sth
from certtools import create_ssl_context, get_public_key_from_file, \
timing_point, create_sth_signature, write_file, check_sth_signature, \
build_merkle_tree
def main():
args, config, localconfig = parse_args()
paths = localconfig["paths"]
mergenodes = config.get("mergenodes", [])
mergedb = paths["mergedb"]
sthfile = mergedb + "/sth"
currentsizefile = mergedb + "/fetched"
sth = json.loads(open(sthfile, "r").read())
currentsize = json.loads(open(currentsizefile, "r").read())
print >>sys.stderr, currentsize["index"]+1,
for mergenode in mergenodes:
if mergenode["name"] == config["primarymergenode"]:
continue
verifiedfile = mergedb + "/verified." + mergenode["name"]
try:
tree = json.loads(open(verifiedfile, "r").read())
print >>sys.stderr, tree["tree_size"],
except (IOError, ValueError):
pass
print >>sys.stderr, sth["tree_size"],
print
if __name__ == '__main__':
sys.exit(main())
|