I've made a patch that logs remote hostname in history, instead of just
"<remote>".
Maybe it's not portable to Win32. Maybe someone can help me with that?
Comments?
--
/Peter �strand <[EMAIL PROTECTED]>
--- main.c.org Fri Apr 27 21:57:23 2001
+++ main.c Wed Oct 31 19:41:00 2001
@@ -12,6 +12,10 @@
*
*/
+#include <netdb.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
#include <assert.h>
#include "cvs.h"
@@ -715,13 +719,36 @@
#endif
/* This is only used for writing into the history file. For
- remote connections, it might be nice to have hostname
- and/or remote path, on the other hand I'm not sure whether
- it is worth the trouble. */
+ remote connections, log hostname. */
#ifdef SERVER_SUPPORT
- if (server_active)
- CurDir = xstrdup ("<remote>");
+ if (server_active)
+ {
+ struct sockaddr_in peer;
+ int len;
+ struct hostent *hp;
+
+ len = sizeof(peer);
+
+ if (getpeername (STDIN_FILENO, (struct sockaddr *) &peer, &len) < 0)
+ {
+ /* getpeername failed */
+ CurDir = xstrdup ("<unknown remote>");
+ }
+ else
+ {
+ hp = gethostbyaddr (&peer.sin_addr, sizeof (struct in_addr), AF_INET);
+ if (hp == NULL)
+ {
+ /* gethostbyaddr failed. Log IP. */
+ CurDir = xstrdup (inet_ntoa (peer.sin_addr));
+ }
+ else
+ {
+ CurDir = xstrdup (hp->h_name);
+ }
+ }
+ }
else
#endif
{