Skip to content
Snippets Groups Projects
Verified Commit 64f9ce73 authored by akwizgran's avatar akwizgran
Browse files

Remove unused patches.

parent 39478a79
No related branches found
No related tags found
No related merge requests found
briar-desktop/libs/jnotify-0.94.jar is built via:
$ wget "http://downloads.sourceforge.net/project/jnotify/jnotify/jnotify-0.94/jnotify-lib-0.94.zip?r=&ts=$(date +%s)"
$ unzip -d jnotify-lib-0.94 jnotify-lib-0.94.zip && cd jnotify-lib-0.94
$ unzip -d src jnotify-0.94-src.zip
$ wget -O build.xml "http://jnotify.cvs.sourceforge.net/viewvc/jnotify/jnotify/build.xml?revision=1.7&pathrev=HEAD"
$ wget -O build.properties "http://jnotify.cvs.sourceforge.net/viewvc/jnotify/jnotify/build.properties?revision=1.13"
$ patch -lp1 < /path/to/this/patch
$ ant build_java # if this fails with invalid flag: -g:{lines,vars,source}, try removing the debug attributes from <javac>
diff -ru jnotify-0.94/net/contentobjects/jnotify/linux/JNotify_linux.java jnotify-0.94-briar/net/contentobjects/jnotify/linux/JNotify_linux.java
--- jnotify-0.94/net/contentobjects/jnotify/linux/JNotify_linux.java 2012-04-25 00:03:54.000000000 +0100
+++ jnotify-0.94-briar/net/contentobjects/jnotify/linux/JNotify_linux.java 2014-01-30 12:31:41.959082350 +0000
@@ -37,6 +37,7 @@
package net.contentobjects.jnotify.linux;
import net.contentobjects.jnotify.JNotifyException;
+import net.contentobjects.jnotify.Util;
public class JNotify_linux
{
@@ -45,7 +46,7 @@
static
{
- System.loadLibrary("jnotify");
+ Util.loadNative();
int res = nativeInit();
if (res != 0)
{
diff -ru jnotify-0.94/net/contentobjects/jnotify/macosx/JNotify_macosx.java jnotify-0.94-briar/net/contentobjects/jnotify/macosx/JNotify_macosx.java
--- jnotify-0.94/net/contentobjects/jnotify/macosx/JNotify_macosx.java 2010-01-26 19:43:42.000000000 +0000
+++ jnotify-0.94-briar/net/contentobjects/jnotify/macosx/JNotify_macosx.java 2014-01-30 12:31:41.959082350 +0000
@@ -1,6 +1,7 @@
package net.contentobjects.jnotify.macosx;
import net.contentobjects.jnotify.JNotifyException;
+import net.contentobjects.jnotify.Util;
public class JNotify_macosx
{
@@ -10,7 +11,7 @@
static
{
- System.loadLibrary("jnotify"); //$NON-NLS-1$
+ Util.loadNative();
Thread thread = new Thread("FSEvent thread") //$NON-NLS-1$
{
public void run()
diff -ru jnotify-0.94/net/contentobjects/jnotify/Util.java jnotify-0.94-briar/net/contentobjects/jnotify/Util.java
--- jnotify-0.94/net/contentobjects/jnotify/Util.java 2006-02-14 08:18:10.000000000 +0000
+++ jnotify-0.94-briar/net/contentobjects/jnotify/Util.java 2014-01-30 12:31:41.959082350 +0000
@@ -30,4 +30,26 @@
return "UNKNOWN";
}
}
+
+ public static void loadNative() throws UnsatisfiedLinkError {
+ try
+ {
+ try
+ {
+ System.loadLibrary("jnotify");
+ }
+ catch (UnsatisfiedLinkError e) {
+ System.loadLibrary("jnotify-" + System.getProperty("os.arch"));
+ }
+ }
+ catch (UnsatisfiedLinkError e)
+ {
+ // add some extra debugging info
+ String msg = "Error loading library, os.arch=" + System.getProperty("os.arch") +
+ ", java.library.path=" + System.getProperty("java.library.path");
+ UnsatisfiedLinkError e2 = new UnsatisfiedLinkError(msg);
+ e2.initCause(e);
+ throw e2;
+ }
+ }
}
diff -ru jnotify-0.94/net/contentobjects/jnotify/win32/JNotify_win32.java jnotify-0.94-briar/net/contentobjects/jnotify/win32/JNotify_win32.java
--- jnotify-0.94/net/contentobjects/jnotify/win32/JNotify_win32.java 2012-04-25 00:04:50.000000000 +0100
+++ jnotify-0.94-briar/net/contentobjects/jnotify/win32/JNotify_win32.java 2014-01-30 12:31:41.959082350 +0000
@@ -39,28 +39,13 @@
package net.contentobjects.jnotify.win32;
import net.contentobjects.jnotify.JNotifyException;
-
+import net.contentobjects.jnotify.Util;
public class JNotify_win32
{
static
{
- try
- {
- if (System.getProperty("os.arch").equals("amd64"))
- {
- System.loadLibrary("jnotify_64bit");
- }
- else
- {
- System.loadLibrary("jnotify");
- }
- }
- catch (UnsatisfiedLinkError e)
- {
- System.err.println("Error loading library, java.library.path=" + System.getProperty("java.library.path"));
- throw e;
- }
+ Util.loadNative();
int res = nativeInit();
if (res != 0)
{
diff --git a/README.md b/README.md
index 902d727..359cc69 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,4 @@
-
A Java library for controlling a Tor instance via its control port. It is
used in the Android app Orbot as well as others.
-To add this library to a gradle project:
-
- compile 'net.freehaven.tor.control:jtorctl:0.2'
+This fork includes patches for managing onion services.
diff --git a/net/freehaven/tor/control/TorControlCommands.java b/net/freehaven/tor/control/TorControlCommands.java
index 36482d5..14486e3 100644
--- a/net/freehaven/tor/control/TorControlCommands.java
+++ b/net/freehaven/tor/control/TorControlCommands.java
@@ -144,5 +144,8 @@ public interface TorControlCommands {
"No such OR",
};
+ public static final String HS_ADDRESS = "onionAddress";
+ public static final String HS_PRIVKEY = "onionPrivKey";
+
}
diff --git a/net/freehaven/tor/control/TorControlConnection.java b/net/freehaven/tor/control/TorControlConnection.java
index 9524612..eacdd66 100644
--- a/net/freehaven/tor/control/TorControlConnection.java
+++ b/net/freehaven/tor/control/TorControlConnection.java
@@ -40,10 +40,14 @@ public class TorControlConnection implements TorControlCommands {
static class Waiter {
List<ReplyLine> response; // Locking: this
+ boolean interrupted;
synchronized List<ReplyLine> getResponse() throws InterruptedException {
while (response == null) {
wait();
+ if (interrupted) {
+ throw new InterruptedException();
+ }
}
return response;
}
@@ -52,6 +56,11 @@ public class TorControlConnection implements TorControlCommands {
this.response = response;
notifyAll();
}
+
+ synchronized void interrupt() {
+ interrupted = true;
+ notifyAll();
+ }
}
static class ReplyLine {
@@ -171,7 +180,7 @@ public class TorControlConnection implements TorControlCommands {
protected synchronized List<ReplyLine> sendAndWaitForResponse(String s,
String rest) throws IOException {
- if(parseThreadException != null) throw parseThreadException;
+ if (parseThreadException != null) throw parseThreadException;
checkThread();
Waiter w = new Waiter();
if (debugOutput != null)
@@ -305,8 +314,15 @@ public class TorControlConnection implements TorControlCommands {
while (true) {
ArrayList<ReplyLine> lst = readReply();
if (lst.isEmpty()) {
- // connection has been closed remotely! end the loop!
- return;
+ // interrupted queued waiters, there won't be any response.
+ synchronized (waiters) {
+ if (!waiters.isEmpty()) {
+ for (Waiter w : waiters) {
+ w.interrupt();
+ }
+ }
+ }
+ throw new IOException("Tor is no longer running");
}
if ((lst.get(0)).status.startsWith("6"))
handleEvent(lst);
@@ -736,11 +752,111 @@ public class TorControlConnection implements TorControlCommands {
sendAndWaitForResponse("TAKEOWNERSHIP\r\n", null);
}
+ /**
+ * Tells Tor to generate and set up a new onion service using the best
+ * supported algorithm.
+ * <p/>
+ * ADD_ONION was added in Tor 0.2.7.1-alpha.
+ */
+ public Map<String,String> addOnion(Map<Integer,String> portLines)
+ throws IOException {
+ return addOnion("NEW:BEST", portLines, null);
+ }
+
+ /**
+ * Tells Tor to generate and set up a new onion service using the best
+ * supported algorithm.
+ * <p/>
+ * ADD_ONION was added in Tor 0.2.7.1-alpha.
+ */
+ public Map<String,String> addOnion(Map<Integer,String> portLines,
+ boolean ephemeral, boolean detach)
+ throws IOException {
+ return addOnion("NEW:BEST", portLines, ephemeral, detach);
+ }
+
+ /**
+ * Tells Tor to set up an onion service using the provided private key.
+ * <p/>
+ * ADD_ONION was added in Tor 0.2.7.1-alpha.
+ */
+ public Map<String,String> addOnion(String privKey,
+ Map<Integer,String> portLines)
+ throws IOException {
+ return addOnion(privKey, portLines, null);
+ }
+
+ /**
+ * Tells Tor to set up an onion service using the provided private key.
+ * <p/>
+ * ADD_ONION was added in Tor 0.2.7.1-alpha.
+ */
+ public Map<String,String> addOnion(String privKey,
+ Map<Integer,String> portLines,
+ boolean ephemeral, boolean detach)
+ throws IOException {
+ List<String> flags = new ArrayList<String>();
+ if (ephemeral)
+ flags.add("DiscardPK");
+ if (detach)
+ flags.add("Detach");
+ return addOnion(privKey, portLines, flags);
+ }
+
+ /**
+ * Tells Tor to set up an onion service.
+ * <p/>
+ * ADD_ONION was added in Tor 0.2.7.1-alpha.
+ */
+ public Map<String,String> addOnion(String privKey,
+ Map<Integer,String> portLines,
+ List<String> flags)
+ throws IOException {
+ if (privKey.indexOf(':') < 0)
+ throw new IllegalArgumentException("Invalid privKey");
+ if (portLines == null || portLines.size() < 1)
+ throw new IllegalArgumentException("Must provide at least one port line");
+ StringBuilder b = new StringBuilder();
+ b.append("ADD_ONION ").append(privKey);
+ if (flags != null && flags.size() > 0) {
+ b.append(" Flags=");
+ String separator = "";
+ for (String flag : flags) {
+ b.append(separator).append(flag);
+ separator = ",";
+ }
+ }
+ for (Map.Entry<Integer,String> portLine : portLines.entrySet()) {
+ int virtPort = portLine.getKey();
+ String target = portLine.getValue();
+ b.append(" Port=").append(virtPort);
+ if (target != null && target.length() > 0)
+ b.append(",").append(target);
+ }
+ b.append("\r\n");
+ List<ReplyLine> lst = sendAndWaitForResponse(b.toString(), null);
+ Map<String,String> ret = new HashMap<String,String>();
+ ret.put(HS_ADDRESS, (lst.get(0)).msg.split("=", 2)[1]);
+ if (lst.size() > 2)
+ ret.put(HS_PRIVKEY, (lst.get(1)).msg.split("=", 2)[1]);
+ return ret;
+ }
+
+ /**
+ * Tells Tor to take down an onion service previously set up with
+ * addOnion(). The hostname excludes the .onion extension.
+ * <p/>
+ * DEL_ONION was added in Tor 0.2.7.1-alpha.
+ */
+ public void delOnion(String hostname) throws IOException {
+ sendAndWaitForResponse("DEL_ONION " + hostname + "\r\n", null);
+ }
+
/** Tells Tor to forget any cached client state relating to the hidden
* service with the given hostname (excluding the .onion extension).
*/
public void forgetHiddenService(String hostname) throws IOException {
- sendAndWaitForResponse("FORGETHS " + hostname + "\r\n", null);
+ sendAndWaitForResponse("HSFORGET " + hostname + "\r\n", null);
}
}
diff --git a/src/or/control.c b/src/or/control.c
index c8c5062..f38ba23 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -196,6 +196,8 @@ static int handle_control_hsfetch(control_connection_t *conn, uint32_t len,
const char *body);
static int handle_control_hspost(control_connection_t *conn, uint32_t len,
const char *body);
+static int handle_control_hsforget(control_connection_t *conn, uint32_t len,
+ const char *body);
static int handle_control_add_onion(control_connection_t *conn, uint32_t len,
const char *body);
static int handle_control_del_onion(control_connection_t *conn, uint32_t len,
@@ -4246,6 +4248,33 @@ handle_control_hspost(control_connection_t *conn,
return 0;
}
+/** Called when we get an HSFORGET command: parse the hidden service's onion
+ * address and purge any cached state related to the service. */
+static int
+handle_control_hsforget(control_connection_t *conn, uint32_t len,
+ const char *body)
+{
+ smartlist_t *args;
+ char *onion_address;
+
+ args = getargs_helper("HSFORGET", conn, body, 1, 1);
+ if (!args)
+ return -1;
+ onion_address = smartlist_get(args, 0);
+ smartlist_free(args);
+
+ if (!rend_valid_service_id(onion_address)) {
+ connection_write_str_to_buf("513 Invalid hidden service address\r\n", conn);
+ tor_free(onion_address);
+ return -1;
+ }
+
+ rend_client_purge_hidden_service(onion_address);
+ tor_free(onion_address);
+ send_control_done(conn);
+ return 0;
+}
+
/** Called when we get a ADD_ONION command; parse the body, and set up
* the new ephemeral Onion Service. */
static int
@@ -5065,6 +5094,9 @@ connection_control_process_inbuf(control_connection_t *conn)
} else if (!strcasecmp(conn->incoming_cmd, "+HSPOST")) {
if (handle_control_hspost(conn, cmd_data_len, args))
return -1;
+ } else if (!strcasecmp(conn->incoming_cmd, "HSFORGET")) {
+ if (handle_control_hsforget(conn, cmd_data_len, args))
+ return -1;
} else if (!strcasecmp(conn->incoming_cmd, "ADD_ONION")) {
int ret = handle_control_add_onion(conn, cmd_data_len, args);
memwipe(args, 0, cmd_data_len); /* Scrub the private key. */
diff --git a/src/or/rendcache.c b/src/or/rendcache.c
index aa69d73..473a6a4 100644
--- a/src/or/rendcache.c
+++ b/src/or/rendcache.c
@@ -587,6 +587,34 @@ rend_cache_lookup_v2_desc_as_service(const char *query, rend_cache_entry_t **e)
return ret;
}
+/** Remove any cached descriptors for <b>service_id</b>. */
+void
+rend_cache_remove_entry(const char *service_id)
+{
+ char key[REND_SERVICE_ID_LEN_BASE32 + 2]; /* <version><service_id>\0 */
+ rend_cache_entry_t *removed;
+
+ tor_assert(rend_valid_service_id(service_id));
+ if (!rend_cache)
+ return;
+
+ tor_snprintf(key, sizeof(key), "2%s", service_id);
+ removed = (rend_cache_entry_t *)strmap_remove_lc(rend_cache, key);
+ if (removed) {
+ log_info(LD_REND, "Removed cached v2 descriptor for service %s.",
+ safe_str_client(service_id));
+ rend_cache_entry_free(removed);
+ }
+
+ tor_snprintf(key, sizeof(key), "0%s", service_id);
+ removed = (rend_cache_entry_t *)strmap_remove_lc(rend_cache, key);
+ if (removed) {
+ log_info(LD_REND, "Removed cached v0 descriptor for service %s.",
+ safe_str_client(service_id));
+ rend_cache_entry_free(removed);
+ }
+}
+
/** Lookup the v2 service descriptor with base32-encoded <b>desc_id</b> and
* copy the pointer to it to *<b>desc</b>. Return 1 on success, 0 on
* well-formed-but-not-found, and -1 on failure.
diff --git a/src/or/rendcache.h b/src/or/rendcache.h
index 270b614..69d1b1b 100644
--- a/src/or/rendcache.h
+++ b/src/or/rendcache.h
@@ -61,6 +61,7 @@ void rend_cache_purge(void);
void rend_cache_free_all(void);
int rend_cache_lookup_entry(const char *query, int version,
rend_cache_entry_t **entry_out);
+void rend_cache_remove_entry(const char *service_id);
int rend_cache_lookup_v2_desc_as_service(const char *query,
rend_cache_entry_t **entry_out);
int rend_cache_lookup_v2_desc_as_dir(const char *query, const char **desc);
diff --git a/src/or/rendclient.c b/src/or/rendclient.c
index a93bc94..f311e1f 100644
--- a/src/or/rendclient.c
+++ b/src/or/rendclient.c
@@ -32,6 +32,9 @@ static extend_info_t *rend_client_get_random_intro_impl(
const rend_cache_entry_t *rend_query,
const int strict, const int warnings);
+static void purge_hid_serv_from_last_hid_serv_requests(
+ const char *onion_address);
+
/** Purge all potentially remotely-detectable state held in the hidden
* service client code. Called on SIGNAL NEWNYM. */
void
@@ -43,6 +46,15 @@ rend_client_purge_state(void)
rend_client_purge_last_hid_serv_requests();
}
+/** Purge all cached state relating to the given hidden service. */
+void
+rend_client_purge_hidden_service(const char *onion_address)
+{
+ tor_assert(rend_valid_service_id(onion_address));
+ rend_cache_remove_entry(onion_address);
+ purge_hid_serv_from_last_hid_serv_requests(onion_address);
+}
+
/** Called when we've established a circuit to an introduction point:
* send the introduction request. */
void
diff --git a/src/or/rendclient.h b/src/or/rendclient.h
index b8f8c2f..b1da48c 100644
--- a/src/or/rendclient.h
+++ b/src/or/rendclient.h
@@ -15,6 +15,7 @@
#include "rendcache.h"
void rend_client_purge_state(void);
+void rend_client_purge_hidden_service(const char *onion_address);
void rend_client_introcirc_has_opened(origin_circuit_t *circ);
void rend_client_rendcirc_has_opened(origin_circuit_t *circ);
--
2.9.3
diff -Bbur weupnp-0.1.3-SNAPSHOT/src/main/java/org/bitlet/weupnp/GatewayDiscover.java weupnp-0.1.3-SNAPSHOT-briar/src/main/java/org/bitlet/weupnp/GatewayDiscover.java
--- weupnp-0.1.3-SNAPSHOT/src/main/java/org/bitlet/weupnp/GatewayDiscover.java 2013-05-01 21:09:27.000000000 +0100
+++ weupnp-0.1.3-SNAPSHOT-briar/src/main/java/org/bitlet/weupnp/GatewayDiscover.java 2013-12-05 20:49:00.000000000 +0000
@@ -253,7 +253,7 @@
while (st.hasMoreTokens()) {
String line = st.nextToken().trim();
- if (line.isEmpty())
+ if (line.equals(""))
continue;
if (line.startsWith("HTTP/1.") || line.startsWith("NOTIFY *"))
@@ -331,16 +331,6 @@
// For every suitable network interface, get all IP addresses
while (networkInterfaces.hasMoreElements()) {
NetworkInterface card = networkInterfaces.nextElement();
-
- try {
- // skip devices, not suitable to search gateways for
- if (card.isLoopback() || card.isPointToPoint() ||
- card.isVirtual() || !card.isUp())
- continue;
- } catch (SocketException e) {
- continue;
- }
-
Enumeration<InetAddress> addresses = card.getInetAddresses();
if (addresses == null)
@@ -348,6 +338,10 @@
while (addresses.hasMoreElements()) {
InetAddress inetAddress = addresses.nextElement();
+
+ if (inetAddress.isLoopbackAddress())
+ continue;
+
int index = arrayIPAddress.size();
if (!getIPv4 || !getIPv6) {
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