SF.net SVN: tuotoo: [6] trunk
Status: Pre-Alpha
Brought to you by:
hanru
|
From: <ha...@us...> - 2007-11-26 08:29:54
|
Revision: 6
http://tuotoo.svn.sourceforge.net/tuotoo/?rev=6&view=rev
Author: hanru
Date: 2007-11-26 00:29:55 -0800 (Mon, 26 Nov 2007)
Log Message:
-----------
some trivial changes.
Modified Paths:
--------------
trunk/src/org/tuotoo/logging/LogLevel.java
trunk/src/org/tuotoo/logging/LogType.java
trunk/src/org/tuotoo/tor/Config.java
trunk/src/org/tuotoo/tor/ordescription/ORDescriptor.java
trunk/src/org/tuotoo/tor/ordescription/ORList.java
trunk/src/org/tuotoo/tor/ordescription/PlainORListFetcher.java
trunk/test/org/tuotoo/tor/test/Proxy.java
Removed Paths:
-------------
trunk/src/org/tuotoo/logging/ChainedLog.java
Deleted: trunk/src/org/tuotoo/logging/ChainedLog.java
===================================================================
--- trunk/src/org/tuotoo/logging/ChainedLog.java 2007-11-24 08:28:46 UTC (rev 5)
+++ trunk/src/org/tuotoo/logging/ChainedLog.java 2007-11-26 08:29:55 UTC (rev 6)
@@ -1,57 +0,0 @@
-/*
- Copyright (c) 2000 - 2004, The JAP-Team
- All rights reserved.
- Redistribution and use in source and binary forms, with or without modification,
- are permitted provided that the following conditions are met:
-
- - Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation and/or
- other materials provided with the distribution.
-
- - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
- may be used to endorse or promote products derived from this software without specific
- prior written permission.
-
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS
- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
- IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
- */
-package org.tuotoo.logging;
-
-/** Writes log output to two Log instances */
-public class ChainedLog implements Log {
- Log m_Log1, m_Log2;
-
- public ChainedLog(Log log1, Log log2) {
- m_Log1 = log1;
- m_Log2 = log2;
- }
-
- public synchronized void log(int level, int type, String mesg) {
- m_Log1.log(level, type, mesg);
- m_Log2.log(level, type, mesg);
- }
-
- public void setLogType(int type) {
- }
-
- public int getLogType() {
- return LogType.ALL;
- }
-
- public void setLogLevel(int level) {
- }
-
- public int getLogLevel() {
- return LogLevel.DEBUG;
- }
-}
Modified: trunk/src/org/tuotoo/logging/LogLevel.java
===================================================================
--- trunk/src/org/tuotoo/logging/LogLevel.java 2007-11-24 08:28:46 UTC (rev 5)
+++ trunk/src/org/tuotoo/logging/LogLevel.java 2007-11-26 08:29:55 UTC (rev 6)
@@ -38,9 +38,7 @@
* Indicates level type of message: For instance to use when catching
* Exeption to output a debug message.
*/
- public final static int EXCEPTION = 2; // 2000-07-31(HF): CRIT zu EXCEPTION
- // geaendert, wegen besserem
- // Verstaendnis
+ public final static int EXCEPTION = 2;
/** Indicates level type of message: Error message */
public final static int ERR = 3;
@@ -61,7 +59,8 @@
public final static int DEBUG = 7;
public final static String STR_Levels[] = { "Emergency", "Alert ",
- "Exception", "Error ", "Warning ", "Notice ", "Info ",
- "Debug " };
+ "Exception", "Error ", "Warning ", "Notice ", "Info ",
+ "Debug "
+ };
}
Modified: trunk/src/org/tuotoo/logging/LogType.java
===================================================================
--- trunk/src/org/tuotoo/logging/LogType.java 2007-11-24 08:28:46 UTC (rev 5)
+++ trunk/src/org/tuotoo/logging/LogType.java 2007-11-26 08:29:55 UTC (rev 6)
@@ -43,8 +43,8 @@
* here, too.
*/
private static final String[] STR_LOG_TYPES = { "NUL", "GUI", "NET",
- "THREAD", "MISC", "PAY", "TOR", "CRYPTO", "FILTER", "AGREEMENT",
- "ALL" };
+ "THREAD", "MISC", "PAY", "TOR", "CRYPTO", "FILTER", "ALL"
+ };
/** The concatenation string of the human readable log types. */
private static final String STR_ADD_LOG_TYPE = "+";
@@ -66,15 +66,15 @@
/** Indicates a misc message (binary: <code>00001000</code>) */
public static final int MISC = LOG_TYPES[4];
- /** Indicates a pay message (binary: <code>00001000</code>) */
+ /** Indicates a pay message (binary: <code>00010000</code>) */
public static final int PAY = LOG_TYPES[5];
- /** Indicates a TOR message (binary: <code>00010000</code>) */
+ /** Indicates a TOR message (binary: <code>00100000</code>) */
public static final int TOR = LOG_TYPES[6];
/**
* Indicates a message related to cryptographic operations (binary:
- * <code>00100000</code>)
+ * <code>01000000</code>)
*/
public static final int CRYPTO = LOG_TYPES[7];
@@ -84,9 +84,6 @@
/** Indicates messages from the http filter system */
public static final int FILTER = LOG_TYPES[8];
- /** Indicates messages from the paw filter system */
- public static final int AGREEMENT = LOG_TYPES[9];
-
/** Indicates all messages */
public static final int ALL = createLogTypeALL();
Modified: trunk/src/org/tuotoo/tor/Config.java
===================================================================
--- trunk/src/org/tuotoo/tor/Config.java 2007-11-24 08:28:46 UTC (rev 5)
+++ trunk/src/org/tuotoo/tor/Config.java 2007-11-26 08:29:55 UTC (rev 6)
@@ -36,6 +36,7 @@
// initialize default properties
defProps.setProperty("proxy.SocksPort", "9150");
+ defProps.setProperty("data.Directory", getDefaultDataDir());
// ...
m_props = new Properties(defProps);
@@ -96,4 +97,10 @@
return System.getProperty("user.home")
+ System.getProperty("file.separator") + "tuotoo.conf";
}
+
+ private static String getDefaultDataDir() {
+ return System.getProperty("user.home")
+ + System.getProperty("file.separator") + ".tuotoo"
+ + System.getProperty("file.separator");
+ }
}
Modified: trunk/src/org/tuotoo/tor/ordescription/ORDescriptor.java
===================================================================
--- trunk/src/org/tuotoo/tor/ordescription/ORDescriptor.java 2007-11-24 08:28:46 UTC (rev 5)
+++ trunk/src/org/tuotoo/tor/ordescription/ORDescriptor.java 2007-11-26 08:29:55 UTC (rev 6)
@@ -291,8 +291,7 @@
ORDescriptor or = (ORDescriptor) onionrouter;
if (m_address.equals(or.getAddress())
- && m_name.equals(or.getName())
- && (m_port == or.getPort())) {
+ && m_name.equals(or.getName()) && (m_port == or.getPort())) {
return true;
}
// routers in the same family are also equal
@@ -457,7 +456,7 @@
ORDescriptor ord = new ORDescriptor(adr, nickname,
Integer.parseInt(orport), strSoftware);
if (!ord.setOnionKey(key)
- || !ord.setSigningKey(signingkey)) {
+ || !ord.setSigningKey(signingkey)) {
return null;
}
ord.setAcl(acl);
@@ -487,8 +486,8 @@
public String toString() {
return "ORRouter: " + this.m_name + " on " + this.m_address + ":"
- + this.m_port + " Software : " + this.m_strSoftware
- + " isExitNode:" + this.m_bIsExitNode;
+ + this.m_port + " Software : " + this.m_strSoftware
+ + " isExitNode:" + this.m_bIsExitNode;
}
private static String calcHash(String desc) {
Modified: trunk/src/org/tuotoo/tor/ordescription/ORList.java
===================================================================
--- trunk/src/org/tuotoo/tor/ordescription/ORList.java 2007-11-24 08:28:46 UTC (rev 5)
+++ trunk/src/org/tuotoo/tor/ordescription/ORList.java 2007-11-26 08:29:55 UTC (rev 6)
@@ -100,7 +100,7 @@
}
/**
- * Updates the list of available ORRouters.
+ * Updates the list of available OR Routers.
*
* @return true if it was ok, false otherwise
*/
@@ -108,12 +108,8 @@
try {
byte[] buff = null;
if (size() == 0
- || (buff = m_orlistFetcher.getRouterStatus()) == null)// either
- // first
- // time
- // list
- // retrival
- // or
+ || (buff = m_orlistFetcher.getRouterStatus()) == null)
+ // either first time list retrival or
// getting information for differential update failed
{
buff = m_orlistFetcher.getAllDescriptors();
@@ -397,8 +393,8 @@
String digest = Base16.encode((Base64.decode(hashDescriptor)));
if ((ord == null)
- || ((ord.getHash() == null) || (!digest.equals(ord
- .getHash())))) {
+ || ((ord.getHash() == null) || (!digest.equals(ord
+ .getHash())))) {
b = m_orlistFetcher.getDescriptor(digest);
if (b != null) {
if (ord != null && ord.getHibernate()) {
@@ -436,8 +432,8 @@
LineNumberReader reader = new LineNumberReader(new InputStreamReader(
new ByteArrayInputStream(document)));
Date published = new Date();// workaround for a while until we are able
- // to get the real published date of the tor
- // list
+ // to get the real published date of the tor
+ // list
reader.mark(200);
String curLine = reader.readLine();
@@ -472,8 +468,9 @@
}
LogHolder.log(LogLevel.DEBUG, LogType.TOR, "Exit Nodes : "
- + m_exitnodes.size() + " Non-Exit Nodes : "
- + m_middlenodes.size());
+ + m_exitnodes.size()
+ + " Non-Exit Nodes : "
+ + m_middlenodes.size());
m_datePublished = published;
return true;
Modified: trunk/src/org/tuotoo/tor/ordescription/PlainORListFetcher.java
===================================================================
--- trunk/src/org/tuotoo/tor/ordescription/PlainORListFetcher.java 2007-11-24 08:28:46 UTC (rev 5)
+++ trunk/src/org/tuotoo/tor/ordescription/PlainORListFetcher.java 2007-11-26 08:29:55 UTC (rev 6)
@@ -85,8 +85,8 @@
*/
private byte[] getDocument(String path) {
try {
- LogHolder.log(LogLevel.DEBUG, LogType.TOR, "fetching " + path
- + " from directory server");
+ LogHolder.log(LogLevel.DEBUG, LogType.TOR,
+ "fetching " + path + " from directory server");
HTTPConnection http = new HTTPConnection(m_ORListServer,
m_ORListPort);
HTTPResponse resp = http.Get(path);
@@ -101,8 +101,9 @@
return null;
return doc;
} catch (Throwable t) {
- LogHolder.log(LogLevel.DEBUG, LogType.TOR, "error while fetching "
- + path + " from directory server: " + t.getMessage());
+ LogHolder.log(LogLevel.DEBUG, LogType.TOR,
+ "error while fetching " + path + " from directory server: "
+ + t.getMessage());
return null;
}
}
Modified: trunk/test/org/tuotoo/tor/test/Proxy.java
===================================================================
--- trunk/test/org/tuotoo/tor/test/Proxy.java 2007-11-24 08:28:46 UTC (rev 5)
+++ trunk/test/org/tuotoo/tor/test/Proxy.java 2007-11-26 08:29:55 UTC (rev 6)
@@ -28,6 +28,11 @@
private static Tor tor;
public Proxy() {
+ SystemErrLog log = new SystemErrLog();
+ log.setLogType(LogType.TOR);
+ log.setLogLevel(LogLevel.DEBUG);
+ LogHolder.setLogInstance(log);
+
tor = Tor.getInstance();
tor.initialize(new TorAnonServerDescription(), null);
port = 9150;
@@ -38,11 +43,6 @@
new Proxy();
try {
- SystemErrLog log = new SystemErrLog();
- log.setLogType(LogType.TOR);
- log.setLogLevel(LogLevel.EMERG);
- LogHolder.setLogInstance(new SystemErrLog());
-
ServerSocket ss = new ServerSocket(port);
while (true) {
Socket s = ss.accept();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|