I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 8c1895e0 authored by jrandom's avatar jrandom Committed by zzz
Browse files

imported fixed susidns

parent c3d0132a
No related branches found
No related tags found
No related merge requests found
Showing
with 957 additions and 0 deletions
The src/ dir contains susidns 0.13 retrieved from http://susi.i2p/ on 2005/09/15
The contents are released under GPL. Please see http://susi.i2p/ for more info
The paths in the src/build.xml were updated to reference jars in the i2p
source tree.
File added
File added
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
"http://java.sun.com/j2ee/dtds/web-app_2.2.dtd">
<web-app>
<display-name>susidns</display-name>
<!-- precompiled servlets -->
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project name="susidns" default="all" basedir=".">
<property name="jetty" value="../../jetty/" />
<property name="project" value="susidns" />
<property name="src" value="java/src" />
<property name="bin" value="./WEB-INF/classes" />
<property name="lib" value="${jetty}/jettylib" />
<property name="tmp" value="./tmp" />
<property name="jsp" value="./jsp" />
<path id="cp">
<pathelement path="${classpath}" />
<pathelement location="${bin}" />
<pathelement location="${lib}/javax.servlet.jar"/>
<pathelement location="${lib}/org.mortbay.jetty.jar"/>
<pathelement location="WEB-INF/lib/jstl.jar" />
<pathelement location="WEB-INF/lib/standard.jar" />
<pathelement location="${lib}/jasper-compiler.jar" />
<pathelement location="${lib}/jasper-runtime.jar" />
<pathelement location="${lib}/javax.servlet.jar" />
<pathelement location="${lib}/commons-logging.jar" />
<pathelement location="${lib}/commons-el.jar" />
<pathelement location="${lib}/ant.jar" />
<pathelement location="../../../core/java/build/i2p.jar" />
</path>
<target name="compile">
<mkdir dir="${bin}" />
<javac debug="true" deprecation="on" source="1.3" target="1.3"
classpathref="cp" destdir="${bin}" srcdir="${src}" includes="**/*.java" />
</target>
<target name="precompilejsp">
<delete file="WEB-INF/web-fragment.xml" />
<delete file="WEB-INF/web-out.xml" />
<mkdir dir="${tmp}" />
<java classname="org.apache.jasper.JspC" fork="true" classpathref="cp">
<arg value="-d" />
<arg value="WEB-INF/classes" />
<arg value="-v" />
<arg value="-p" />
<arg value="i2p.susi.dns.jsp" />
<arg value="-webinc" />
<arg value="WEB-INF/web-fragment.xml" />
<arg value="-webapp" />
<arg value="./jsp" />
</java>
<javac debug="true" deprecation="on" source="1.3" target="1.3"
destdir="${bin}" srcdir="./WEB-INF/classes" includes="**/*.java" classpathref="cp">
</javac>
<copy file="WEB-INF/web-template.xml" tofile="WEB-INF/web-out.xml" />
<loadfile property="jspc.web.fragment" srcfile="WEB-INF/web-fragment.xml" />
<replace file="WEB-INF//web-out.xml">
<replacefilter token="&lt;!-- precompiled servlets --&gt;" value="${jspc.web.fragment}" />
</replace>
</target>
<target name="all" depends="compile,precompilejsp,war"/>
<target name="war">
<war destfile="${project}.war" webxml="WEB-INF/web-out.xml">
<fileset dir=".">
<include name="WEB-INF/**/*.class"/>
<include name="WEB-INF/lib/*.jar"/>
<include name="${src}/**/*.java"/>
<include name="jsp/*.jsp"/>
<include name="images/*.png"/>
<include name="css.css"/>
<include name="index.html"/>
<include name="build.xml"/>
<include name="WEB-INF/web-template.xml"/>
<include name="WEB-INF/web-out.xml"/>
<include name="WEB-INF/classes/${project}.properties"/>
</fileset>
</war>
</target>
<target name="clean">
<delete file="susidns.war" />
<delete>
<fileset dir="." includes="**/*.class" />
<fileset dir="." includes="tmp" />
</delete>
</target>
<target name="distclean" depends="clean" />
</project>
p {
font-family:Verdana,Tahoma,Arial,Helvetica;
color:black;
line-height:12pt;
margin-left:5mm;
margin-right:5mm;
font-size:10pt;
}
span.addrhlpr {
font-size:7pt;
}
h3 {
font-family:Verdana,Tahoma,Arial,Helvetica;
color:black;
font-size:12pt;
letter-spacing:2pt;
line-height:18pt;
font-weight:bold;
}
body {
background-color: white;
color:black;
}
a {
color:#327BBF;
text-decoration:none;
}
a:hover {
text-decoration:underline;
}
th {
font-family:Verdana,Tahoma,Arial,Helvetica;
color:black;
line-height:12pt;
margin-left:5mm;
margin-right:5mm;
font-size:10pt;
}
td {
font-family:Verdana,Tahoma,Arial,Helvetica;
color:black;
line-height:12pt;
margin-left:5mm;
margin-right:5mm;
font-size:10pt;
vertical-align:center;
}
li {
font-family:Verdana,Tahoma,Arial,Helvetica;
color:black;
line-height:12pt;
margin-left:5mm;
margin-right:5mm;
font-size:10pt;
}
tr.list1 {
background-color:#E0E0E0;
}
tr.list0 {
background-color:white;
}
p.messages {
background-color:#92CAFF;
color:#327BBF;
color:black;
border-style:dotted;
padding-top: 5mm;
padding-right: 5mm;
padding-bottom: 5mm;
padding-left: 5mm;
}
#help {
border-style:dotted;
padding-top: 5mm;
padding-right: 5mm;
padding-bottom: 5mm;
padding-left: 5mm;
}
p.footer {
font-size:7pt;
}
\ No newline at end of file
apps/susidns/src/images/add.png

