Git Product home page Git Product logo

dnssd's Introduction

USE THIS INSTEAD: https://github.com/tenderlove/zeroconf

= dnssd

home :: https://github.com/tenderlove/dnssd
bugs :: https://github.com/tenderlove/dnssd/issues

* https://developer.apple.com/library/archive/documentation/Networking/Conceptual/dns_discovery_api/Introduction.html

== DESCRIPTION:

DNS Service Discovery (aka Bonjour, MDNS) API for Ruby.  Implements browsing,
resolving, registration and domain enumeration.  Supports avahi's DNSSD
compatibility layer for avahi 0.6.25 or newer.

== FEATURES/PROBLEMS:

* Needs more pie.
* Not all of the DNSSD API is implemented
* Sometimes tests fail

== SYNOPSIS:

See the sample directory (Hint: <tt>gem contents --prefix dnssd</tt>)

Registering a service:

  http = TCPServer.new nil, 80
  
  DNSSD.announce http, 'my awesome HTTP server'

Browsing services:

  require 'dnssd'
  
  DNSSD.browse '_http._tcp.' do |reply|
    p reply
  end

== REQUIREMENTS:

* OS X
* The dns-sd library on other operating systems
* avahi 0.6.25+ (plus libavahi-compat-libdnssd-dev on debian)

== INSTALL:

  sudo gem install dnssd

If you have dnssd installed in a non-standard location you can use the build
options --with-dnssd-dir and --with-dnssd-lib:

  sudo gem install dnssd -- \
    --with-dnssd-dir=/path/to/dnssd \
    --with-dnssd-lib=/path/to/lib/dnssd

Using the default Bonjour SDK install for Windows, the command to build
the Ruby dnssd extension will look like this:

  # Windows 2000 or Windows XP
  sudo gem install dnssd -- \
     --with-dnssd-dir=c:/progra~1/bonjou~1 \
     --with-dnssd-lib=c:/progra~1/bonjou~1/lib/win32
  
  # Windows Vista and later
  sudo gem install dnssd -- \
     --with-dnssd-dir=c:/progra~2/bonjou~1 \
     --with-dnssd-lib=c:/progra~2/bonjou~1/lib/win32

== LICENSE:

Copyright (c) 2004 Chad Fowler, Charles Mills, Rich Kilmer

Copyright (c) 2009 Phil Hagelberg, Aaron Patterson, Eric Hodel

Licensed under the ruby license

dnssd's People

Contributors

corecode avatar drbrain avatar jornane avatar searls avatar sodabrew avatar tenderlove avatar tomstuart avatar toolmantim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dnssd's Issues

getaddrinfo issues

Hello!
I'm trying to get addresses using such code:

DNSSD::Service.getaddrinfo(reply.target, 1) { |addrinfo| ... } 

and the program never reach the 'do end' block. It worked fine in 2.x branch. But 2.x is incompatible with 3.x so i removed '.new' part. What am i doing wrong now? :)
Thanks!

Connecting to browse result with name containing "." yields -65540

If the name of the found reply contains ".", reply.name returns the name up to the dot and no more. Trying to resolve or connect to it fails with -65540.

Not sure if I'm doing something wrong having "." in my name or if it's a bug in dnssd...

puts reply.name, reply.type, reply.domain

yields:

12
23.12
123.office.spotify.net: Spotify._nuremote._tcp.local.

(pretend that 12.23.12.123 is a valid IP)

Installation issues with ruby 2.7.1, OS X Big Sur & xcode 13.1

Description

I'm having issues installing this gem on Big Sur under ruby 2.7.1. It seems by this traceback that it can't find the file /usr/lib/libmdns.dylib which does indeed not exist. I cannot find any brew-package that would supplement this dependency for me.

Versions

xcode-select version 2384.
xcode version 13.1
xcode command line tools version: 13A1030d
Mac os Version: macOS Big Sur 11.6 (20G165)
Mac arch: Intel
Ruby v: 2.7.1
Bundler v: 2.1.4

