Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
briar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julian Dehm
briar
Commits
c74c24ec
Unverified
Commit
c74c24ec
authored
8 years ago
by
str4d
Committed by
akwizgran
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add ADD_ONION and DEL_ONION support to jtorctl patch
parent
33c1f163
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
patches/jtorctl.patch
+119
-2
119 additions, 2 deletions
patches/jtorctl.patch
with
119 additions
and
2 deletions
patches/jtorctl.patch
+
119
−
2
View file @
c74c24ec
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..
38b1879
100644
index 9524612..
c0f2070
100644
--- a/net/freehaven/tor/control/TorControlConnection.java
+++ b/net/freehaven/tor/control/TorControlConnection.java
@@ -740,7 +740,7 @@
public class TorControlConnection implements TorControlCommands {
@@ -736,11 +736,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 {
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment