Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
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...