diff --git a/apps/jetty/build.xml b/apps/jetty/build.xml
index 49a1064d3..13d3f92e0 100644
--- a/apps/jetty/build.xml
+++ b/apps/jetty/build.xml
@@ -80,13 +80,44 @@
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/jetty/java/src/org/mortbay/http/I2PRequestLog.java b/apps/jetty/java/src/org/mortbay/http/I2PRequestLog.java
new file mode 100644
index 000000000..4c96e49f2
--- /dev/null
+++ b/apps/jetty/java/src/org/mortbay/http/I2PRequestLog.java
@@ -0,0 +1,182 @@
+// ========================================================================
+// $Id: NCSARequestLog.java,v 1.35 2005/08/13 00:01:24 gregwilkins Exp $
+// Copyright 2000-2004 Mort Bay Consulting Pty. Ltd.
+// ------------------------------------------------------------------------
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+// http://www.apache.org/licenses/LICENSE-2.0
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+// ========================================================================
+
+package org.mortbay.http;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.Locale;
+import java.util.TimeZone;
+
+import javax.servlet.http.Cookie;
+
+import org.apache.commons.logging.Log;
+import org.mortbay.log.LogFactory;
+import org.mortbay.util.DateCache;
+import org.mortbay.util.LogSupport;
+import org.mortbay.util.RolloverFileOutputStream;
+import org.mortbay.util.StringUtil;
+
+
+/* ------------------------------------------------------------ */
+/** NCSA HTTP Request Log.
+ *
+ * Override log() to put in the requestor's destination hash,
+ * instead of 127.0.0.1,
+ * which is placed in the X-I2P-DestHash field in the request headers
+ * by I2PTunnelHTTPServer.
+ *
+ * NCSA common or NCSA extended (combined) request log.
+ * @version $Id: NCSARequestLog.java,v 1.35 2005/08/13 00:01:24 gregwilkins Exp $
+ * @author Tony Thompson
+ * @author Greg Wilkins
+ */
+public class I2PRequestLog extends NCSARequestLog
+{
+ /* ------------------------------------------------------------ */
+ /** Constructor.
+ */
+ public I2PRequestLog()
+ {
+ super();
+ }
+
+ /* ------------------------------------------------------------ */
+ /** Constructor.
+ * @param filename Filename, which can be in
+ * rolloverFileOutputStream format
+ * @see org.mortbay.util.RolloverFileOutputStream
+ * @exception IOException
+ */
+ public I2PRequestLog(String filename)
+ throws IOException
+ {
+ super(filename);
+ }
+
+ /* ------------------------------------------------------------ */
+ /** Log a request.
+ * @param request The request
+ * @param response The response to this request.
+ * @param responseLength The bytes written to the response.
+ */
+ public void log(HttpRequest request,
+ HttpResponse response,
+ int responseLength)
+ {
+ try{
+ // ignore ignorables
+ if (_ignorePathMap != null &&
+ _ignorePathMap.getMatch(request.getPath()) != null)
+ return;
+
+ // log the rest
+ if (_fileOut==null)
+ return;
+
+ StringBuffer buf = new StringBuffer(160);
+
+ String addr = request.getField("X-I2P-DestHash");
+ if(addr != null)
+ buf.append(addr).append(".i2p");
+ else
+ buf.append(request.getRemoteAddr());
+
+ buf.append(" - ");
+ String user = request.getAuthUser();
+ buf.append((user==null)?"-":user);
+ buf.append(" [");
+ buf.append(_logDateCache.format(request.getTimeStamp()));
+ buf.append("] \"");
+ buf.append(request.getMethod());
+ buf.append(' ');
+ buf.append(request.getURI());
+ buf.append(' ');
+ buf.append(request.getVersion());
+ buf.append("\" ");
+ int status=response.getStatus();
+ buf.append((char)('0'+((status/100)%10)));
+ buf.append((char)('0'+((status/10)%10)));
+ buf.append((char)('0'+(status%10)));
+ if (responseLength>=0)
+ {
+ buf.append(' ');
+ if (responseLength>99999)
+ buf.append(Integer.toString(responseLength));
+ else
+ {
+ if (responseLength>9999)
+ buf.append((char)('0'+((responseLength/10000)%10)));
+ if (responseLength>999)
+ buf.append((char)('0'+((responseLength/1000)%10)));
+ if (responseLength>99)
+ buf.append((char)('0'+((responseLength/100)%10)));
+ if (responseLength>9)
+ buf.append((char)('0'+((responseLength/10)%10)));
+ buf.append((char)('0'+(responseLength%10)));
+ }
+ buf.append(' ');
+ }
+ else
+ buf.append(" - ");
+
+ String log =buf.toString();
+ synchronized(_writer)
+ {
+ _writer.write(log);
+ if (isExtended())
+ {
+ logExtended(request,response,_writer);
+ if (!getLogCookies())
+ _writer.write(" -");
+ }
+
+ if (getLogCookies())
+ {
+ Cookie[] cookies = request.getCookies();
+ if (cookies==null || cookies.length==0)
+ _writer.write(" -");
+ else
+ {
+ _writer.write(" \"");
+ for (int i=0;i0)
+ {
+ _ignorePathMap=new PathMap();
+ for (int i=0;i<_ignorePaths.length;i++)
+ _ignorePathMap.put(_ignorePaths[i],_ignorePaths[i]);
+ }
+ else
+ _ignorePathMap=null;
+
+ _writer=new OutputStreamWriter(_out);
+ }
+
+ /* ------------------------------------------------------------ */
+ public boolean isStarted()
+ {
+ return _fileOut!=null;
+ }
+
+ /* ------------------------------------------------------------ */
+ public void stop()
+ {
+ try{if (_writer!=null)_writer.flush();} catch (IOException e){LogSupport.ignore(log,e);}
+ if (_out!=null && _closeOut)
+ try{_out.close();}catch(IOException e){LogSupport.ignore(log,e);}
+ _out=null;
+ _fileOut=null;
+ _closeOut=false;
+ _logDateCache=null;
+ _writer=null;
+ }
+
+ /* ------------------------------------------------------------ */
+ /** Log a request.
+ * @param request The request
+ * @param response The response to this request.
+ * @param responseLength The bytes written to the response.
+ */
+ public void log(HttpRequest request,
+ HttpResponse response,
+ int responseLength)
+ {
+ try{
+ // ignore ignorables
+ if (_ignorePathMap != null &&
+ _ignorePathMap.getMatch(request.getPath()) != null)
+ return;
+
+ // log the rest
+ if (_fileOut==null)
+ return;
+
+ StringBuffer buf = new StringBuffer(160);
+
+ String addr = null;
+ if(_preferProxiedForAddress)
+ {
+ // If header is not present, addr will remain null ...
+ addr = request.getField(HttpFields.__XForwardedFor);
+ }
+ if(addr == null)
+ addr = request.getRemoteAddr();
+ buf.append(addr);
+
+ buf.append(" - ");
+ String user = request.getAuthUser();
+ buf.append((user==null)?"-":user);
+ buf.append(" [");
+ buf.append(_logDateCache.format(request.getTimeStamp()));
+ buf.append("] \"");
+ buf.append(request.getMethod());
+ buf.append(' ');
+ buf.append(request.getURI());
+ buf.append(' ');
+ buf.append(request.getVersion());
+ buf.append("\" ");
+ int status=response.getStatus();
+ buf.append((char)('0'+((status/100)%10)));
+ buf.append((char)('0'+((status/10)%10)));
+ buf.append((char)('0'+(status%10)));
+ if (responseLength>=0)
+ {
+ buf.append(' ');
+ if (responseLength>99999)
+ buf.append(Integer.toString(responseLength));
+ else
+ {
+ if (responseLength>9999)
+ buf.append((char)('0'+((responseLength/10000)%10)));
+ if (responseLength>999)
+ buf.append((char)('0'+((responseLength/1000)%10)));
+ if (responseLength>99)
+ buf.append((char)('0'+((responseLength/100)%10)));
+ if (responseLength>9)
+ buf.append((char)('0'+((responseLength/10)%10)));
+ buf.append((char)('0'+(responseLength%10)));
+ }
+ buf.append(' ');
+ }
+ else
+ buf.append(" - ");
+
+ String log =buf.toString();
+ synchronized(_writer)
+ {
+ _writer.write(log);
+ if (_extended)
+ {
+ logExtended(request,response,_writer);
+ if (!_logCookies)
+ _writer.write(" -");
+ }
+
+ if (_logCookies)
+ {
+ Cookie[] cookies = request.getCookies();
+ if (cookies==null || cookies.length==0)
+ _writer.write(" -");
+ else
+ {
+ _writer.write(" \"");
+ for (int i=0;i
-
+
./eepsite/logs/yyyy_mm_dd.request.log
90
true