A zeroconf proof of concept
Matt Mackall
mpm at selenic.com
Mon Jun 30 14:14:53 CDT 2008
On Mon, 2008-06-30 at 14:06 -0500, Augie Fackler wrote:
> On Jun 30, 2008, at 2:03 PM, Matt Mackall wrote:
>
> >
> > On Mon, 2008-06-30 at 13:53 -0500, Augie Fackler wrote:
> >> On Jun 30, 2008, at 10:52 AM, Matt Mackall wrote:
> >>
> >>> <snip instructions>
> >>>
> >>> Theoretically, this extension should work on Linux, Mac, and
> >>> Windows,
> >>> but I've only tried it on Linux. Enjoy.
> >>
> >> I've been poking it a bit on OS X, and it's failing on the line
> >> s.connect(('1.0.0.1', 0)) with an exception claiming "Can't assign
> >> requested address". I don't have more time to put into this now,
> >> but I
> >> may get a chance to look at this tonight.
> >
> > That's this code, which is admittedly a little odd:
> >
> >>> + s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
> >>> + s.connect(('1.0.0.1', 0))
> >>> + ip = s.getsockname()[0]
> >>> + localip = socket.inet_aton(ip)
> >
> > What's needed is a way to find a meaningful IP address for the
> > machine.
> > There are various things that don't work great and this is one of
> > them.
> > The idea is to open a dummy socket to a dummy address and find the
> > outgoing interface. The above on Linux doesn't even send a packet.
>
> Yeah, figured that out. It works here if I specify a nonzero port
> number.
>
> One thing I've noticed is that you're registering as an http server.
Seems only sensible: we are an http server.
> Maybe it'd be nicer to register as a custom server type? the zc-ified
> hg paths was showing me some of the HP printers in the office as being
> hg repos.
That's tricky. We could add some magic property to indicate we're a
Mercurial server. But then we have to think about the use case of people
who serve their repos with a proper web server and want to publish
zeroconf records that hg understands without going through hg serve.
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list