开发者

Writing PowerDNS back-end in Lua

I just cannot get开发者_运维百科 this to work. The script answers correctly, and PowerDNS sees it as working, but then the process never gets beyond an acknowledgement of its readiness.

The PowerDNS server gets stuck in read(), and all network connections on port 53 are ignored totally. The server starts a pdns_server process as well as the script itself, and nothing happens. Logging at level 9 is totally and utterly worthless: nothing happens. Ditto for "pdns monitor" except that the stderr output from the script can be seen.

I've put the script here. This is so frustrating... what am I missing? Is it the io.lines() call? Is it because the input is buffered?

Update: I'm using the documentation to create this. I've also looked at other languages (I know a few) - such as v6rev (though I don't know Python) and this example of a backend in Java.

Update 2 I better mention that this is combined with a gmysql backend as well; PowerDNS does allow multiple backends, though I don't know the specifics of it. I did switch the order of the backends in the configuration file, with no changes seen afterwards. Also, MySQL queries do work. Without the pipe backend, the MySQL backend handles things just fine.


No one has any tips, so... this is what I found out. It is indeed related to buffering - or at least, that's what it looks like. The code originally had lines like this:

print("OK\tPowerDNS backend ok")

These lines were where the problem was; replacing them with this sequence worked:

print("OK\tPowerDNS backend ok")
io.flush()

However - replacing them with the following sequence did not work:

io.write("OK\tPowerDNS backend ok")
io.flush()

Presumably this is because of some difference between print() and io.write(). Looking for details on Lua unbuffered I/O turned up nothing. It may be that I should use io.stdout.write() instead of io.write().

By accident, I ran across this posting to the Lua-Users mailing list which mentions the setvbuf function. However, the setvbuf function appears to be new as of Lua 5.1, so it is not available in Lua 5.0.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