diff options
Diffstat (limited to 'monitor/josef_leveldb.py')
| -rwxr-xr-x | monitor/josef_leveldb.py | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/monitor/josef_leveldb.py b/monitor/josef_leveldb.py index cee0035..9557bb2 100755 --- a/monitor/josef_leveldb.py +++ b/monitor/josef_leveldb.py @@ -10,6 +10,7 @@ SEP = ";" def match_domain(d1, d2): + # print d1, d2 # Exact match if d1 == d2: return True @@ -60,12 +61,14 @@ def db_add_domain(db, domain, data): tmpl = domain.split('.') k = "" for item in reversed(tmpl): - next_k = item + '.' + k - if k != "": - db_append(db, k[:-1], next_k[:-1]) + if k == "": + next_k = item + else: + next_k = item + '.' + k + db_append(db, k, next_k) k = next_k - db.Delete(k[:-1]) - db_append(db, k[:-1], data) + db.Delete(k) + db_append(db, k, data) def db_add_certs(db, data): @@ -95,9 +98,13 @@ def db_lookup_domain(db, domain): cur_domain = domain_list.pop() intermediate = db.Get(cur_domain).split(SEP) - while True: try: + intermediate.remove("") + except ValueError: + pass + + try: cur_domain = domain_list.pop() + "." + cur_domain except IndexError: return res @@ -105,11 +112,11 @@ def db_lookup_domain(db, domain): next_level = [] for item in intermediate: if match_domain(cur_domain, item): - # print item + print item try: tmp = db.Get(item) if tmp[1] == '{': - res.append(tmp[1:-1]) + res.append(tmp[1:]) next_level += tmp.split(SEP) except KeyError: # print "Could not find " + item @@ -118,10 +125,6 @@ def db_lookup_domain(db, domain): else: intermediate.remove(item) intermediate = next_level - try: - intermediate.remove("") - except ValueError: - pass return res |
