Wireless Hacks. 1917 IndustrialStrength Tips and Tools [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Wireless Hacks. 1917 IndustrialStrength Tips and Tools [Electronic resources] - نسخه متنی

Rob Flickenger

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید












Hack 28 Rendezvous Service Advertisements in Linux




Let your users know what services are available
on your network, even if you aren't running OS
X.



Since I'm running a node on SeattleWireless (as
well as a streaming jukebox that I'm developing),
I'd like to let people know what local services are
available. Sure, most visitors just jump straight to their favorite
web site or check their email (or their popularity) when they hit my
node, but perhaps they'd like to enjoy some local
content at a whopping 11 Mbps?


This is one reason why I love
multicast DNS service
(http://www.multicastdns.org/)
advertisements (and Rendezvous, in particular). My Linux Jukebox and
Wiki are now announcing themselves
like an old-time barker at the county fair. Wireless users at the
cafe across the street (or anywhere within a block or so) can find my
local services any time just by looking at available Rendezvous sites
(Figure 3-23). As if that weren't
enough, my streamer is even advertising itself as a
daap stream, so iTunes 4 users can see that
it's available from inside iTunes.



Figure 3-23. Users can easily find advertised services using a Rendezvous-enabled browser.





To advertise Rendezvous services, you need a multicast DNS
advertiser. I think
Apple's own Posix
implementation is more than adequate. (Download it after a free
registration on Apple's site at http://www.opensource.apple.com/projects/rendezvous/source/Rendezvous.tar.gz.) The application you're
after is mDNSProxyResponderPosix, in the
mDNSPosix/ directory. It builds cleanly and
without so much as a warning under Linux 2.4.20. Once
it's built, install it somewhere handy (such as
/usr/local/bin, for example).


Next, figure out which services you want to advertise. They
don't even have to be local services, since the
Proxy server will obligingly hand out whatever IP addresses you care
to throw at it, local or not. I'm advertising my
local Wiki, the Jukebox, and the NoCat web site, just for fun.


The mDNSProxyResponderPosix program expects the
following arguments:


mDNSProxyResponderPosix [IP] [Host] [Title] [Service type] [Port] [Optional text]


The first argument is the IP address
you'd like to advertise. The second should be a
simple name that will be resolved as a
.local address
in multicast DNS. The Service title should be enclosed in double
quotes, and should be a descriptive name for what is being
advertised.


The Service type field is a little tricky. It takes the form:


_service._transport.


where service is a well-known IANA
service name (i.e., something out of
/etc/services) and transport
is the actual transport (such as
_tcp. or _udp.). The
Port argument is simply
the port number, and the optional text field supplies additional
information to the application receiving the advertisements (more on
this later).


For example, here's how I advertise my local
music jukebox:


$ mDNSProxyResponderPosix 10.15.6.1 muzik "Music Jukebox" _http._tcp. 80 &


This creates a muzik.local address that resolves
to 10.15.6.1. It is an HTTP service, running on tcp port 80. Also
notice the & at the end of the line. This is
necessary because mDNSProxyResponderPosix
doesn't auto-daemonize (hey, it's
just example code, after all). As it listens on UDP port 5353, it
doesn't need any special privileges to run, so I
recommend running it as a nonprivileged user.


This is all well and good for the jukebox, but what if you need to go
to a particular URL? For example, to get to my
Wiki, you need to go to http://florian.local/wiki, not just
http://florian.local/. This is
where the optional text field at the end comes in. Safari accepts a
path= argument in this field that gets appended to
the URL line. For example:


$ mDNSProxyResponderPosix 10.15.6.1 florian "About this node" _http._tcp.80[RETURN] 
path=/wiki &


And there you have it. Incidentally, if you're using

VirtualHosts in Apache,
you'll have to tell Apache to respond to the name
you're advertising (florian.local in the above example.) This is
done easily with the ServerAlias directive from
within your <VirtualHost> stanza:


ServerName florian.rob.swn 
ServerAlias florian.local


What about advertising nonlocal
services, like other web sites? Just specify their IP address as
normal:


$ mDNSProxyResponderPosix 216.218.203.211 nocat "NoCatNet" _http._tcp. 80 & 


Finally, since we have music available, it would be nice to advertise
directly to iTunes' sharing feature. Since iTunes is
simply expecting advertisements to the daap
service (as opposed to HTTP), this is a piece of cake:


$ mDNSProxyResponderPosix 10.15.6.1 squeal "http://muzik.rob.swn/" [RETURN]
_daap._tcp. 80


Unfortunately, you can't play the stream directly
from the "shared" play list, as
Apple uses a proprietary protocol to handle the streaming. So, since
I can't easily stream directly to the user (yet), I
do the next best thing: just spam the user with the relevant URL. If
the user is curious enough to browse to the URL that automagically
pops up in their iTunes playlist, they'll be
presented with my streamer.


Of course, mDNSProxyResponderPosix
isn't nearly as efficient as it could be. After all,
you're starting a separate instance for each service
you want to advertise, and there is not even a simple configuration
file. But keep in mind that this application is just example code
from Apple, and in due time more sophisticated multicast DNS
advertisement tools will come along. The full source (as well as the
complete spec, and some other great documents) are available, just
waiting for someone to write the killer Linux/BSD/Windows Rendezvous
app.





/ 158