toolmantim-zeroconf 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +44 -0
- data/Rakefile +71 -0
- data/lib/dnssd.rb +137 -0
- data/lib/net/dns.rb +49 -0
- data/lib/net/dns/mdns-sd.rb +240 -0
- data/lib/net/dns/mdns.rb +1189 -0
- data/lib/net/dns/resolv-mdns.rb +230 -0
- data/lib/net/dns/resolv-replace.rb +66 -0
- data/lib/net/dns/resolv.rb +2012 -0
- data/lib/net/dns/resolvx.rb +219 -0
- data/lib/zeroconf.rb +15 -0
- data/lib/zeroconf/common.rb +0 -0
- data/lib/zeroconf/ext.rb +7 -0
- data/lib/zeroconf/pure.rb +13 -0
- data/lib/zeroconf/version.rb +3 -0
- data/originals/dnssd-0.6.0/COPYING +56 -0
- data/originals/dnssd-0.6.0/README +50 -0
- data/originals/net-mdns-0.4/COPYING +58 -0
- data/originals/net-mdns-0.4/README +21 -0
- data/originals/net-mdns-0.4/TODO +278 -0
- data/samples/exhttp.rb +50 -0
- data/samples/exhttpv1.rb +29 -0
- data/samples/exwebrick.rb +56 -0
- data/samples/mdns-watch.rb +132 -0
- data/samples/mdns.rb +238 -0
- data/samples/test_dns.rb +128 -0
- data/samples/v1demo.rb +167 -0
- data/samples/v1mdns.rb +111 -0
- data/test/stress/stress_register.rb +48 -0
- data/test/test_browse.rb +24 -0
- data/test/test_highlevel_api.rb +35 -0
- data/test/test_register.rb +32 -0
- data/test/test_resolve.rb +23 -0
- data/test/test_resolve_ichat.rb +56 -0
- data/test/test_textrecord.rb +58 -0
- metadata +93 -0
@@ -0,0 +1,219 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright (C) 2005 Sam Roberts
|
3
|
+
|
4
|
+
This library is free software; you can redistribute it and/or modify it
|
5
|
+
under the same terms as the ruby language itself, see the file COPYING for
|
6
|
+
details.
|
7
|
+
=end
|
8
|
+
|
9
|
+
require 'net/dns/resolv'
|
10
|
+
|
11
|
+
class Resolv
|
12
|
+
class DNS
|
13
|
+
|
14
|
+
class Message
|
15
|
+
# Returns true if message is a query.
|
16
|
+
def query?
|
17
|
+
qr == 0
|
18
|
+
end
|
19
|
+
|
20
|
+
# Returns true if message is a response.
|
21
|
+
def response?
|
22
|
+
!query?
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class Resolv
|
30
|
+
|
31
|
+
# The default resolvers.
|
32
|
+
def self.default_resolvers
|
33
|
+
DefaultResolver.resolvers
|
34
|
+
end
|
35
|
+
|
36
|
+
# The resolvers configured.
|
37
|
+
attr_reader :resolvers
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
class Resolv
|
42
|
+
class DNS
|
43
|
+
|
44
|
+
class Config
|
45
|
+
# A name that has a number of labels greater than than +ndots+ will be looked
|
46
|
+
# up directly. The default value of +ndots+ is 1, so "example" would not be
|
47
|
+
# looked up directly, but "example.com" would be (it has 1 dot). Names ending in a dot, like
|
48
|
+
# "org.", will always be looked up directly, regardless of the setting of ndots.
|
49
|
+
attr_reader :ndots
|
50
|
+
# A series of search suffixes to use if the name being looked up does not end
|
51
|
+
# in a dot.
|
52
|
+
attr_reader :search
|
53
|
+
# The list of nameservers to query, should be dotted IP addresses, not
|
54
|
+
# domain names.
|
55
|
+
attr_reader :nameservers
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class Resolv
|
62
|
+
class DNS
|
63
|
+
module Label
|
64
|
+
|
65
|
+
class Str
|
66
|
+
# Str is-a String, allow it to be compared to one.
|
67
|
+
def to_str
|
68
|
+
return @string
|
69
|
+
end
|
70
|
+
# Case-insensitive comparison.
|
71
|
+
def <=>(s)
|
72
|
+
@downcase <=> s.downcase
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
class Resolv
|
82
|
+
class DNS
|
83
|
+
|
84
|
+
class Name
|
85
|
+
# Append +arg+ to this Name. +arg+ can be a String or a Name.
|
86
|
+
#
|
87
|
+
# Returns +self+.
|
88
|
+
def <<(arg)
|
89
|
+
arg = Name.create(arg)
|
90
|
+
@labels.concat(arg.to_a)
|
91
|
+
@absolute = arg.absolute?
|
92
|
+
self
|
93
|
+
end
|
94
|
+
|
95
|
+
# Returns a new Name formed by concatenating +self+ with +arg+. +arg+ can
|
96
|
+
# be a String or a Name.
|
97
|
+
def +(arg)
|
98
|
+
arg = Name.create(arg)
|
99
|
+
Name.new(@labels + arg.to_a, arg.absolute?)
|
100
|
+
end
|
101
|
+
|
102
|
+
# Set whether +self+ is absolute or not. This is particularly useful when
|
103
|
+
# creating a Name from a String, since the trailing "." is rarely used in
|
104
|
+
# string representations of domain names, even when the domain name is
|
105
|
+
# fully qualified. This makes them very difficult to compare to a Name
|
106
|
+
# returned from the DNS record decoders, because DNS names are always
|
107
|
+
# absolute.
|
108
|
+
def absolute=(abs)
|
109
|
+
@absolute = abs ? true : false
|
110
|
+
end
|
111
|
+
|
112
|
+
# Returns whether two names are equal, disregarding the absolute? property
|
113
|
+
# of the names.
|
114
|
+
#
|
115
|
+
# Note that this differs from #==, which does not consider two names
|
116
|
+
# equal if they differ in absoluteness.
|
117
|
+
def equal?(name)
|
118
|
+
n = Name.create(name)
|
119
|
+
|
120
|
+
@labels == n.to_a
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
class Resolv
|
129
|
+
class DNS
|
130
|
+
|
131
|
+
# DNS names are hierarchical in a similar sense to ruby classes/modules,
|
132
|
+
# and the comparison operators are defined similarly to those of Module. A
|
133
|
+
# name is +<+ another if it is a subdomain of it.
|
134
|
+
# www.example.com < example.com # -> true
|
135
|
+
# example.com < example.com # -> false
|
136
|
+
# example.com <= example.com # -> true
|
137
|
+
# com < example.com # -> false
|
138
|
+
# bar.com < example.com # -> nil
|
139
|
+
class Name
|
140
|
+
def related?(name)
|
141
|
+
n = Name.create(name)
|
142
|
+
|
143
|
+
l = length < n.length ? length : n.length
|
144
|
+
|
145
|
+
@labels[-l, l] == n.to_a[-l, l]
|
146
|
+
end
|
147
|
+
|
148
|
+
def lt?(name)
|
149
|
+
n = Name.create(name)
|
150
|
+
length > n.length && to_a[-n.length, n.length] == n.to_a
|
151
|
+
end
|
152
|
+
|
153
|
+
|
154
|
+
# Summary:
|
155
|
+
# name < other => true, false, or nil
|
156
|
+
#
|
157
|
+
# Returns true if +name+ is a subdomain of +other+. Returns
|
158
|
+
# <code>nil</code> if there's no relationship between the two.
|
159
|
+
def <(name)
|
160
|
+
n = Name.create(name)
|
161
|
+
|
162
|
+
return nil unless self.related?(n)
|
163
|
+
|
164
|
+
lt?(n)
|
165
|
+
end
|
166
|
+
|
167
|
+
# Summary:
|
168
|
+
# name > other => true, false, or nil
|
169
|
+
#
|
170
|
+
# Same as +other < name+, see #<.
|
171
|
+
def >(name)
|
172
|
+
n = Name.create(name)
|
173
|
+
|
174
|
+
n < self
|
175
|
+
end
|
176
|
+
|
177
|
+
# Summary:
|
178
|
+
# name <= other => true, false, or nil
|
179
|
+
#
|
180
|
+
# Returns true if +name+ is a subdomain of +other+ or is the same as
|
181
|
+
# +other+. Returns <code>nil</code> if there's no relationship between
|
182
|
+
# the two.
|
183
|
+
def <=(name)
|
184
|
+
n = Name.create(name)
|
185
|
+
self.equal?(n) || self < n
|
186
|
+
end
|
187
|
+
|
188
|
+
# Summary:
|
189
|
+
# name >= other => true, false, or nil
|
190
|
+
#
|
191
|
+
# Returns true if +name+ is an ancestor of +other+, or the two DNS names
|
192
|
+
# are the same. Returns <code>nil</code> if there's no relationship
|
193
|
+
# between the two.
|
194
|
+
def >=(name)
|
195
|
+
n = Name.create(name)
|
196
|
+
self.equal?(n) || self > n
|
197
|
+
end
|
198
|
+
|
199
|
+
# Summary:
|
200
|
+
# name <=> other => -1, 0, +1, nil
|
201
|
+
#
|
202
|
+
# Returns -1 if +name+ is a subdomain of +other+, 0 if
|
203
|
+
# +name+ is the same as +other+, and +1 if +other+ is a subdomain of
|
204
|
+
# +name+, or nil if +name+ has no relationship with +other+.
|
205
|
+
def <=>(name)
|
206
|
+
n = Name.create(name)
|
207
|
+
|
208
|
+
return nil unless self.related?(n)
|
209
|
+
|
210
|
+
return -1 if self.lt?(n)
|
211
|
+
return +1 if n.lt?(self)
|
212
|
+
# must be #equal?
|
213
|
+
return 0
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
data/lib/zeroconf.rb
ADDED
File without changes
|
data/lib/zeroconf/ext.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'zeroconf/common'
|
2
|
+
|
3
|
+
module Zeroconf
|
4
|
+
module Pure
|
5
|
+
require File.expand_path("#{File.dirname(__FILE__)}/../net/dns/mdns-sd")
|
6
|
+
::DNSSD = Net::DNS::MDNSSD
|
7
|
+
|
8
|
+
unless defined?(DNSSD::TextRecord)
|
9
|
+
class ::DNSSD::TextRecord < Hash
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
|
2
|
+
You can redistribute it and/or modify it under either the terms of the GPL
|
3
|
+
(see the file GPL), or the conditions below:
|
4
|
+
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
6
|
+
software without restriction, provided that you duplicate all of the
|
7
|
+
original copyright notices and associated disclaimers.
|
8
|
+
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
10
|
+
you do at least ONE of the following:
|
11
|
+
|
12
|
+
a) place your modifications in the Public Domain or otherwise
|
13
|
+
make them Freely Available, such as by posting said
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
15
|
+
the author to include your modifications in the software.
|
16
|
+
|
17
|
+
b) use the modified software only within your corporation or
|
18
|
+
organization.
|
19
|
+
|
20
|
+
c) give non-standard binaries non-standard names, with
|
21
|
+
instructions on where to get the original software distribution.
|
22
|
+
|
23
|
+
d) make other distribution arrangements with the author.
|
24
|
+
|
25
|
+
3. You may distribute the software in object code or binary form,
|
26
|
+
provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a) distribute the binaries and library files of the software,
|
29
|
+
together with instructions (in the manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b) accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c) give non-standard binaries non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d) make other distribution arrangements with the author.
|
39
|
+
|
40
|
+
4. You may modify and include the part of the software into any other
|
41
|
+
software (possibly commercial). But some files in the distribution
|
42
|
+
are not written by the author, so that they are not under these terms.
|
43
|
+
|
44
|
+
For the list of those files and their copying conditions, see the
|
45
|
+
file LEGAL.
|
46
|
+
|
47
|
+
5. The scripts and library files supplied as input to or produced as
|
48
|
+
output from the software do not automatically fall under the
|
49
|
+
copyright of the software, but belong to whomever generated them,
|
50
|
+
and may be sold commercially, and may be aggregated with this
|
51
|
+
software.
|
52
|
+
|
53
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
54
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
55
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
56
|
+
PURPOSE.
|
@@ -0,0 +1,50 @@
|
|
1
|
+
Version 0.6.0
|
2
|
+
|
3
|
+
* Added RDoc to the C files
|
4
|
+
* Fixed bug in threading and the service handle
|
5
|
+
* Added DNSSD::Reply superclass for all reply objects
|
6
|
+
* Added fullname singleton method
|
7
|
+
* Added Flag#== method
|
8
|
+
|
9
|
+
Version 0.5.0
|
10
|
+
|
11
|
+
* First release
|
12
|
+
|
13
|
+
Background
|
14
|
+
|
15
|
+
This represents a Ruby binding to the DNS Service Discovery API published
|
16
|
+
and open-sourced by Apple Computer. This should compile with the source
|
17
|
+
available from the Darwin project, or on OS X Panther systems. It will
|
18
|
+
also compile on Win32 platforms that have installed the Rendezvous for
|
19
|
+
Windows Technology Preview 2 which can be found here:
|
20
|
+
|
21
|
+
http://developer.apple.com/macosx/rendezvous/
|
22
|
+
|
23
|
+
To build, simply run:
|
24
|
+
|
25
|
+
$ ruby setup.rb config
|
26
|
+
$ ruby setup.rb setup
|
27
|
+
# ruby setup.rb install (may require root privilege)
|
28
|
+
|
29
|
+
This installs two files, a high level api:
|
30
|
+
|
31
|
+
<ruby lib path>/site_ruby/1.8/dnssd.rb
|
32
|
+
|
33
|
+
...and a low level native expension:
|
34
|
+
|
35
|
+
<ruby lib path>/site_ruby/1.8/powerpc-darwin/rdnssd.so/.dll/.bundle
|
36
|
+
|
37
|
+
The dnssd.rb file is what you require:
|
38
|
+
|
39
|
+
require 'dnssd'
|
40
|
+
|
41
|
+
...and that loads the rdnssd native extension. See the ./test
|
42
|
+
directory for tests that demonstrate using the DNSSD library for
|
43
|
+
Ruby.
|
44
|
+
|
45
|
+
Developers:
|
46
|
+
|
47
|
+
Charlie Mills
|
48
|
+
Rich Kilmer
|
49
|
+
Chad Fowler
|
50
|
+
Stuart Cheshire
|
@@ -0,0 +1,58 @@
|
|
1
|
+
net-mdns is copyrighted free software by Sam Roberts <sroberts@uniserve.com>.
|
2
|
+
|
3
|
+
You can redistribute it and/or modify it under either the terms of the GPL (see
|
4
|
+
the file GPL), or the conditions below:
|
5
|
+
|
6
|
+
1. You may make and give away verbatim copies of the source form of the
|
7
|
+
software without restriction, provided that you duplicate all of the
|
8
|
+
original copyright notices and associated disclaimers.
|
9
|
+
|
10
|
+
2. You may modify your copy of the software in any way, provided that
|
11
|
+
you do at least ONE of the following:
|
12
|
+
|
13
|
+
a) place your modifications in the Public Domain or otherwise make them
|
14
|
+
Freely Available, such as by posting said modifications to Usenet or an
|
15
|
+
equivalent medium, or by allowing the author to include your
|
16
|
+
modifications in the software.
|
17
|
+
|
18
|
+
b) use the modified software only within your corporation or
|
19
|
+
organization.
|
20
|
+
|
21
|
+
c) give non-standard binaries non-standard names, with instructions on
|
22
|
+
where to get the original software distribution.
|
23
|
+
|
24
|
+
d) make other distribution arrangements with the author.
|
25
|
+
|
26
|
+
3. You may distribute the software in object code or binary form,
|
27
|
+
provided that you do at least ONE of the following:
|
28
|
+
|
29
|
+
a) distribute the binaries and library files of the software, together
|
30
|
+
with instructions (in the manual page or equivalent) on where to get the
|
31
|
+
original distribution.
|
32
|
+
|
33
|
+
b) accompany the distribution with the machine-readable source of the
|
34
|
+
software.
|
35
|
+
|
36
|
+
c) give non-standard binaries non-standard names, with instructions on
|
37
|
+
where to get the original software distribution.
|
38
|
+
|
39
|
+
d) make other distribution arrangements with the author.
|
40
|
+
|
41
|
+
4. You may modify and include the part of the software into any other
|
42
|
+
software (possibly commercial). But some files in the distribution
|
43
|
+
are not written by the author, so that they are not under these terms.
|
44
|
+
|
45
|
+
For the list of those files and their copying conditions, see the
|
46
|
+
file LEGAL.
|
47
|
+
|
48
|
+
5. The scripts and library files supplied as input to or produced as
|
49
|
+
output from the software do not automatically fall under the
|
50
|
+
copyright of the software, but belong to whomever generated them,
|
51
|
+
and may be sold commercially, and may be aggregated with this
|
52
|
+
software.
|
53
|
+
|
54
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
55
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
56
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
57
|
+
PURPOSE.
|
58
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
net-mdns - DNS-SD and mDNS implementation for Ruby
|
2
|
+
|
3
|
+
Installation:
|
4
|
+
|
5
|
+
The standard way, with the setup.rb script:
|
6
|
+
|
7
|
+
ruby setup.rb --help
|
8
|
+
ruby setup.rb all
|
9
|
+
|
10
|
+
Documentation:
|
11
|
+
|
12
|
+
http://dnssd.rubyforge.org/net-mdns
|
13
|
+
|
14
|
+
Author:
|
15
|
+
|
16
|
+
Sam Roberts <sroberts@uniserve.com>
|
17
|
+
|
18
|
+
Licence:
|
19
|
+
|
20
|
+
Ruby's, see COPYING.
|
21
|
+
|