Edited — Reproduced on

Mac arch: Intel
ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-darwin19]
Bundler version 1.17.2
xcode-select version 2384
macOS Big Sur 11.6

Steps to reproduce

  rails new experiment
  cd experiment
  bundle exec rails serve # this works
  bundle add dnssd
  bundle exec rails serve # this crashes with traceback

I've reproduced this on two separate macbook pro's. Both Intel, not sure that the exact versions are the same on both.

Example repo:
https://github.com/StefanWallin/dnssd-install-issuse

Traceback

Traceback (most recent call last):
	43: from bin/rails:4:in `<main>'
	42: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
	41: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
	40: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
	39: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
	38: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
	37: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/commands.rb:18:in `<main>'
	36: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/command.rb:50:in `invoke'
	35: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/command/base.rb:69:in `perform'
	34: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
	33: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
	32: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
	31: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/commands/server/server_command.rb:135:in `perform'
	30: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/commands/server/server_command.rb:135:in `tap'
	29: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/railties-6.1.3/lib/rails/commands/server/server_command.rb:138:in `block in perform'
	28: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:332:in `require'
	27: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:299:in `load_dependency'
	26: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:332:in `block in require'
	25: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
	24: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
	23: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
	22: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
	21: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
	20: from /Users/username/gitstuff/experiment/config/application.rb:7:in `<main>'
	19: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/bundler.rb:174:in `require'
	18: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/bundler/runtime.rb:58:in `require'
	17: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/bundler/runtime.rb:58:in `each'
	16: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/bundler/runtime.rb:69:in `block in require'
	15: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/bundler/runtime.rb:69:in `each'
	14: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/bundler/runtime.rb:74:in `block (2 levels) in require'
	13: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
	12: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
	11: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
	10: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
	 9: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
	 8: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/dnssd-3.0.1/lib/dnssd.rb:167:in `<main>'
	 7: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:332:in `require'
	 6: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:299:in `load_dependency'
	 5: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.1.3/lib/active_support/dependencies.rb:332:in `block in require'
	 4: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
	 3: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
	 2: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
	 1: from /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
/Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/bootsnap-1.7.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': dlopen(/Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/dnssd-3.0.1/lib/dnssd/dnssd.bundle, 9): Library not loaded: /usr/lib/libmdns.dylib (LoadError)
  Referenced from: /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/dnssd-3.0.1/lib/dnssd/dnssd.bundle
  Reason: image not found - /Users/username/.asdf/installs/ruby/2.7.1/lib/ruby/gems/2.7.0/gems/dnssd-3.0.1/lib/dnssd/dnssd.bundle

DNSSD::Service#stop does not work on ruby 1.9

You can not stop stop browsing on ruby 1.9

require "dnssd"
Thread.abort_on_exception = true

replies = []
dns = DNSSD.browse("_http._tcp") do |reply|
  replies << reply
end

sleep 5

dns.stop

#we never reach this line
puts replies.inspect

From linux, DNSSD.register 'block' example fails

running the DNSSD.register 'block' example fails on linux with

--(jadams@aye-seven)-(8/pts/13)-(1711/04-Jan-13)--
--($:~/ruby/dnssd)(master)ruby-1.9.3-p327@openplay--
$ ruby sample/register.rb
Registering some blackjack services
(run sample/browse.rb or sample/resolve.rb)

registered blockless (no callback)
*** WARNING *** 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/avahi-compat?s=libdns_sd&e=ruby&f=DNSServiceAddRecord
/home/jadams/.rvm/gems/ruby-1.9.3-p327@openplay/gems/dnssd-2.0/lib/dnssd/service.rb:39:in _add_record': DNSSD operation failed with error code: -65544 (DNSSD::UnsupportedError) from /home/jadams/.rvm/gems/ruby-1.9.3-p327@openplay/gems/dnssd-2.0/lib/dnssd/service.rb:39:inadd_record'
from sample/register.rb:26:in block in <main>' from /home/jadams/.rvm/gems/ruby-1.9.3-p327@openplay/gems/dnssd-2.0/lib/dnssd/service.rb:164:inprocess'
from /home/jadams/.rvm/gems/ruby-1.9.3-p327@openplay/gems/dnssd-2.0/lib/dnssd/service.rb:226:in register' from sample/register.rb:24:in

'

Removing the call to DNSSD.register 'block' resolves this issue. Registering the service at the end of the file works fine, as well as the registration with no callback.

This isn't a problem for my use case (literally just trying to advertise a service's availability for now), but figured I'd report it anyway.

Again, I can help with whatever you need to help get more info on this if it's worthwhile to you. Otherwise, this is just another data point for yon internet wanderers.

Can't build on Windows (checking for htons in arpa/inet.h... no)

Here's the output when I try to install this gem:

C:\Users\Charles>gem install dnssd -- --with-dnssd-dir=c:/progra~1/bonjou~1 --with-dnssd-lib=c:/progra~1/bonjou~1/lib/win32
Building native extensions.  This could take a while...
ERROR:  Error installing dnssd:
        ERROR: Failed to build gem native extension.

C:/Ruby19/bin/ruby.exe extconf.rb --with-dnssd-dir=c:/progra~1/bonjou~1 --with-dnssd-lib=c:/progra~1/bonjou~1/lib/win32
checking for dns_sd.h... yes
checking for main() in -ldnssd... yes
checking for htons in arpa/inet.h... no
checking for htons() in arpa/inet.h... no
couldn't find htons
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers.  Check the mkmf.log file for more details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --without-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/Ruby19/bin/ruby
        --with-warnings
        --without-warnings
        --with-dnssd-dir
        --with-dnssd-include
        --without-dnssd-include=${dnssd-dir}/include
        --with-dnssd-lib=${dnssd-dir}/lib
        --with-dnssdlib
        --without-dnssdlib


Gem files will remain installed in C:/Ruby19/lib/ruby/gems/1.9.1/gems/dnssd-1.3.1 for inspection.
Results logged to C:/Ruby19/lib/ruby/gems/1.9.1/gems/dnssd-1.3.1/ext/dnssd/gem_make.out

Does anyone know how I can resolve this? Shouldn't it be looking in winsock.h, as opposed to arpa/inet.h?

Thanks,

-Charles

Compilation failure on Solaris

Trying to build on Solaris, it fails with the following message:

checking for if_indextoname() in sys/types.h,sys/socket.h,net/if.h... no
unable to find if_indextoname or if_nametoindex
*** extconf.rb failed ***

I've checked the libraries and headers are in place:

[kusor@b117vm ~]$ cat /usr/include/net/if.h |grep if_indextoname
extern  char                    *if_indextoname(unsigned, char *);
[kusor@b117vm ~]$ cat /usr/include/net/if.h |grep if_nametoindex
extern  unsigned                if_nametoindex(const char *);

[kusor@b117vm ~]$ uname -a
SunOS b117vm 5.11 snv_117 i86pc i386 i86pc

Adding the following to extconf.rb fixes the issue:

if PLATFORM =~ /solaris/
  $CFLAGS << ' -lxnet'
end

Here is the correct output:

[kusor@b117vm /opt/local/lib/ruby/gems/1.8/gems/dnssd-1.3.1/ext/dnssd]$ sudo ruby18 extconf.rb
checking for dns_sd.h... yes
checking for main() in -ldnssd... no
checking for main() in -ldns_sd... yes
checking for htons in arpa/inet.h... no
checking for htons() in arpa/inet.h... yes
checking for ntohs in arpa/inet.h... no
checking for ntohs() in arpa/inet.h... yes
checking for iphlpapi.h... no
checking for if_indextoname() in sys/types.h,sys/socket.h,net/if.h... yes
checking for if_nametoindex() in sys/types.h,sys/socket.h,net/if.h... yes
checking for getservbyport() in netdb.h... yes
checking for struct sockaddr_in in netinet/in.h... yes
checking for struct sockaddr_in.sin_len in netinet/in.h... no

checking for missing avahi features
checking for DNSServiceGetProperty() in dns_sd.h... no
checking for DNSServiceGetAddrInfo() in dns_sd.h... no
checking for kDNSServiceFlagsForce() in dns_sd.h... no
checking for kDNSServiceFlagsNonBrowsable() in dns_sd.h... no
checking for kDNSServiceFlagsReturnIntermediates() in dns_sd.h... no
checking for kDNSServiceFlagsShareConnection() in dns_sd.h... no
checking for kDNSServiceErr_BadSig() in dns_sd.h... no
creating Makefile

compilation failure on FreeBSD

Hi there,

I'm trying to install this gem without success, any help would be grateful =)

The environement is set like this :

# ruby --version
ruby 1.8.7 (2012-02-08 patchlevel 358) [i386-freebsd9]

#gem --version
1.8.11

# pkg_info -L mDNS\* | grep dns_sd
/usr/local/include/dns_sd.h
/usr/local/lib/libdns_sd.so
/usr/local/lib/libdns_sd.so.1

First i tried a basic :

# gem install dnssd

That fall like :

have_header: checking for dns_sd.h... -------------------- no

"cpp -I. -I/usr/local/lib/ruby/1.8/i386-freebsd9 -I. -I/usr/include   -I/usr/include  -I/usr/include -O2 -pipe -fno-strict-aliasing  -fPIC    conftest.c -o conftest.i"
conftest.c:1:20: error: dns_sd.h: No such file or directory
checked program was:
/* begin */
1: #include <dns_sd.h>
/* end */

Then I tried to install the gem like this :

# gem install dnssd -- --with-dnssd-lib=/usr/local/lib --with-dnssd-dir=/usr/local/

The full output is here : http://pastebin.com/7vrK2qsR

Then basicaly falling like this :

cc -I. -I. -I/usr/local/lib/ruby/1.8/i386-freebsd9 -I. -DHAVE_DNS_SD_H -DHAVE_IF_INDEXTONAME -DHAVE_IF_NAMETOINDEX -DHAVE_GETSERVBYPORT -DHAVE_TYPE_STRUCT_SOCKADDR_IN -DHAVE_ST_SIN_LEN -DHAVE_DNSSERVICEGETPROPERTY -DHAVE_DNSSERVICEGETADDRINFO -DHAVE_KDNSSERVICEFLAGSFORCE -DHAVE_KDNSSERVICEFLAGSNONBROWSABLE -DHAVE_KDNSSERVICEFLAGSRETURNINTERMEDIATES -DHAVE_KDNSSERVICEFLAGSSHARECONNECTION -DHAVE_KDNSSERVICEERR_BADSIG -I/usr/local//include -I/usr/include   -I/usr/include -fPIC -I/usr/include -O2 -pipe -fno-strict-aliasing  -fPIC  -c service.c
service.c: In function 'dnssd_service_getaddrinfo_reply':
service.c:406: error: dereferencing pointer to incomplete type
*** Error code 1

Can't require rails after browse

I just upgraded my library from dnssd 2 to 3 and now it's choking when I try to require rails after a dnssd lookup.

ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]

Console 1

>> require 'dnssd'
=> true
>> DNSSD::VERSION
=> "3.0.1"
>> DNSSD.register "foo", "_foo._tcp", nil, 12345
=> #<DNSSD::Service::Register:0x007faed250a040 @replies=[], @continue=true, @thread=nil, @lock=#<Mutex:0x007faed2509ff0>, @records=[]>

Console 2

>> require 'dnssd'
=> true
>> DNSSD::VERSION
=> "3.0.1"
>> DNSSD.browse!("_foo._tcp") {|x| p x; break}
#<DNSSD::Reply::Browse:0x3fc4355f4694 "foo._foo._tcp.local." interface: en11 flags: #<DNSSD::Flags add, more_coming>>
=> nil
>> require "/Users/user/src/web/tyn/config/application"
Errno::EBADF: Bad file descriptor @ fptr_finalize - /Users/user/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/source/local.rb
	from /Users/user/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /Users/user/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /Users/user/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/source.rb:231:in `<top (required)>'
	from /Users/user/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /Users/user/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /Users/user/.gem/ruby/2.2.2/gems/bundler-1.13.6/lib/bundler/rubygems_ext.rb:15:in `<top (required)>'
	from /Users/user/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /Users/user/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /Users/user/.gem/ruby/2.2.2/gems/bundler-1.13.6/lib/bundler.rb:10:in `<top (required)>'
	from /Users/user/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /Users/user/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /Users/user/.gem/ruby/2.2.2/gems/bundler-1.13.6/lib/bundler/setup.rb:6:in `<top (required)>'
	from /Users/user/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `require'
	from /Users/user/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:128:in `rescue in require'
	from /Users/user/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:39:in `require'
	from /Users/user/src/web/tyn/config/boot.rb:6:in `<top (required)>'
	from /Users/user/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /Users/user/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /Users/user/src/web/tyn/config/application.rb:1:in `<top (required)>'
	from /Users/user/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /Users/user/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from (irb):4

ruby 1.9 compatibility

I can install the gem on Ruby 1.9, but the current Version (1.3.1) has problems with it.
The main issue seems to be:
NoMethodError: undefined method zero?' for "\f":String dnssd/lib/dnssd/text_record.rb:37:indecode'

I haven't got around to fix it.
Here's my output of "rake test --trace"
http://pastie.org/746584
Running latest ruby 1.9.2dev (2009-12-16 trunk 26114) [i386-darwin9.8.0]

Unknown error during service discovery

This may be a bug in Avahi's libdnssd compatibility wrapper, though the avahi-browse utility is able to browse and resolve services without issue.

When a service on the network has a description ending with a period, service resolution fails with the following error:

DNSSD Error: DNSSD::UnknownError - DNSSD operation failed with unrecognized error code: -65537:
 /var/lib/gems/1.9.1/gems/dnssd-2.0/lib/dnssd/service.rb:163:in `_process'
 /var/lib/gems/1.9.1/gems/dnssd-2.0/lib/dnssd/service.rb:163:in `process'
 /var/lib/gems/1.9.1/gems/dnssd-2.0/lib/dnssd/service.rb:257:in `resolve'
 my_code.rb:137:in `block (2 levels) in start_network_browser'
 /var/lib/gems/1.9.1/gems/dnssd-2.0/lib/dnssd/service.rb:164:in `process'
 /var/lib/gems/1.9.1/gems/dnssd-2.0/lib/dnssd/service.rb:66:in `browse'
 /var/lib/gems/1.9.1/gems/dnssd-2.0/lib/dnssd.rb:178:in `run'
 /var/lib/gems/1.9.1/gems/dnssd-2.0/lib/dnssd.rb:86:in `browse!'
 my_code.rb:130:in `block in start_network_browser'

It appears the error is generated by DNSServiceProcessResult() on line 227 of ext/service.c: https://github.com/tenderlove/dnssd/blob/master/ext/dnssd/service.c#L227

I noticed the issue when my discovery code started crashing whenever a particular computer was turned on. That computer had a service with the following Avahi service descriptor: Removing the period from the field works around the issue, but is not a solution.

<service-group>
    <name replace-wildcards="yes">HTTP Server on %h.</name>
    <service>
        <type>_http._tcp</type>
        <port>80</port>
    </service>
</service-group>

If this is a bug in Avahi, please feel free to pass this bug report to them. I'm running Ubuntu 11.04, Avahi compatibility layer version 0.6.30-0ubuntu2, ruby 1.9.2p0, dnssd gem 2.0.

DNSSD register weird behavior when used with Eventmachine

Hi,
I'm getting some really odd behavior when using DNSSD with Eventmachine. I'm using DNSSD to register my ruby program's HTTP interface. Depending on whether I've commented out various innocuous lines of code, reorder some lines, or slowed down the amount of data Eventmachine is processing (from $stdin in my case) then the register either works, doesn't work at all, or works briefly before removing itself (even through the ruby process is still running fine).

I've been able to whittle the problem down to the following gist that reproduces the problem. Although I haven't been able to try this on any other machine yet.
http://gist.github.com/260730

My details:
Ruby 1.8.7
Mac OS X 10.6.2
Eventmachine 0.12.10
dnssd 1.3.1

Any help much appreciated.

Samples do not work in version 3.0.1

$ ruby ~/.gem/ruby/2.0.0/gems/dnssd-3.0.1/sample/browse.rb 
/home/.../.gem/ruby/2.0.0/gems/dnssd-3.0.1/sample/browse.rb:7:in `<main>': private method `new' called for DNSSD::Service:Class (NoMethodError)

Running on Debian

Hi,
It worth noticing ine the readme that in order to work in debian the gem need the libavahi-compat-libdnssd-dev package

Incompatible with OS X 10.10 Yosemite

Couldn't get this sucker to install on my Maverick's machine. When running rake compile, first I get can't find header dns_sd.h (which is present, in /usr/include):

~/code/dnssd#master$ rake compile
Defaulting gemspec to MIT license.
Call license in hoe spec to change.
mkdir -p tmp/x86_64-darwin13.0/dnssd/2.1.2
cd tmp/x86_64-darwin13.0/dnssd/2.1.2
/usr/local/var/rbenv/versions/2.1.2-github1/bin/ruby -I. ../../../../ext/dnssd/extconf.rb
checking for dns_sd.h... no
unable to find dnssd header
*** ../../../../ext/dnssd/extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=../../../../ext/dnssd
    --curdir
    --ruby=/usr/local/var/rbenv/versions/2.1.2-github1/bin/ruby
    --with-warnings
    --without-warnings
    --with-dnssd-dir
    --without-dnssd-dir
    --with-dnssd-include
    --without-dnssd-include=${dnssd-dir}/include
    --with-dnssd-lib
    --without-dnssd-lib=${dnssd-dir}/lib
rake aborted!
Command failed with status (1): [/usr/local/var/rbenv/versions/2.1.2-github...]

Tasks: TOP => compile => compile:x86_64-darwin13.0 => compile:dnssd:x86_64-darwin13.0 => copy:dnssd:x86_64-darwin13.0:2.1.2 => tmp/x86_64-darwin13.0/dnssd/2.1.2/dnssd.bundle => tmp/x86_64-darwin13.0/dnssd/2.1.2/Makefile
(See full trace by running task with --trace)

If I remove that header check, I get:

~/code/dnssd#master$ rake compile
Defaulting gemspec to MIT license.
Call license in hoe spec to change.
cd tmp/x86_64-darwin13.0/dnssd/2.1.2
/usr/local/var/rbenv/versions/2.1.2-github1/bin/ruby -I. ../../../../ext/dnssd/extconf.rb
checking for main() in -ldnssd... no
checking for main() in -ldns_sd... no
checking for main() in -lmdns... no
checking for main() in -lSystem... yes
checking for htons in arpa/inet.h... yes
checking for ntohs in arpa/inet.h... yes
checking for iphlpapi.h... no
checking for if_indextoname() in sys/types.h,sys/socket.h,net/if.h... yes
checking for if_nametoindex() in sys/types.h,sys/socket.h,net/if.h... yes
checking for getservbyport() in netdb.h... yes
checking for rb_thread_fd_select() in ruby/intern.h... yes
checking for struct sockaddr_in in netinet/in.h... yes
checking for struct sockaddr_in.sin_len in netinet/in.h... yes

