diff options
author | Rob Austein <sra@hactrn.net> | 2009-06-18 19:45:00 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2009-06-18 19:45:00 +0000 |
commit | 69c47b4a044d85777ba7c0e9efcbd4cb7ff60e0c (patch) | |
tree | 2c7a8da4fd363121c23ab6e8cd0e3be55bd91a81 /myrpki/myrpki.py | |
parent | cf4e9bd35962a99ec8868f917f5642a7a8bd3997 (diff) |
Checkpoint
svn path=/myrpki/Makefile; revision=2536
Diffstat (limited to 'myrpki/myrpki.py')
-rw-r--r-- | myrpki/myrpki.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/myrpki/myrpki.py b/myrpki/myrpki.py index 4c5df830..e4dd7409 100644 --- a/myrpki/myrpki.py +++ b/myrpki/myrpki.py @@ -46,9 +46,6 @@ bpki_ee_req_file = cfg.get(myrpki_section, "bpki_ee_pkcs10") output_filename = cfg.get(myrpki_section, "output_filename") relaxng_schema = cfg.get(myrpki_section, "relaxng_schema") -v4regexp = re.compile("^[-0-9./]+$", re.I) -v6regexp = re.compile("^[-0-9a-f:/]+$", re.I) - class comma_set(set): def __str__(self): @@ -56,15 +53,18 @@ class comma_set(set): class roa_request(object): + v4re = re.compile("^([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]+(-[0-9]+)?$", re.I) + v6re = re.compile("^([0-9a-f]{0,4}:){0,15}[0-9a-f]{0,4}/[0-9]+(-[0-9]+)?$", re.I) + def __init__(self, asn): self.asn = asn self.v4 = comma_set() self.v6 = comma_set() def add(self, prefix): - if v4regexp.match(prefix): + if self.v4re.match(prefix): self.v4.add(prefix) - elif v6regexp.match(prefix): + elif self.v6re.match(prefix): self.v6.add(prefix) else: raise RuntimeError, 'Bad prefix syntax: "%s"' % prefix @@ -88,6 +88,9 @@ class roa_requests(dict): class child(object): + v4re = re.compile("^(([0-9]{1,3}\.){3}[0-9]{1,3}/[0-9]+)|(([0-9]{1,3}\.){3}[0-9]{1,3}-([0-9]{1,3}\.){3}[0-9]{1,3})$", re.I) + v6re = re.compile("^(([0-9a-f]{0,4}:){0,15}[0-9a-f]{0,4}/[0-9]+)|(([0-9a-f]{0,4}:){0,15}[0-9a-f]{0,4}-([0-9a-f]{0,4}:){0,15}[0-9a-f]{0,4})$", re.I) + def __init__(self, handle): self.handle = handle self.asns = comma_set() @@ -97,9 +100,9 @@ class child(object): def add(self, prefix = None, asn = None, validity = None): if prefix is not None: - if v4regexp.match(prefix): + if self.v4re.match(prefix): self.v4.add(prefix) - elif v6regexp.match(prefix): + elif self.v6re.match(prefix): self.v6.add(prefix) else: raise RuntimeError, 'Bad prefix syntax: "%s"' % prefix @@ -194,6 +197,3 @@ bpki_ee(e) ElementTree(e).write(output_filename + ".tmp") os.rename(output_filename + ".tmp", output_filename) - -subprocess.check_call(("xmllint", "-relaxng", relaxng_schema, - "-noout", output_filename)) |