git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[JGIT PATCH 3/3] Record pushes done over anonymous git:// using peer IP

From
Shawn O. Pearce <spearce@spearce.org>
Date
Feb 4, 2009, 23:15 UTC
Message-ID
<1233789342-28079-3-git-send-email-spearce@spearce.org>
In-Reply-To
<1233789342-28079-2-git-send-email-spearce@spearce.org>

The only data we have on the remote user on the other side of a git:// network connection is their IP address/hostname. So we list that in the reflog as it is better than no data at all.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 .../src/org/spearce/jgit/transport/Daemon.java     |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java b/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java
index 646c88d..5087533 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/transport/Daemon.java
@@ -43,6 +43,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InterruptedIOException;
+import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.ServerSocket;
 import java.net.Socket;
@@ -53,6 +54,7 @@
 import java.util.Map;
 import java.util.regex.Pattern;
 
+import org.spearce.jgit.lib.PersonIdent;
 import org.spearce.jgit.lib.Repository;
 
 /** Basic daemon for the anonymous <code>git://</code> transport protocol. */
@@ -118,8 +120,15 @@ protected void execute(final DaemonClient dc,
 					@Override
 					protected void execute(final DaemonClient dc,
 							final Repository db) throws IOException {
+						final InetAddress peer = dc.getRemoteAddress();
+						String host = peer.getCanonicalHostName();
+						if (host == null)
+							host = peer.getHostAddress();
 						final ReceivePack rp = new ReceivePack(db);
 						final InputStream in = dc.getInputStream();
+						final String name = "anonymous";
+						final String email = name + "@" + host;
+						rp.setRefLogIdent(new PersonIdent(name, email));
 						rp.receive(in, dc.getOutputStream(), null);
 					}
 				} };
-- 
1.6.1.2.492.g8554a
Previous: Shawn O. Pearce
Message 3 of 3 in “Allow RefUpdate callers to control the PersonIdent recorded”
  1. 1/3 Allow RefUpdate callers to control the PersonIdent recordedShawn O. Pearce, Feb 4, 2009
  2. 2/3 Allow the reflog identity to be set in ReceivePackShawn O. Pearce, Feb 4, 2009
  3. 3/3 Record pushes done over anonymous git:// using peer IPShawn O. Pearce, Feb 4, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.