]> git.ipfire.org Git - thirdparty/knot-resolver.git/commit
converted constant tables, support kres.type.TYPE1234
authorMarek Vavruša <mvavrusa@cloudflare.com>
Thu, 23 Nov 2017 07:50:58 +0000 (23:50 -0800)
committerMarek Vavruša <mvavrusa@cloudflare.com>
Fri, 24 Nov 2017 03:30:29 +0000 (19:30 -0800)
commit0ec11416f80a16ad15fb5541b8d26aa66de51547
tree7b5e622ed7cc059532f11dec2e2809cbdaadf58d
parent1ea9ebce2c6638f3545a67ca176fe89212846319
converted constant tables, support kres.type.TYPE1234

The difficulty with using structs as constant tables is that access
to non-existent fields throws an error. This is difficult to handle
without wrapping every access in a pcall, for example in predict module:

```
error: /usr/local/lib/kdns_modules/predict.lua:34: 'struct rr_type' has no member named 'TYPE65535'
```

So I converted the constant tables into regular Lua tables,
and added a metatable for RR types to allow looking up unnamed types,
in the TYPE%d format. Looking up non-existent fields will now
return nil instead of throwing an error.
daemon/lua/kres.lua.in