| 275 | self.txn.add(name, ttl, rd) |
| 276 | |
| 277 | def _parse_modify(self, side: str) -> Tuple[str, str, int, int, str]: |
| 278 | # Here we catch everything in '{' '}' in a group so we can replace it |
| 279 | # with ''. |
| 280 | is_generate1 = re.compile(r"^.*\$({(\+|-?)(\d+),(\d+),(.)}).*$") |
| 281 | is_generate2 = re.compile(r"^.*\$({(\+|-?)(\d+)}).*$") |
| 282 | is_generate3 = re.compile(r"^.*\$({(\+|-?)(\d+),(\d+)}).*$") |
| 283 | # Sometimes there are modifiers in the hostname. These come after |
| 284 | # the dollar sign. They are in the form: ${offset[,width[,base]]}. |
| 285 | # Make names |
| 286 | mod = "" |
| 287 | sign = "+" |
| 288 | offset = "0" |
| 289 | width = "0" |
| 290 | base = "d" |
| 291 | g1 = is_generate1.match(side) |
| 292 | if g1: |
| 293 | mod, sign, offset, width, base = g1.groups() |
| 294 | if sign == "": |
| 295 | sign = "+" |
| 296 | else: |
| 297 | g2 = is_generate2.match(side) |
| 298 | if g2: |
| 299 | mod, sign, offset = g2.groups() |
| 300 | if sign == "": |
| 301 | sign = "+" |
| 302 | width = "0" |
| 303 | base = "d" |
| 304 | else: |
| 305 | g3 = is_generate3.match(side) |
| 306 | if g3: |
| 307 | mod, sign, offset, width = g3.groups() |
| 308 | if sign == "": |
| 309 | sign = "+" |
| 310 | base = "d" |
| 311 | |
| 312 | ioffset = int(offset) |
| 313 | iwidth = int(width) |
| 314 | |
| 315 | if sign not in ["+", "-"]: |
| 316 | raise dns.exception.SyntaxError(f"invalid offset sign {sign}") |
| 317 | if base not in ["d", "o", "x", "X", "n", "N"]: |
| 318 | raise dns.exception.SyntaxError(f"invalid type {base}") |
| 319 | |
| 320 | return mod, sign, ioffset, iwidth, base |
| 321 | |
| 322 | def _generate_line(self): |
| 323 | # range lhs [ttl] [class] type rhs [ comment ] |