[or-cvs] fix most torctl issues; move rest into TODO
Nick Mathewson
nickm at seul.org
Thu Jul 14 20:26:13 UTC 2005
Update of /home/or/cvsroot/control/java/net/freehaven/tor/control
In directory moria:/tmp/cvs-serv6984/java/net/freehaven/tor/control
Modified Files:
TorControlConnection.java TorControlConnection0.java
TorControlConnection1.java
Added Files:
ConfigEntry.java
Log Message:
fix most torctl issues; move rest into TODO
--- NEW FILE: ConfigEntry.java ---
// $Id: ConfigEntry.java,v 1.1 2005/07/14 20:26:11 nickm Exp $
// Copyright 2005 Nick Mathewson, Roger Dingledine
// See LICENSE file for copying information
package net.freehaven.tor.control;
/** A single key-value pair from Tor's configuration. */
public class ConfigEntry {
public ConfigEntry(String k, String v) {
key = k;
value = v;
}
public final String key;
public final String value;
}
Index: TorControlConnection.java
===================================================================
RCS file: /home/or/cvsroot/control/java/net/freehaven/tor/control/TorControlConnection.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- TorControlConnection.java 11 Jul 2005 19:14:18 -0000 1.5
+++ TorControlConnection.java 14 Jul 2005 20:26:11 -0000 1.6
@@ -15,6 +15,12 @@
/** A connection to a running Tor process. */
public abstract class TorControlConnection// implements TorControlCommands {
{
+ public static class ConfigEntry {
+ public ConfigEntry(String k, String v) { key = k; value = v; }
+ public final String key;
+ public final String value;
+ }
+
protected EventHandler handler;
protected LinkedList waiters;
@@ -137,15 +143,14 @@
public abstract void setConf(Collection kvList) throws IOException;
/** Return the value of the configuration option 'key' */
- public String getConf(String key) throws IOException {
+ public List getConf(String key) throws IOException {
List lst = new ArrayList();
lst.add(key);
- Map r = getConf(lst);
- return (String) r.get(key);
+ return getConf(lst);
}
/** Return a key-value map for the configuration options in 'keys' */
- public abstract Map getConf(Collection keys) throws IOException;
+ public abstract List getConf(Collection keys) throws IOException;
/** Tell Tor to begin sending us events of the types listed in 'events'.
* Elements must be one of the EVENT_* values from TorControlCommands */
Index: TorControlConnection0.java
===================================================================
RCS file: /home/or/cvsroot/control/java/net/freehaven/tor/control/TorControlConnection0.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- TorControlConnection0.java 11 Jul 2005 19:14:18 -0000 1.4
+++ TorControlConnection0.java 14 Jul 2005 20:26:11 -0000 1.5
@@ -249,7 +249,7 @@
sendAndWaitForResponse(CMD_SETCONF, b.toString().getBytes());
}
- public Map getConf(Collection keys) throws IOException {
+ public List getConf(Collection keys) throws IOException {
StringBuffer s = new StringBuffer();
for (Iterator it = keys.iterator(); it.hasNext(); ) {
String key = (String) it.next();
@@ -259,12 +259,12 @@
CMD_CONFVALUE);
List lines = new ArrayList();
Bytes.splitStr(lines, c.body, 0, (byte)'\n');
- Map result = new HashMap();
+ List result = new ArrayList();
for (Iterator it = lines.iterator(); it.hasNext(); ) {
String kv = (String) it.next();
int idx = kv.indexOf(' ');
- result.put(kv.substring(0, idx),
- kv.substring(idx+1));
+ result.add(new ConfigEntry(kv.substring(0, idx),
+ kv.substring(idx+1)));
}
return result;
}
Index: TorControlConnection1.java
===================================================================
RCS file: /home/or/cvsroot/control/java/net/freehaven/tor/control/TorControlConnection1.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- TorControlConnection1.java 11 Jul 2005 19:14:18 -0000 1.3
+++ TorControlConnection1.java 14 Jul 2005 20:26:11 -0000 1.4
@@ -218,7 +218,7 @@
sendAndWaitForResponse(b.toString(), null);
}
- public Map getConf(Collection keys) throws IOException {
+ public List getConf(Collection keys) throws IOException {
StringBuffer sb = new StringBuffer("GETCONF");
for (Iterator it = keys.iterator(); it.hasNext(); ) {
String key = (String) it.next();
@@ -226,12 +226,12 @@
}
sb.append("\r\n");
ArrayList lst = sendAndWaitForResponse(sb.toString(), null);
- Map result = new HashMap();
+ ArrayList result = new ArrayList();
for (Iterator it = lst.iterator(); it.hasNext(); ) {
String kv = ((ReplyLine) it.next()).msg;
int idx = kv.indexOf('=');
- result.put(kv.substring(0, idx),
- kv.substring(idx+1));
+ result.add(new ConfigEntry(kv.substring(0, idx),
+ kv.substring(idx+1)));
}
return result;
}
More information about the tor-commits
mailing list