From 163ffa7c4a7529ce257df72b1be392a0c0a32443 Mon Sep 17 00:00:00 2001 From: Tim Retout Date: Fri, 18 Jul 2014 18:11:40 +0100 Subject: Allow URI schemes starting with "tor+", e.g. "tor+http://" --- Makefile.am | 4 ++++ configure.ac | 1 + tor.cc | 12 ++++++++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 7ebcb3a..e419b94 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,4 +4,8 @@ methodsdir = $(prefix)/lib/apt/methods methods_PROGRAMS = tor tor_SOURCES = tor.cc tor.h server.cc server.h apti18n.h +install-exec-hook: + cd $(DESTDIR)$(methodsdir) && \ + $(LN_S) tor tor+http + EXTRA_DIST = README.md diff --git a/configure.ac b/configure.ac index 21f82ab..1188688 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,7 @@ AC_INIT([apt-transport-tor], [0.1], [diocles@debian.org]) AM_INIT_AUTOMAKE([-Wall -Werror foreign]) AC_PROG_CXX +AC_PROG_LN_S AC_CONFIG_HEADERS([config.h]) AC_CHECK_LIB([apt-pkg], [main]) AC_CHECK_LIB([curl], [curl_version]) diff --git a/tor.cc b/tor.cc index 8406cba..4d7a91e 100644 --- a/tor.cc +++ b/tor.cc @@ -151,8 +151,16 @@ bool TorMethod::Fetch(FetchItem *Itm) URI Uri = Itm->Uri; string remotehost = Uri.Host; - // Undo the "tor" at the start - Uri.Access = "http"; + // Undo any "tor" or "tor+" at the start + string prefix="tor+"; + if ("tor" == Uri.Access) + { + Uri.Access = "http"; + } + else if (!Uri.Access.compare(0, prefix.size(), prefix)) + { + Uri.Access = Uri.Access.substr(prefix.size()); + } // TODO: // - http::Pipeline-Depth -- cgit v1.2.3-18-g5258