egberts/bind9_parser

slave zone: masters keyword not recognised

gianks opened this issue · 4 comments

There seem to be no support for the keyword masters in the slave zone definitions.

    return my_clauses.parseString(named_config, parseAll=True)

  File "/usr/lib/python3/dist-packages/pyparsing.py", line 1955, in parseString
    raise exc

  File "/usr/lib/python3/dist-packages/pyparsing.py", line 4065, in parseImpl
    raise ParseSyntaxException._from_exception(pe)

ParseSyntaxException: Expected {W:(ABCD...) | W:(ABCD...) | <master_name>}

named.conf.local not working example:

zone "domain.it" { type slave; masters { 1.1.1.1; }; file "/var/lib/bind/domain.it.hosts"; };

Many fixes.

I got the following examples/patterns/zone-slave-masters-named.conf:

$ cat examples/patterns/zone-slave-masters-named.conf 


zone "example.test" {
    type slave;
    masters { 192.168.1.1; };
};

And using the new dump-named-conf.py:

$ ./dump-named-conf.py examples/patterns/zone-slave-masters-named.conf 

print(result.asDict()):
{'zones': [{'masters_zone': {'zone_master_list': [{'ip4': '192.168.1.1'}]},
            'type': 'slave',
            'zone_name': '"example.test"'}]}
end of result.

Just to be safe, I ensured that parser properly saves all multiple slave zones

$ cat examples/patterns/zone-multiple-slave-masters-named.conf 


zone "example.test" {
    type slave;
    masters { 192.168.1.1; };
};
zone "second-example.test" {
    type slave;
    masters { 172.16.1.1; };
};
zone "third-example" {
    type slave;
    masters { 10.0.0.1; };
};
$ ./dump-named-conf.py examples/patterns/zone-multiple-slave-masters-named.conf 

print(result.asDict()):
{'zones': [{'masters_zone': {'zone_master_list': [{'ip4': '192.168.1.1'}]},
            'type': 'slave',
            'zone_name': '"example.test"'},
           {'masters_zone': {'zone_master_list': [{'ip4': '172.16.1.1'}]},
            'type': 'slave',
            'zone_name': '"second-example.test"'},
           {'masters_zone': {'zone_master_list': [{'ip4': '10.0.0.1'}]},
            'type': 'slave',
            'zone_name': '"third-example"'}]}
end of result.