checking for missing avahi features
checking for DNSServiceGetProperty() in dns_sd.h... no
checking for DNSServiceGetAddrInfo() in dns_sd.h... no
checking for kDNSServiceFlagsForce() in dns_sd.h... no
checking for kDNSServiceFlagsNonBrowsable() in dns_sd.h... no
checking for kDNSServiceFlagsReturnIntermediates() in dns_sd.h... no
checking for kDNSServiceFlagsShareConnection() in dns_sd.h... no
checking for kDNSServiceErr_BadSig() in dns_sd.h... no

checking for ruby features
checking for ruby/encoding.h... yes

creating Makefile
cd -
cd tmp/x86_64-darwin13.0/dnssd/2.1.2
make
compiling ../../../../ext/dnssd/dnssd.c
couldn't understand kern.osversion `14.0.0'
In file included from /usr/include/os/object.h:27,
                 from /usr/include/dispatch/dispatch.h:48,
                 from /usr/include/dns_sd.h:129,
                 from ../../../../ext/dnssd/dnssd.h:6,
                 from ../../../../ext/dnssd/dnssd.c:1:
/usr/include/os/base.h:113:20: error: missing binary operator before token "("
/usr/include/os/base.h:119:54: error: missing binary operator before token "("
In file included from /usr/include/dispatch/dispatch.h:51,
                 from /usr/include/dns_sd.h:129,
                 from ../../../../ext/dnssd/dnssd.h:6,
                 from ../../../../ext/dnssd/dnssd.c:1:
