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

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

 



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@xxxxxxxxxxx>
---
 .../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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux