) rr_domain_name_or_wildcard_type.setName('<rr-name-or-wildcard>') rr_domain_name_or_wildcard_type.setResultsName('domain_name') # Bind9 convention # domain_name = rr_fqdn_w_absolute # domain_name.setName('domain_name') # hostname do not have underscore, just [a-z0-9\-] # OS imposes a minimum size of 3 for hostname, but DNS server can support 1-char # RFC952 caps hostname at 24 chars maximum. # Hostname cannot be of dotted-quad notation # Hostname cannot handle leadng/trailing hyphen/dash. # Max length is 64 (since Linux 1.0+ via HOST_NAME_MAX) host_name_first_char = Char(srange('[a-zA-Z0-9]')) host_name_first_char.setName('<one_char_hostname>') host_name_two_chars = Combine(Char(srange('[a-zA-Z0-9]')) + Char(srange('[a-zA-Z0-9]'))) host_name_two_chars.setName('<two_char_hostname>') charset_host_name_middle_chars = srange('[a-zA-Z0-9]') + '-' host_name_long_type = Regex('[a-zA-Z0-9]{1}[a-zA-Z0-9\-]{0,62}[a-zA-Z0-9]{1}')('hostname_long') host_name_long_type.setName('<hostname_regex>') # TODO block examples like 'example-.-nono' host_name_just_the_hostname = ( host_name_long_type | host_name_two_chars | host_name_first_char )('hostname_indice')
import os import os.path import errno import sys import argparse from pprint import PrettyPrinter from pyparsing import Literal, CaselessLiteral, \ ParseException, ParseSyntaxException, \ Word, alphanums, Group, Optional, nums, Combine, Char, \ cppStyleComment, pythonStyleComment, OneOrMore, \ Suppress, ungroup unix_pipe_support = False period = Literal('.') exclamation = Char('!') exclamation.setName('not') lbrack, rbrack, semicolon, slash = map(Suppress, '{};/') dquote = Literal('"').setName("'\"'") squote = Literal("'").setName('"\'"') isc_boolean = ( CaselessLiteral('yes') | CaselessLiteral('no') | Literal('1') | Literal('0') | CaselessLiteral('True') | CaselessLiteral('False') ) isc_boolean.setName('<boolean>') # alphanums_series = Group(Word(alphanums) + Word(alphanums)) + semicolon charset_hexnums = '0123456789ABCDEFabcdef'