2.43 KiB

apps/susidns/src/images/delete.png

3.21 KiB

apps/susidns/src/images/how.png

11.7 KiB

apps/susidns/src/images/logo.png

4.39 KiB

apps/susidns/src/images/reload.png

2.65 KiB

apps/susidns/src/images/save.png

2.52 KiB

apps/susidns/src/images/search.png

2.7 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="refresh" content="0;url=index.jsp" />
<title>susidns</title>
</head>
<body>
<a href="index.jsp">Enter</a>
</body>
</html>
\ No newline at end of file
/*
* Created on Sep 02, 2005
*
* This file is part of susidns project, see http://susi.i2p/
*
* Copyright (C) 2005 <susi23@mail.i2p>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Revision: 1.1 $
*/
package i2p.susi.dns;
public class AddressBean
{
private String name, destination;
public AddressBean()
{
}
public AddressBean(String name, String destination)
{
this.name = name;
this.destination = destination;
}
public String getDestination()
{
return destination;
}
public void setDestination(String destination)
{
this.destination = destination;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
}
/*
* Created on Sep 02, 2005
*
* This file is part of susidns project, see http://susi.i2p/
*
* Copyright (C) 2005 <susi23@mail.i2p>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Revision: 1.2 $
*/
package i2p.susi.dns;
import java.util.Comparator;
public class AddressByNameSorter implements Comparator
{
public int compare(Object arg0, Object arg1)
{
AddressBean a = (AddressBean)arg0;
AddressBean b = (AddressBean)arg1;
if( a == null )
return 1;
if( b == null )
return -1;
return a.getName().compareToIgnoreCase(b.getName());
}
}
/*
* Created on Sep 02, 2005
*
* This file is part of susidns project, see http://susi.i2p/
*
* Copyright (C) 2005 <susi23@mail.i2p>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Revision: 1.7 $
*/
package i2p.susi.dns;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Enumeration;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Properties;
public class AddressbookBean
{
private String book, action, serial, lastSerial, filter, search, hostname, destination;
private Properties properties, addressbook;
private int trClass;
private LinkedList deletionMarks;
private static Comparator sorter;
static {
sorter = new AddressByNameSorter();
}
public String getSearch() {
return search;
}
public void setSearch(String search) {
this.search = search;
}
public boolean isHasFilter()
{
return filter != null && filter.length() > 0;
}
public void setTrClass(int trClass) {
this.trClass = trClass;
}
public int getTrClass() {
trClass = 1 - trClass;
return trClass;
}
public boolean isIsEmpty()
{
return ! isNotEmpty();
}
public boolean isNotEmpty()
{
return addressbook != null && addressbook.size() > 0;
}
public AddressbookBean()
{
properties = new Properties();
deletionMarks = new LinkedList();
}
private long configLastLoaded = 0;
private void loadConfig()
{
long currentTime = System.currentTimeMillis();
if( properties.size() > 0 && currentTime - configLastLoaded < 10000 )
return;
try {
properties.clear();
properties.load( new FileInputStream( ConfigBean.configFileName ) );
configLastLoaded = currentTime;
}
catch (Exception e) {
Debug.debug( e.getClass().getName() + ": " + e.getMessage() );
}
}
public String getFileName()
{
loadConfig();
String filename = properties.getProperty( getBook() + "_addressbook" );
return ConfigBean.addressbookPrefix + filename;
}
private Object[] entries;
public Object[] getEntries()
{
return entries;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public String getBook()
{
if( book == null || ( book.compareToIgnoreCase( "master" ) != 0 &&
book.compareToIgnoreCase( "router" ) != 0 ) &&
book.compareToIgnoreCase( "published" ) != 0 )
book = "master";
return book;
}
public void setBook(String book) {
this.book = book;
}
public String getSerial() {
lastSerial = "" + Math.random();
action = null;
return lastSerial;
}
public void setSerial(String serial) {
this.serial = serial;
}
public String getMessages()
{
loadConfig();
String message = "";
if( action != null ) {
if( lastSerial != null && serial != null && serial.compareTo( lastSerial ) == 0 ) {
boolean changed = false;
if( action.compareToIgnoreCase( "add") == 0 ) {
if( addressbook != null && hostname != null && destination != null ) {
addressbook.put( hostname, destination );
changed = true;
message += "Destination added.<br/>";
}
}
if( action.compareToIgnoreCase( "delete" ) == 0 ) {
Iterator it = deletionMarks.iterator();
int deleted = 0;
while( it.hasNext() ) {
String name = (String)it.next();
addressbook.remove( name );
changed = true;
deleted++;
}
if( changed ) {
message += "" + deleted + " destination(s) deleted.<br/>";
}
}
if( changed ) {
try {
save();
message += "Addressbook saved.<br/>";
} catch (Exception e) {
Debug.debug( e.getClass().getName() + ": " + e.getMessage() );
message += "ERROR: Could not write addressbook file.<br/>";
}
}
}
else {
message += "Invalid nonce. Are you being spoofed?";
}
}
action = null;
addressbook = new Properties();
try {
addressbook.load( new FileInputStream( getFileName() ) );
LinkedList list = new LinkedList();
Enumeration e = addressbook.keys();
while( e.hasMoreElements() ) {
String name = (String)e.nextElement();
String destination = addressbook.getProperty( name );
if( filter != null && filter.length() > 0 ) {
if( filter.compareTo( "0-9" ) == 0 ) {
char first = name.charAt(0);
if( first < '0' || first > '9' )
continue;
}
else if( ! name.toLowerCase().startsWith( filter.toLowerCase() ) ) {
continue;
}
}
if( search != null && search.length() > 0 ) {
if( name.indexOf( search ) == -1 ) {
continue;
}
}
list.addLast( new AddressBean( name, destination ) );
}
Object array[] = list.toArray();
Arrays.sort( array, sorter );
entries = array;
}
catch (Exception e) {
Debug.debug( e.getClass().getName() + ": " + e.getMessage() );
}
if( message.length() > 0 )
message = "<p class=\"messages\">" + message + "</p>";
return message;
}
private void save() throws IOException
{
String filename = properties.getProperty( getBook() + "_addressbook" );
addressbook.store( new FileOutputStream( ConfigBean.addressbookPrefix + filename ), null );
}
public String getFilter() {
return filter;
}
public boolean isMaster()
{
return getBook().compareToIgnoreCase( "master" ) == 0;
}
public boolean isRouter()
{
return getBook().compareToIgnoreCase( "router" ) == 0;
}
public void setFilter(String filter) {
if( filter != null && ( filter.length() == 0 || filter.compareToIgnoreCase( "none" ) == 0 ) ) {
filter = null;
search = null;
}
this.filter = filter;
}
public String getDestination() {
return destination;
}
public void setDestination(String destination) {
this.destination = destination;
}
public String getHostname() {
return hostname;
}
public void setResetDeletionMarks( String dummy ) {
deletionMarks.clear();
}
public void setMarkedForDeletion( String name ) {
deletionMarks.addLast( name );
}
public void setHostname(String hostname) {
this.hostname = hostname;
}
}
/*
* Created on Sep 02, 2005
*
* This file is part of susidns project, see http://susi.i2p/
*
* Copyright (C) 2005 <susi23@mail.i2p>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Revision: 1.3 $
*/
package i2p.susi.dns;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Serializable;
public class ConfigBean implements Serializable {
/*
* as this is not provided as constant in addressbook, we define it here
*/
public static String addressbookPrefix = "addressbook/";
public static String configFileName = addressbookPrefix + "config.txt";
private String action, config;
private String serial, lastSerial;
private boolean saved;
public static String getConfigFileName() {
return configFileName;
}
public String getfileName() {
return getConfigFileName();
}
public boolean isSaved() {
return saved;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public String getConfig()
{
if( config != null )
return config;
reload();
return config;
}
private void reload()
{
File file = new File( configFileName );
if( file != null && file.isFile() ) {
StringBuffer buf = new StringBuffer();
try {
BufferedReader br = new BufferedReader( new FileReader( file ) );
String line;
while( ( line = br.readLine() ) != null ) {
buf.append( line );
buf.append( "\n" );
}
config = buf.toString();
saved = true;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
private void save()
{
File file = new File( configFileName );
try {
PrintWriter out = new PrintWriter( new FileOutputStream( file ) );
out.print( config );
out.flush();
out.close();
saved = true;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void setConfig(String config) {
this.config = config;
this.saved = false;
/*
* as this is a property file we need a newline at the end of the last line!
*/
if( ! this.config.endsWith( "\n" ) ) {
this.config += "\n";
}
}
public String getMessages() {
String message = "";
if( action != null ) {
if( lastSerial != null && serial != null && serial.compareTo( lastSerial ) == 0 ) {
if( action.compareToIgnoreCase( "save") == 0 ) {
save();
message = "Configuration saved.";
}
else if( action.compareToIgnoreCase( "reload") == 0 ) {
reload();
message = "Configuration reloaded.";
}
}
else {
message = "Invalid nonce. Are you being spoofed?";
}
}
if( message.length() > 0 )
message = "<p class=\"messages\">" + message + "</p>";
return message;
}
public String getSerial()
{
lastSerial = "" + Math.random();
action = null;
return lastSerial;
}
public void setSerial(String serial ) {
this.serial = serial;
}
}
/*
* Created on Sep 02, 2005
*
* This file is part of susidns project, see http://susi.i2p/
*
* Copyright (C) 2005 <susi23@mail.i2p>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Revision: 1.1 $
*/
package i2p.susi.dns;
import net.i2p.I2PAppContext;
import net.i2p.util.Log;
public class Debug
{
private static Log _log;
private static I2PAppContext _context;
static
{
try {
_context = I2PAppContext.getGlobalContext(); // new I2PAppContext();
_log = _context.logManager().getLog(Debug.class);
}
catch( NoClassDefFoundError e ) {
_context = null;
_log = null;
}
}
public static void debug( String msg )
{
if( _log != null ) {
_log.debug( msg );
}
else {
System.err.println( "DEBUG: [susidns] " + msg );
}
}
}
/*
* Created on Sep 02, 2005
*
* This file is part of susidns project, see http://susi.i2p/
*
* Copyright (C) 2005 <susi23@mail.i2p>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* $Revision: 1.3 $
*/
package i2p.susi.dns;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Properties;
public class SubscriptionsBean
{
private String action, fileName, content, serial, lastSerial;
private boolean saved;
Properties properties;
public SubscriptionsBean()
{
properties = new Properties();
}
private long configLastLoaded = 0;
private void loadConfig()
{
long currentTime = System.currentTimeMillis();
if( properties.size() > 0 && currentTime - configLastLoaded < 10000 )
return;
try {
properties.clear();
properties.load( new FileInputStream( ConfigBean.configFileName ) );
configLastLoaded = currentTime;
}
catch (Exception e) {
Debug.debug( e.getClass().getName() + ": " + e.getMessage() );
}
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public String getFileName()
{
loadConfig();
fileName = ConfigBean.addressbookPrefix + properties.getProperty( "subscriptions", "subscriptions.txt" );
return fileName;
}
private void reload()
{
File file = new File( getFileName() );
if( file != null && file.isFile() ) {
StringBuffer buf = new StringBuffer();
try {
BufferedReader br = new BufferedReader( new FileReader( file ) );
String line;
while( ( line = br.readLine() ) != null ) {
buf.append( line );
buf.append( "\n" );
}
content = buf.toString();
saved = true;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
private void save()
{
File file = new File( getFileName() );
try {
PrintWriter out = new PrintWriter( new FileOutputStream( file ) );
out.print( content );
out.flush();
out.close();
saved = true;
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public String getMessages() {
String message = "";
if( action != null ) {
if( lastSerial != null && serial != null && serial.compareTo( lastSerial ) == 0 ) {
if( action.compareToIgnoreCase( "save") == 0 ) {
save();
message = "Subscriptions saved.";
}
else if( action.compareToIgnoreCase( "reload") == 0 ) {
reload();
message = "Subscriptions reloaded.";
}
}
else {
message = "Invalid nonce. Are you being spoofed?";
}
}
if( message.length() > 0 )
message = "<p class=\"messages\">" + message + "</p>";
return message;
}
public String getSerial()
{
lastSerial = "" + Math.random();
action = null;
return lastSerial;
}
public void setSerial(String serial ) {
this.serial = serial;
}
public void setContent(String content) {
this.content = content;
this.saved = false;
/*
* as this is a property file we need a newline at the end of the last line!
*/
if( ! this.content.endsWith( "\n" ) ) {
this.content += "\n";
}
}
public String getContent()
{
if( content != null )
return content;
reload();
return content;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment