bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Replace history's "<remote>" with client's IP


From: Mark D. Baushke
Subject: Re: Replace history's "<remote>" with client's IP
Date: Tue, 18 Oct 2005 15:06:33 -0700

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Derek Price <derek@ximbiot.com> writes:

> Mark D. Baushke wrote:
> 
> >Adding that to the possibity of two decimal represenatations of a 16-bit
> >port number means that there needs to be enough space in buf for 
> >
> >"xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:ddd.ddd.ddd.ddd ddddd ddddd\0"
> >
> >which is 58 characters... allow a few extra for a nice round 64 number...
> >  
> >
> 
> Why not just Xasprintf the value? I don't see a good reason for using a
> fixed length buffer here.

The diff I had was very old and was against an cvs 1.11.x release which
didn't have the Xasprintf() stuff in it at the time...

Were I to write it again today against 1.12.x, I would use Xasprintf().

> Also, there is no reason to reimplement the code to make the addr into a
> string. The POSIX getnameinfo() function already exists to turn a struct
> sockaddr * into a printable IP address or FQDN, as you prefer, and it
> should already handle both IPV4 & IPV6. I think that is about as current
> as it gets and its sister, getaddrinfo() is already in GNULIB, so we
> could probably get a reimplementation of getnameinfo() into GNULIB too.
> Of course, then you'd have to stick with the fixed length buffer. :)

I am NOT proposing the hack that I posted be part of the canonical CVS.

I had the code laying around in a tree that I used to test out the idea
once... at the time, I found that it was not 100% reliable on all
possible server hosts... I do not at present recall at present if there
was a getnameinfo() function on all of the hosts I tried or not.

If someone wants to put something like this into CVS, I would not
object, but I don't have any development time right now for this.

The intent of the posted patch was just to show how the information
could be obtained by a user that might need it for their CVSROOT/history
file.

> Reverse lookup could pretty easily be made into a config option like it
> is for Apache, since it is slow.

Sure.

> From the getnameinfo() man page:
> 
> In order to assist the programmer in choosing reasonable sizes for the
> supplied buffers, <netdb.h> defines the constants
> # define NI_MAXHOST 1025
> # define NI_MAXSERV 32
> The former is the constant MAXDNAME in recent versions of BINDÂ’s
> <arpa/nameser.h> header file. The latter is a guess based on the ser-
> vices listed in the current Assigned Numbers RFC.
> 
> Of course, those numbers are only relevant if you need the port number
> or want a reverse lookup on the IP when possible, and the constants are
> not portable according to POSIX, but they'd be easy to provide
> substitutes for when not defined.

Sure.

        -- Mark
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)

iD8DBQFDVXHpCg7APGsDnFERAg9oAKC24EhdrWrnB+L+BhFMvASGo4WjzgCg3D7d
Pc6PlqDplfBMBl28IJ7vN0Y=
=rs5p
-----END PGP SIGNATURE-----




reply via email to

[Prev in Thread] Current Thread [Next in Thread]