Subject: [RFC/PATCH 0/6] git: please honor DNS SRV records

From: Jonathan Nieder <[email-masked]>
Date: Mon, 6 Jun 2011 04:30:20 -0500

Hi,

Julien Cristau wrote:
> On Tue, May 24, 2011 at 15:22:55 -0500, Jonathan Nieder wrote:

>> As rfc2782 explains, SRV records allow administrators "to use serveral
>> servers for a single domain, to move services from host to host with
>> little fuss, and to designate some hosts as primary servers for a
>> service and others as backups".  Julien Cristau noticed that in the
>> recent alioth move that second part would have been very handy (since
>> the git protocol doesn't include a concept of redirects).
[...]
> I played with this a bit tonight, came up with
> http://people.debian.org/~jcristau/git-srv-hack.diff which seems to work
> for me.  In case somebody wants to test/polish it up...

So I have played with it a little more.  Very rough, completely
untested, in desperate need of a test script, but I think it is ready
for some feedback.  To recap, this is really just an evil workaround
for the lack of support for redirects in git protocol, but it has a
nice side effect of making load balancing a little easier for server
administrators.

Patches 1-3 are code movement, to give the code that is being changed
a home and make it a little easier to contemplate.  In particular
patch 3 draws attention to some code from git daemon that makes DNS
lookups to get the canonical hostname and IP a client contacted.
Should it pay attention to SRV records?

Patch 5 is another cleanup patch.  It unifies the ipv4 and ipv6
implementations of git_tcp_connect by abstracting away some of the
differences between the underlying OS interfaces.  Patch 4 is a tiny
bugfix noticed in the process.

None of the above should be necessary for or even has much to do with
patch 6, the nominal topic of the series.  Sorry about that.

Anyway, patch 6 is an attempt to implement rfc2782, expanded from the
implementation of a subset that Julien sent.  It doesn't pay attention
to the "additional data" section of the SRV response to avoid A or
AAAA lookups, but it probably should.

At the back of my head there is this nagging feeling that getaddrinfo
should accept an ai_flags bit to do this for us automatically, but it
doesn't as far as I can tell.  Maybe this can be a stepping stone
toward that...

If nothing else, it's kind of fun.  Thoughts?  Does the general idea
seem sane?  Am I overlooking some standard function that takes care of
this all automatically?