Skip to content
Snippets Groups Projects
jtorctl.patch 68.3 KiB
Newer Older
diff -Bbur jtorctl/net/freehaven/tor/control/Bytes.java jtorctl-briar/net/freehaven/tor/control/Bytes.java
--- jtorctl/net/freehaven/tor/control/Bytes.java	2013-04-24 16:46:08.000000000 +0100
+++ jtorctl-briar/net/freehaven/tor/control/Bytes.java	2013-05-16 19:56:30.000000000 +0100
@@ -16,46 +16,43 @@
     /** Write the two-byte value in 's' into the byte array 'ba', starting at
      * the index 'pos'. */
     public static void setU16(byte[] ba, int pos, short s) {
-        ba[pos]   = (byte)((s >> 8) & 0xff);
-        ba[pos+1] = (byte)((s     ) & 0xff);
+		ba[pos] = (byte) ((s >> 8) & 0xff);
+		ba[pos + 1] = (byte) (s & 0xff);
     }
 
     /** Write the four-byte value in 'i' into the byte array 'ba', starting at
      * the index 'pos'. */
     public static void setU32(byte[] ba, int pos, int i) {
-        ba[pos]   = (byte)((i >> 24) & 0xff);
-        ba[pos+1] = (byte)((i >> 16) & 0xff);
-        ba[pos+2] = (byte)((i >>  8) & 0xff);
-        ba[pos+3] = (byte)((i      ) & 0xff);
+		ba[pos] = (byte) ((i >> 24) & 0xff);
+		ba[pos + 1] = (byte) ((i >> 16) & 0xff);
+		ba[pos + 2] = (byte) ((i >>  8) & 0xff);
+		ba[pos + 3] = (byte) (i & 0xff);
     }
 
     /** Return the four-byte value starting at index 'pos' within 'ba' */
     public static int getU32(byte[] ba, int pos) {
-        return
-            ((ba[pos  ]&0xff)<<24) |
-            ((ba[pos+1]&0xff)<<16) |
-            ((ba[pos+2]&0xff)<< 8)  |
-            ((ba[pos+3]&0xff));
+		return ((ba[pos] & 0xff) << 24) |
+				((ba[pos + 1] & 0xff) << 16) |
+				((ba[pos + 2] & 0xff) << 8)  |
+				((ba[pos + 3] & 0xff));
     }
 
     public static String getU32S(byte[] ba, int pos) {
-        return String.valueOf( (getU32(ba,pos))&0xffffffffL );
+		return String.valueOf((getU32(ba, pos)) & 0xffffffffL);
     }
 
     /** Return the two-byte value starting at index 'pos' within 'ba' */
     public static int getU16(byte[] ba, int pos) {
-        return
-            ((ba[pos  ]&0xff)<<8) |
-            ((ba[pos+1]&0xff));
+		return ((ba[pos] & 0xff) << 8) |
+				((ba[pos + 1] & 0xff));
     }
 
     /** Return the string starting at position 'pos' of ba and extending
      * until a zero byte or the end of the string. */
     public static String getNulTerminatedStr(byte[] ba, int pos) {
-        int len, maxlen = ba.length-pos;
-        for (len=0; len<maxlen; ++len) {
-            if (ba[pos+len] == 0)
-                break;
+		int len, maxlen = ba.length - pos;
+		for(len = 0; len < maxlen; ++len) {
+			if(ba[pos + len] == 0) break;
         }
         return new String(ba, pos, len);
     }
@@ -64,18 +61,16 @@
      * Read bytes from 'ba' starting at 'pos', dividing them into strings
      * along the character in 'split' and writing them into 'lst'
      */
-    public static void splitStr(List<String> lst, byte[] ba, int pos, byte split) {
-        while (pos < ba.length && ba[pos] != 0) {
+	public static void splitStr(List<String> lst, byte[] ba, int pos,
+			byte split) {
+		while(pos < ba.length && ba[pos] != 0) {
             int len;
-            for (len=0; pos+len < ba.length; ++len) {
-                if (ba[pos+len] == 0 || ba[pos+len] == split)
-                    break;
+			for(len = 0; pos + len < ba.length; ++len) {
+				if(ba[pos + len] == 0 || ba[pos + len] == split) break;
             }
-            if (len>0)
-                lst.add(new String(ba, pos, len));
+			if(len > 0) lst.add(new String(ba, pos, len));
             pos += len;
-            if (ba[pos] == split)
-                ++pos;
+			if(ba[pos] == split) ++pos;
         }
     }
 
@@ -86,11 +81,8 @@
     public static List<String> splitStr(List<String> lst, String str) {
         // split string on spaces, include trailing/leading
         String[] tokenArray = str.split(" ", -1);
-        if (lst == null) {
-            lst = Arrays.asList( tokenArray );
-        } else {
-            lst.addAll( Arrays.asList( tokenArray ) );
-        }
+		if(lst == null) lst = Arrays.asList(tokenArray);
+		else lst.addAll(Arrays.asList(tokenArray));
         return lst;
     }
 
@@ -101,10 +93,10 @@
 
     public static final String hex(byte[] ba) {
         StringBuffer buf = new StringBuffer();
-        for (int i = 0; i < ba.length; ++i) {
-            int b = (ba[i]) & 0xff;
+		for(int i = 0; i < ba.length; ++i) {
+			int b = ba[i] & 0xff;
             buf.append(NYBBLES[b >> 4]);
-            buf.append(NYBBLES[b&0x0f]);
+			buf.append(NYBBLES[b & 0x0f]);
         }
         return buf.toString();
     }
diff -Bbur jtorctl/net/freehaven/tor/control/ConfigEntry.java jtorctl-briar/net/freehaven/tor/control/ConfigEntry.java
--- jtorctl/net/freehaven/tor/control/ConfigEntry.java	2013-04-24 16:46:08.000000000 +0100
+++ jtorctl-briar/net/freehaven/tor/control/ConfigEntry.java	2013-05-16 19:56:30.000000000 +0100
@@ -4,6 +4,11 @@
 
 /** A single key-value pair from Tor's configuration. */
 public class ConfigEntry {
+
+	public final String key;
+	public final String value;
+	public final boolean is_default;
+
     public ConfigEntry(String k, String v) {
         key = k;
         value = v;
@@ -14,7 +20,4 @@
         value = "";
         is_default = true;
     }
-    public final String key;
-    public final String value;
-    public final boolean is_default;
 }
diff -Bbur jtorctl/net/freehaven/tor/control/EventHandler.java jtorctl-briar/net/freehaven/tor/control/EventHandler.java
--- jtorctl/net/freehaven/tor/control/EventHandler.java	2013-04-24 16:46:08.000000000 +0100
+++ jtorctl-briar/net/freehaven/tor/control/EventHandler.java	2013-05-16 19:56:30.000000000 +0100
@@ -9,9 +9,10 @@
  * @see TorControlConnection#setEvents
  */
 public interface EventHandler {
+
     /**
-     * Invoked when a circuit's status has changed.
-     * Possible values for <b>status</b> are:
+	 * Invoked when a circuit's status has changed.  Possible values for
+	 * <b>status</b> are:
      * <ul>
      *   <li>"LAUNCHED" :  circuit ID assigned to new circuit</li>
      *   <li>"BUILT"    :  all hops finished, can now accept streams</li>
@@ -19,7 +20,6 @@
      *   <li>"FAILED"   :  circuit closed (was not built)</li>
      *   <li>"CLOSED"   :  circuit closed (was built)</li>
      *	</ul>
-     * 
      * <b>circID</b> is the alphanumeric identifier of the affected circuit,
      * and <b>path</b> is a comma-separated list of alphanumeric ServerIDs.
      */
@@ -24,9 +24,10 @@
      * and <b>path</b> is a comma-separated list of alphanumeric ServerIDs.
      */
     public void circuitStatus(String status, String circID, String path);
+
     /**
-     * Invoked when a stream's status has changed.
-     * Possible values for <b>status</b> are:
+	 * Invoked when a stream's status has changed.  Possible values for
+	 * <b>status</b> are:
      * <ul>
      *   <li>"NEW"         :  New request to connect</li>
      *   <li>"NEWRESOLVE"  :  New request to resolve an address</li>
@@ -37,7 +38,6 @@
      *   <li>"CLOSED"      :  Stream closed</li>
      *   <li>"DETACHED"    :  Detached from circuit; still retriable.</li>
      *	</ul>
-     *
      * <b>streamID</b> is the alphanumeric identifier of the affected stream,
      * and its <b>target</b> is specified as address:port.
      */
@@ -42,18 +42,21 @@
      * and its <b>target</b> is specified as address:port.
      */
     public void streamStatus(String status, String streamID, String target);
+
     /**
-     * Invoked when the status of a connection to an OR has changed.
-     * Possible values for <b>status</b> are ["LAUNCHED" | "CONNECTED" | "FAILED" | "CLOSED"].
-     * <b>orName</b> is the alphanumeric identifier of the OR affected.
+	 * Invoked when the status of a connection to an OR has changed.  Possible
+	 * values for <b>status</b> are ["LAUNCHED" | "CONNECTED" | "FAILED" |
+	 * "CLOSED"]. <b>orName</b> is the alphanumeric identifier of the OR
Loading
Loading full blame...