/usr/include/dispatch/object.h:325:20: error: missing binary operator before token "("
/usr/include/dispatch/object.h:363:20: error: missing binary operator before token "("
/usr/include/dispatch/object.h:391:20: error: missing binary operator before token "("
/usr/include/dispatch/object.h:423:20: error: missing binary operator before token "("
make: *** [dnssd.o] Error 1
rake aborted!
Command failed with status (2): [make...]

Tasks: TOP => compile => compile:x86_64-darwin13.0 => compile:dnssd:x86_64-darwin13.0 => copy:dnssd:x86_64-darwin13.0:2.1.2 => tmp/x86_64-darwin13.0/dnssd/2.1.2/dnssd.bundle
(See full trace by running task with --trace)

Entirely borked, unfortunately. Not sure how to go about fixing here.

Compilation failure on Void Linux

In Void Linux, the dns_sd.h header is installed to /usr/include/avahi-compat-libdns_sd/dns_sd.h, but the gem assumes that the header is installed to <something>/include/dns_sd.h. Therefore, sudo gem install dnssd -- --with-dnssd-dir=/usr/include/avahi-compat-libdns_sd/ fails, and the mkmf.log file shown the compiler trying to include /usr/include/avahi-compat-libdns_sd//include.

How do I replicate the result of this dns-sd command?

dns-sd -P my_new_app _http local 80 my_new_app.local <my.dev.machine.ip>

You know, for the developers!
The commands is designed to register a proxy service, it does so by adding to the service this record in the mDNS soup:
my_new_app.local. 10 IN A <my.dev.machine.ip>

Let's assume you have the usual passenger setup with virtual hosts on your dev machine; this means that from the local network other browsers (like the one in your phone) can hit your dev app.
I just think that the A record is a bit brittle and not very mDSN like. I'm trying to figure out how to use this gem to do the same thing and eventually replace the A record with one or two CNAME.

The goal is to make something like:
my_new_app.local. 10 IN CNAME my_dev_book.local.

mobile.my_new_app.local. 10 IN CNAME my_dev_book.local.

