[Dnsmasq-discuss] control socket

Simon Kelley simon at thekelleys.org.uk
Sun Nov 27 12:01:03 GMT 2005


iler_ml at fastmail.fm wrote:
> Hello,
> 
> I am about to add the 'control-socket' to dnsmasq, in 
> order to obtain the cache status. Of course other commands
> can be added later, but my primary goal is gettting
> the cache status.
> 
> Is anything like control socket already in the works ?

Look at the dbus code, in 2.23 and 2.24. This isn't included in the 
default build, but works fine if you change

#undef HAVE_DBUS

in src/config.h to

#define HAVE_DBUS

It only depends in libdbus-1 (a fairly new version) - dbus is designed 
to be usable without a load of other dependencies, unlike most of the 
freedesktop.org stuff.

The code currently implements methods to set the upstream nameservers, 
clear the cache and reload /etc/hosts, and one to report the version.
These are documented in the file "DBus-interface"
Adding more methods would be easy; just add more cases to the 
message_handler() function in src/dbus.c. Passing data out of dnsmasq is 
as easy as pasing it in.

These methods are invokable by scripts, etc by using the dbus-send 
command, and there are dbus client library bindings for most languages.

I would much rather extend this facility than implement a whole new one. 
If you really need a dedicated dnsmasq-ctl utility, that should be a 
wrapper around dbus-send.


> 
> My goal is just to get cache status from dnsmasq.
> Maybe the simpler solution is to use signal and have
> dnsmasq write output to some file ?
> 
> If you think control socket is useful, then 
> do you have feedback about: 
> - default port; 
> - which option to use to change the port, 
> - whether to use TCP or unix-domain for the socket;
> - name for the dnsmasq-ctl utility 
> - whether to put dnsmasq-ctl utility inside dnsmasq 
> (under some argv option), or as separate executable ?
> 

See above: add methods to the dbus interface, and write dnsmasq-ctl as a 
shell wrapper around dbus-send.


> Yakov Lerner

Cheers,

Simon.




More information about the Dnsmasq-discuss mailing list