forked from I2P_Developers/i2p.i2p
propagate from branch 'i2p.i2p' (head 5d56a7eb371dddb9336e596bda69f99c91294b05)
to branch 'i2p.i2p.str4d.ui' (head 3aeafcdb5c0ffbc9c77f574558f8438d3e81133e)
This commit is contained in:
@@ -13,6 +13,22 @@
|
||||
</filter-mapping>
|
||||
|
||||
<display-name>susidns</display-name>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>addressbook-runner</servlet-name>
|
||||
<servlet-class>net.i2p.addressbook.servlet.Servlet</servlet-class>
|
||||
<init-param>
|
||||
<param-name>home</param-name>
|
||||
<param-value>./addressbook</param-value>
|
||||
</init-param>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>addressbook-runner</servlet-name>
|
||||
<url-pattern>/addressbook-runner</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<!-- precompiled servlets -->
|
||||
|
||||
<!-- non-.jsp URLs -->
|
||||
|
@@ -16,20 +16,22 @@
|
||||
-->
|
||||
<pathelement location="${lib}/commons-el.jar" />
|
||||
<pathelement location="${lib}/javax.servlet.jar"/>
|
||||
<!-- jsp-api.jar only present for debian builds -->
|
||||
|
||||
<!-- following jars only present for debian builds -->
|
||||
<pathelement location="${lib}/jsp-api.jar" />
|
||||
<!-- tomcat-api.jar only present for debian builds -->
|
||||
<pathelement location="${lib}/tomcat-api.jar" />
|
||||
<!-- tomcat-util.jar only present for debian builds -->
|
||||
<pathelement location="${lib}/tomcat-util.jar" />
|
||||
<pathelement location="${lib}/tomcat-util-scan.jar" />
|
||||
<pathelement location="${lib}/jasper-el.jar" />
|
||||
|
||||
<pathelement location="lib/jstl.jar" />
|
||||
<pathelement location="lib/standard.jar" />
|
||||
<pathelement location="${lib}/jasper-runtime.jar" />
|
||||
<pathelement location="${lib}/commons-logging.jar" />
|
||||
<!-- jasper-el.jar only present for debian builds -->
|
||||
<pathelement location="${lib}/jasper-el.jar" />
|
||||
<pathelement location="${lib}/jetty-util.jar" />
|
||||
<pathelement location="${ant.home}/lib/ant.jar" />
|
||||
<pathelement location="../../../core/java/build/i2p.jar" />
|
||||
<pathelement location="../../addressbook/dist/addressbook.jar" />
|
||||
</path>
|
||||
|
||||
<property name="javac.compilerargs" value="" />
|
||||
|
@@ -314,6 +314,9 @@ public class AddressbookBean extends BaseBean
|
||||
}
|
||||
if (action.equals(_t("Delete Entry")))
|
||||
search = null;
|
||||
} else if (action.equals(_t("Add Alternate"))) {
|
||||
// button won't be in UI
|
||||
message = "Unsupported";
|
||||
}
|
||||
if( changed ) {
|
||||
try {
|
||||
|
@@ -231,7 +231,7 @@ public class NamingServiceBean extends AddressbookBean
|
||||
if (_context.getBooleanProperty(PROP_PW_ENABLE) ||
|
||||
(serial != null && serial.equals(lastSerial))) {
|
||||
boolean changed = false;
|
||||
if (action.equals(_t("Add")) || action.equals(_t("Replace"))) {
|
||||
if (action.equals(_t("Add")) || action.equals(_t("Replace")) || action.equals(_t("Add Alternate"))) {
|
||||
if(hostname != null && destination != null) {
|
||||
try {
|
||||
// throws IAE with translated message
|
||||
@@ -243,20 +243,38 @@ public class NamingServiceBean extends AddressbookBean
|
||||
Destination oldDest = getNamingService().lookup(host, nsOptions, outProperties);
|
||||
if (oldDest != null && destination.equals(oldDest.toBase64())) {
|
||||
message = _t("Host name {0} is already in address book, unchanged.", displayHost);
|
||||
} else if (oldDest != null && !action.equals(_t("Replace"))) {
|
||||
} else if (oldDest == null && action.equals(_t("Add Alternate"))) {
|
||||
message = _t("Host name {0} is not in the address book.", displayHost);
|
||||
} else if (oldDest != null && action.equals(_t("Add"))) {
|
||||
message = _t("Host name {0} is already in address book with a different destination. Click \"Replace\" to overwrite.", displayHost);
|
||||
} else {
|
||||
try {
|
||||
Destination dest = new Destination(destination);
|
||||
if (oldDest != null) {
|
||||
nsOptions.putAll(outProperties);
|
||||
nsOptions.setProperty("m", Long.toString(_context.clock().now()));
|
||||
String now = Long.toString(_context.clock().now());
|
||||
if (action.equals(_t("Add Alternate")))
|
||||
nsOptions.setProperty("a", now);
|
||||
else
|
||||
nsOptions.setProperty("m", now);
|
||||
}
|
||||
nsOptions.setProperty("s", _t("Manually added via SusiDNS"));
|
||||
boolean success = getNamingService().put(host, dest, nsOptions);
|
||||
boolean success;
|
||||
if (action.equals(_t("Add Alternate"))) {
|
||||
// check all for dups
|
||||
List<Destination> all = getNamingService().lookupAll(host);
|
||||
if (all == null || !all.contains(dest)) {
|
||||
success = getNamingService().addDestination(host, dest, nsOptions);
|
||||
} else {
|
||||
// will get generic message below
|
||||
success = false;
|
||||
}
|
||||
} else {
|
||||
success = getNamingService().put(host, dest, nsOptions);
|
||||
}
|
||||
if (success) {
|
||||
changed = true;
|
||||
if (oldDest == null)
|
||||
if (oldDest == null || action.equals(_t("Add Alternate")))
|
||||
message = _t("Destination added for {0}.", displayHost);
|
||||
else
|
||||
message = _t("Destination changed for {0}.", displayHost);
|
||||
@@ -285,8 +303,21 @@ public class NamingServiceBean extends AddressbookBean
|
||||
} else if (action.equals(_t("Delete Selected")) || action.equals(_t("Delete Entry"))) {
|
||||
String name = null;
|
||||
int deleted = 0;
|
||||
Destination matchDest = null;
|
||||
if (action.equals(_t("Delete Entry"))) {
|
||||
// remove specified dest only in case there is more than one
|
||||
if (destination != null) {
|
||||
try {
|
||||
matchDest = new Destination(destination);
|
||||
} catch (DataFormatException dfe) {}
|
||||
}
|
||||
}
|
||||
for (String n : deletionMarks) {
|
||||
boolean success = getNamingService().remove(n, nsOptions);
|
||||
boolean success;
|
||||
if (matchDest != null)
|
||||
success = getNamingService().remove(n, matchDest, nsOptions);
|
||||
else
|
||||
success = getNamingService().remove(n, nsOptions);
|
||||
String uni = AddressBean.toUnicode(n);
|
||||
String displayHost = uni.equals(n) ? n : uni + " (" + n + ')';
|
||||
if (!success) {
|
||||
|
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (c) 2004 Ragnarok
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package net.i2p.addressbook.servlet;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
//import net.i2p.addressbook.DaemonThread;
|
||||
import net.i2p.util.Log;
|
||||
|
||||
/**
|
||||
* A wrapper for addressbook to allow it to be started as a web application.
|
||||
*
|
||||
* This was a GenericServlet, we make it an HttpServlet solely to provide a
|
||||
* simple page to display status.
|
||||
*
|
||||
* @since 0.9.30 moved from addressbook to SusiDNS
|
||||
* @author Ragnarok
|
||||
*
|
||||
*/
|
||||
public class Servlet extends HttpServlet {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private transient Thread thread;
|
||||
//private String nonce;
|
||||
//private static final String PROP_NONCE = "addressbook.nonce";
|
||||
|
||||
/**
|
||||
* Simple output to verify that the addressbook servlet is running.
|
||||
*
|
||||
* (non-Javadoc)
|
||||
* see javax.servlet.Servlet#service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
|
||||
*/
|
||||
public void service(HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
//System.err.println("Got request nonce = " + request.getParameter("nonce"));
|
||||
//if (this.thread != null && request.getParameter("wakeup") != null &&
|
||||
// this.nonce != null && this.nonce.equals(request.getParameter("nonce"))) {
|
||||
// //System.err.println("Sending interrupt");
|
||||
// this.thread.interrupt();
|
||||
// // no output
|
||||
//} else {
|
||||
PrintWriter out = response.getWriter();
|
||||
out.write("I2P addressbook OK");
|
||||
//}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see javax.servlet.Servlet#init(javax.servlet.ServletConfig)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void init(ServletConfig config) {
|
||||
try {
|
||||
super.init(config);
|
||||
} catch (ServletException exp) {
|
||||
System.err.println("Addressbook init exception: " + exp);
|
||||
}
|
||||
//this.nonce = "" + Math.abs((new Random()).nextLong());
|
||||
// put the nonce where susidns can get it
|
||||
//System.setProperty(PROP_NONCE, this.nonce);
|
||||
String[] args = new String[1];
|
||||
args[0] = config.getInitParameter("home");
|
||||
try {
|
||||
ClassLoader cl = getServletContext().getClassLoader();
|
||||
Class cls = Class.forName("net.i2p.addressbook.DaemonThread", true, cl);
|
||||
// We do it this way so that if we can't find addressbook,
|
||||
// the whole thing doesn't die.
|
||||
// We do add addressbook.jar in WebAppConfiguration,
|
||||
// so this is just in case.
|
||||
//Thread t = new DaemonThread(args);
|
||||
Thread t = (Thread) cls.getConstructor(String[].class).newInstance((Object)args);
|
||||
t.setDaemon(true);
|
||||
t.setName("Addressbook");
|
||||
t.start();
|
||||
this.thread = t;
|
||||
//System.out.println("INFO: Starting Addressbook " + Daemon.VERSION);
|
||||
//System.out.println("INFO: config root under " + args[0]);
|
||||
} catch (Throwable t) {
|
||||
// addressbook.jar may not be in the classpath
|
||||
I2PAppContext.getGlobalContext().logManager().getLog(Servlet.class).logAlways(Log.WARN, "Addressbook thread not started: " + t);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void destroy() {
|
||||
if (this.thread != null) {
|
||||
//((DaemonThread)this.thread).halt();
|
||||
try {
|
||||
ClassLoader cl = getServletContext().getClassLoader();
|
||||
Class<?> cls = Class.forName("net.i2p.addressbook.DaemonThread", true, cl);
|
||||
Object t = cls.cast(this.thread);
|
||||
cls.getDeclaredMethod("halt").invoke(t);
|
||||
} catch (Throwable t) {}
|
||||
}
|
||||
super.destroy();
|
||||
}
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<body>
|
||||
<p>
|
||||
The servlet that starts the addressbook DaemonThread.
|
||||
Moved from addressbook to SusiDNS in 0.9.30.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
@@ -136,6 +136,7 @@ ${book.loadBookMessages}
|
||||
|
||||
<div id="search">
|
||||
<form method="POST" action="addressbook">
|
||||
<input type="hidden" name="book" value="${book.book}">
|
||||
<input type="hidden" name="begin" value="0">
|
||||
<input type="hidden" name="end" value="49">
|
||||
<table>
|
||||
@@ -154,6 +155,7 @@ ${book.loadBookMessages}
|
||||
%>
|
||||
<c:if test="${book.notEmpty}">
|
||||
<form method="POST" action="addressbook">
|
||||
<input type="hidden" name="book" value="${book.book}">
|
||||
<input type="hidden" name="serial" value="<%=susiNonce%>">
|
||||
<input type="hidden" name="begin" value="0">
|
||||
<input type="hidden" name="end" value="49">
|
||||
@@ -181,7 +183,7 @@ ${book.loadBookMessages}
|
||||
<td class="names"><a href="/imagegen/id?s=256&c=${addr.b32}" target="_blank" title="<%=intl._t("View larger version of identicon for this hostname")%>"><img src="/imagegen/id?s=20&c=${addr.b32}"></a><a href="http://${addr.name}/" target="_top">${addr.displayName}</a></td>
|
||||
<td class="names"><span class="addrhlpr"><a href="http://${addr.b32}/" target="_blank" title="<%=intl._t("Base 32 address")%>">b32</a></span></td>
|
||||
<td class="helper"><a href="http://${addr.name}/?i2paddresshelper=${addr.destination}" target="_blank" title="<%=intl._t("Helper link to share host address with option to add to addressbook")%>">link</a></td>
|
||||
<td class="names"><span class="addrhlpr"><a href="details?h=${addr.name}" title="<%=intl._t("More information on this entry")%>"><%=intl._t("details")%></a></span></td>
|
||||
<td class="names"><span class="addrhlpr"><a href="details?h=${addr.name}&book=${book.book}" title="<%=intl._t("More information on this entry")%>"><%=intl._t("details")%></a></span></td>
|
||||
<td class="destinations"><div class="destaddress" name="dest_${addr.name}" width="200px">${addr.destination}</div></td>
|
||||
|
||||
<c:if test="${book.validBook}">
|
||||
@@ -215,6 +217,7 @@ ${book.loadBookMessages}
|
||||
</c:if>
|
||||
|
||||
<form method="POST" action="addressbook">
|
||||
<input type="hidden" name="book" value="${book.book}">
|
||||
<input type="hidden" name="serial" value="<%=susiNonce%>">
|
||||
<input type="hidden" name="begin" value="0">
|
||||
<input type="hidden" name="end" value="49">
|
||||
@@ -233,6 +236,9 @@ ${book.loadBookMessages}
|
||||
<p class="buttons">
|
||||
<input class="cancel" type="reset" value="<%=intl._t("Cancel")%>" >
|
||||
<input class="accept" type="submit" name="action" value="<%=intl._t("Replace")%>" >
|
||||
<% if (!book.getBook().equals("published")) { %>
|
||||
<input class="add" type="submit" name="action" value="<%=intl._t("Add Alternate")%>" >
|
||||
<% } %>
|
||||
<input class="add" type="submit" name="action" value="<%=intl._t("Add")%>" >
|
||||
</p>
|
||||
</div>
|
||||
|
@@ -77,6 +77,8 @@
|
||||
if (addrs == null) {
|
||||
%><p>Not found: <%=detail%></p><%
|
||||
} else {
|
||||
// use one nonce for all
|
||||
String nonce = book.getSerial();
|
||||
for (i2p.susi.dns.AddressBean addr : addrs) {
|
||||
String b32 = addr.getB32();
|
||||
%>
|
||||
@@ -149,10 +151,12 @@
|
||||
<div id="buttons">
|
||||
<form method="POST" action="addressbook">
|
||||
<p class="buttons">
|
||||
<input type="hidden" name="serial" value="${book.serial}">
|
||||
<input type="hidden" name="book" value="${book.book}">
|
||||
<input type="hidden" name="serial" value="<%=nonce%>">
|
||||
<input type="hidden" name="begin" value="0">
|
||||
<input type="hidden" name="end" value="49">
|
||||
<input type="hidden" name="checked" value="<%=detail%>">
|
||||
<input type="hidden" name="destination" value="<%=addr.getDestination()%>">
|
||||
<input class="delete" type="submit" name="action" value="<%=intl._t("Delete Entry")%>" >
|
||||
</p>
|
||||
</form>
|
||||
|
Reference in New Issue
Block a user