My feeling is that a snippet that can achieve this inside this gem's example folder would prove really useful to many.

Using dnssd gem from within Docker

I was trying to use this gem on Debian inside of a Docker container running on macOS and kept running into this error:

DNSSD operation failed with unrecognized error code: -65537 (DNSSD::UnknownError)

After getting the gem native extensions to build (which required the libavahi-compat-libdnssd-dev package to be installed) I was perplexed as to why this was still failing.

Turns out that dnssd relies on dbus which Docker does not enable by default. I found some resources that suggested mounting some volumes into the container to expose the host machine's dbus to the docker container, but macOS doesn't have dbus.

Ultimately I was able to get this to work by running the docker container on a linux host and using the options -v /var/run/dbus:/var/run/dbus -v /var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket on my docker run command to connect the host machine's dbus to the container.

No action needed, but might be something to add to the README. Also just want to put this here in case someone else is having the same issue. This was pretty difficult to debug.

XCode 5.1 causes dnssd to fail to install

em::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for dns_sd.h... yes
checking for main() in -ldnssd... no
checking for main() in -ldns_sd... no
checking for main() in -lmdns... no
checking for main() in -lSystem... yes
checking for htons in arpa/inet.h... yes
checking for ntohs in arpa/inet.h... yes
checking for iphlpapi.h... no
checking for if_indextoname() in sys/types.h,sys/socket.h,net/if.h... yes
checking for if_nametoindex() in sys/types.h,sys/socket.h,net/if.h... yes
checking for getservbyport() in netdb.h... yes
checking for struct sockaddr_in in netinet/in.h... yes
checking for struct sockaddr_in.sin_len in netinet/in.h... yes

checking for missing avahi features
checking for DNSServiceGetProperty() in dns_sd.h... yes
checking for DNSServiceGetAddrInfo() in dns_sd.h... yes
checking for kDNSServiceFlagsForce() in dns_sd.h... yes
checking for kDNSServiceFlagsNonBrowsable() in dns_sd.h... yes
checking for kDNSServiceFlagsReturnIntermediates() in dns_sd.h... yes
checking for kDNSServiceFlagsShareConnection() in dns_sd.h... yes
checking for kDNSServiceErr_BadSig() in dns_sd.h... yes

checking for ruby features
checking for ruby/encoding.h... yes

creating Makefile

make "DESTDIR="
compiling dnssd.c
compiling errors.c
compiling flags.c
compiling record.c
compiling service.c
linking shared-object dnssd/dnssd.bundle
clang: error: unknown argument: '-multiply_definedsuppress' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
make: *** [dnssd.bundle] Error 1

From linux, browsing doesn't find any services

Running the samples on a linux box running ubuntu 12.10 (64 bit), I can register the service but the browse.rb script doesn't list it successfully. This works fine on a Mac. Tried it on two different ubuntu machines (both running 12.10) with the same failure mode. It just never lists any services as found.

I can give any more details needed. Not sure if this is a bug with libavahi's compat lib or what. Browsing from avahi-discover works fine.

Resolve issues while scanning for printer

I scan with the following code example for printers. After about 40 rounds in the for loop the following error appears:

compat.c: write() failed: Bad file descriptor
ruby: compat.c:425: sdref_free: Assertion `__ret == 0' failed.
compat.c: write() failed: Broken pipe
compat.c: read() failed: EOF

Any ideas how to fix this? Looks like it is crashing in the avahi-lib in this line:

ASSERT_SUCCESS(write_command(sdref->main_fd, COMMAND_QUIT));

require 'dnssd'

service =  '_http._tcp' #network printer
resolved = []

i = 1
while i <=100
 DNSSD.browse service do |b|
   DNSSD.resolve(b) do |r|
     resolved << r
   end
 end

 sleep 0.5
 puts "***** Round #{i} *****"
 resolved.each do |r|
   puts r.fullname
 end
 i+=1
 resolved = []
end

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.