MOO-cows Mailing List Archive
Re: IP # from connection_name?
On Sat, 18 Jan 1997, Gustavo Glusman wrote:
> >I changed my connection_name() to return strings like this:
> >"port 3200 from localhost (127.0.0.1), port 1032"
> Could you please post the patch?
I guess so. I'm not at all proud of it though.
There's probably bugs in it which will destroy your database, etc.
The code I changed was in lookup_name_from_addr() in name_lookup.c. There's 3
ensure_buffer(&buffer, &buflen, len + 1);
ensure_buffer(&buffer, &buflen, len + 21);
I don't see how an IP could be longer than 15 characters but the original code
uses a length of 20 for them so I might as well.
buffer[len] = '\0';
unsigned32 a = ntohl(addr->sin_addr.s_addr);
sprintf((char *)buffer+len, " (%u.%u.%u.%u)",
(unsigned) (a >> 24) & 0xff, (unsigned) (a >> 16) & 0xff,
(unsigned) (a >> 8) & 0xff, (unsigned) a & 0xff);
This is basically just copying the code from the bottom of this function in
the case where the lookup fails. Then I thought I wanted the IP surrounded in
parentheses even in that case, so:
There are better ways to do this but I wanted to change the server code as
little as possible.
Subject Index |