karlentwistle / ruby_home

Ruby HAP Server - HomeKit support for the Rubyist

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OpenBSD misses dns_sd.h

microspino opened this issue Β· comments

This projects is awesome.
Until now i've used it on an old mac mini.
Now i would like to move everything on my OpenBSD home server.

It misses dns-sd, I'm getting the following error during install:

checking for dns_sd.h... no

I've already searched for an OpenBSD port of FreeBSD's net/avahi-libdns without luck.
Also, on OpenBSD there's not a port of Debian's libavahi-compat-libdnssd-dev

Do you know a workaround for this?

BTW many many thx for putting your efforts in building this thing, i saw your talk from Sheffield Ruby 18 and felt astonished by your hard work!

Thanks for the kind words. I am glad you found and enjoyed the presentation πŸ˜„

I've never ran RubyHome on OpenBSD only on Mac OS X for development and my Raspberry Pi. I'm very interested to hear if it's possible to get it working on OpenBSD.

RubyHome uses the dnssd gem for DNS Service Discovery which @tenderlove maintains at https://github.com/tenderlove/dnssd. There is possibly a similar issue posted in the repository tenderlove/dnssd#9 with a suggested fix that might be of some help.

Please let me know if that's useful / how you get on.

Thanks again! 😸

Nice piece of advice! I've made some progress...Here's what I did:

pkg_add avahi
gem install dnssd -- --with-dnssd-lib=/usr/local/lib --with-dnssd-include=/usr/local/include/avahi-compat-libdns_sd/

...And then πŸŽ‰ πŸ˜„ dnssd smooooothly installed so thx @kalw (aka Regis A. Despres) for the hint.

After that I launched avahi&co.

doas rcctl enable messagebus avahi_daemon 
doas rcctl start messagebus avahi_daemon

Then created and run a switch.rb

Everything went well until the last paring step i.e. after inserting the code in my iOS Home app.
There I got:

...
The program 'ruby' called 'DNSServiceAddRecord()' which is not supported (or only supported partially) in the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/blog/projects/avahi-compat.html>
2019-09-26 00:56:20 - DNSSD::UnsupportedError - DNSSD operation failed with error code: -65544:
/usr/local/lib/ruby/gems/2.4/gems/dnssd-3.0.1/lib/dnssd/service.rb:45:in `_add_record'
...

Which seems to be related to the use of partially supported call made by dnssd.
The error log has a pointer to some more info located here http://0pointer.de/blog/projects/avahi-compat.html (author of the avahi port)

I will dig more into it and let you know.

@microspino glad to hear you got a bit further!

The new bug you've encountered is actually also present when running on Linux. To circumvent the issue, for now, I ended up added a guard clause to the DNS::Service#update method call. I also found this inside the test suite of dnssd.

This means RubyHome is still useable on Linux but the services that are advertised via DNS Service Discovery can get out of date until the program is restarted. This doesn't appear to effect anything in a massive way and I've been using RubyHome successfully on my Raspberry Pi for months.

The quick fix would be for you to run:

irb(main):001:0> require 'dnssd' => true
irb(main):002:0> RbConfig::CONFIG['target_os'] => "darwin18"

Then we could update the code to also skip your OpenBSD target_os.

The longer term fix would be (I guess) updating https://github.com/tenderlove/dnssd to make it work without DNSServiceAddRecord on Linux and OpenBSD.

πŸŽ‰ πŸŽ‰ πŸŽ‰
I've modified my ruby_home gem ...ruby_home-0.2.2/lib/ruby_home/dns/service.rb with this on line#9:

return if RbConfig::CONFIG['target_os'] =~ /linux|openbsd/

RbConfig::CONFIG['target_os'] was "openbsd6.4" on my home server.

It works like a charm.
πŸ™‡

I can control my Kitchen Light with Siri now and 🀣 since I'm sure everybody in the world was waiting for this 🀣 we can safely close the issue i guess.