1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2016, 2017, 2018, 2020, 2021 Efraim Flashner <efraim@flashner.co.il>
5 ;;; Copyright © 2016, 2017 Nikita <nikita@n0.is>
6 ;;; Copyright © 2017–2021 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2017, 2018, 2019, 2021 Eric Bavier <bavier@posteo.net>
8 ;;; Copyright © 2017 Rutger Helling <rhelling@mykolab.com>
9 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
10 ;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
11 ;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
12 ;;; Copyright © 2020 André Batista <nandre@riseup.net>
14 ;;; This file is part of GNU Guix.
16 ;;; GNU Guix is free software; you can redistribute it and/or modify it
17 ;;; under the terms of the GNU General Public License as published by
18 ;;; the Free Software Foundation; either version 3 of the License, or (at
19 ;;; your option) any later version.
21 ;;; GNU Guix is distributed in the hope that it will be useful, but
22 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;;; GNU General Public License for more details.
26 ;;; You should have received a copy of the GNU General Public License
27 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
29 (define-module (gnu packages tor)
30 #:use-module ((guix licenses) #:prefix license:)
31 #:use-module (guix packages)
32 #:use-module (guix utils)
33 #:use-module (guix download)
34 #:use-module (guix git-download)
35 #:use-module (guix build-system gnu)
36 #:use-module (guix build-system python)
37 #:use-module (gnu packages)
38 #:use-module (gnu packages base)
39 #:use-module (gnu packages libevent)
40 #:use-module (gnu packages linux)
41 #:use-module (gnu packages check)
42 #:use-module (gnu packages compression)
43 #:use-module (gnu packages pcre)
44 #:use-module (gnu packages pkg-config)
45 #:use-module (gnu packages python)
46 #:use-module (gnu packages python-crypto)
47 #:use-module (gnu packages python-web)
48 #:use-module (gnu packages python-xyz)
49 #:use-module (gnu packages qt)
50 #:use-module (gnu packages autotools)
51 #:use-module (gnu packages tls)
52 #:use-module (gnu packages w3m))
60 (uri (string-append "https://dist.torproject.org/tor-"
64 "0x7hhl0svfc4yh9xvq7kkzgmwjcw1ak9i0794wjg4biy2fmclzs4"))))
65 (build-system gnu-build-system)
71 (modify-phases %standard-phases
72 (add-before 'check 'skip-practracker
73 ;; This is a style linter. It doesn't get to throw fatal errors.
75 (setenv "TOR_DISABLE_PRACTRACKER" "set")
78 `(("pkg-config" ,pkg-config)
79 ("python" ,python))) ; for tests
81 `(("libevent" ,libevent)
82 ("libseccomp" ,libseccomp)
86 ("zstd" ,zstd "lib")))
87 (home-page "https://www.torproject.org/")
88 (synopsis "Anonymous network router to improve privacy on the Internet")
90 "Tor protects you by bouncing your communications around a distributed
91 network of relays run by volunteers all around the world: it prevents
92 somebody watching your Internet connection from learning what sites you
93 visit, and it prevents the sites you visit from learning your physical
94 location. Tor works with many of your existing applications, including
95 web browsers, instant messaging clients, remote login, and other
96 applications based on the TCP protocol.
98 This package is the full featured @code{tor} which is needed for running
99 relays, bridges or directory authorities. If you just want to access the Tor
100 network or to setup an onion service you may install @code{tor-client}
102 (license license:bsd-3)))
104 (define-public tor-client
109 (substitute-keyword-arguments (package-arguments tor)
110 ((#:configure-flags flags)
112 '("--disable-module-relay")))))
113 (synopsis "Client to the anonymous Tor network")
115 "Tor protects you by bouncing your communications around a distributed
116 network of relays run by volunteers all around the world: it prevents
117 somebody watching your Internet connection from learning what sites you
118 visit, and it prevents the sites you visit from learning your physical
119 location. Tor works with many of your existing applications, including
120 web browsers, instant messaging clients, remote login, and other
121 applications based on the TCP protocol.
123 To @code{torify} applications (to take measures to ensure that an application,
124 which has not been designed for use with Tor such as ssh, will use only Tor for
125 internet connectivity, and also ensures that there are no leaks from DNS, UDP or
126 the application layer) you need to install @code{torsocks}.
128 This package only provides a client to the Tor Network.")))
130 (define-public torsocks
136 (uri (string-append "https://people.torproject.org/~dgoulet/"
137 "torsocks/torsocks-" version ".tar.xz"))
140 "08inrkap29gikb6sdmb58z43hw4abwrfw7ny40c4xzdkss0vkwdr"))))
141 (build-system gnu-build-system)
143 `(("libcap" ,libcap)))
145 `(#:phases (modify-phases %standard-phases
146 (add-after 'build 'absolutize
147 (lambda* (#:key inputs #:allow-other-keys)
148 (substitute* "src/bin/torsocks"
150 (string-append "getcap=" (which "getcap") "\n")))
152 (home-page "https://www.torproject.org/")
153 (synopsis "Use socks-friendly applications with Tor")
155 "Torsocks allows you to use most socks-friendly applications in a safe
156 way with Tor. It ensures that DNS requests are handled safely and explicitly
157 rejects UDP traffic from the application you're using.")
159 ;; All the files explicitly say "version 2 only".
160 (license license:gpl2)))
162 (define-public privoxy
168 (uri (string-append "mirror://sourceforge/ijbswa/Sources/"
169 version "%20%28stable%29/privoxy-"
170 version "-stable-src.tar.gz"))
173 "1mzfxwnvnf1jkvfcrsivm6mjwdzjrc3h89qziz0mwi32ih0f87f6"))))
174 (build-system gnu-build-system)
176 '(;; The default 'sysconfdir' is $out/etc; change that to
178 #:configure-flags (list (string-append "--sysconfdir="
179 (assoc-ref %outputs "out")
181 "--localstatedir=/var"
184 #:tests? #f ; no test suite
186 (modify-phases %standard-phases
187 (add-after 'unpack 'patch-default-logging
189 (with-fluids ((%default-port-encoding "ISO-8859-1"))
190 ;; Do not create /var/run nor /var/log/privoxy/logfile.
191 (substitute* "GNUmakefile.in"
192 (("(logfile \\|\\| exit )1" _ match)
193 (string-append match "0"))
194 (("(\\$\\(DESTDIR\\)\\$\\(SHARE_DEST\\)) \\\\" _ match)
196 ((".*\\$\\(LOG_DEST\\) \\$\\(DESTDIR\\)\\$\\(PID_DEST\\).*")
198 ;; Disable logging in the default configuration to allow for
199 ;; non-root users using it as is.
200 (substitute* "config"
201 (("^logdir") "#logdir")
202 (("^logfile") "#logfile")))
211 `(("autoconf" ,autoconf)
212 ("automake" ,automake)))
213 (home-page "https://www.privoxy.org")
214 (synopsis "Web proxy with advanced filtering capabilities for enhancing privacy")
216 "Privoxy is a non-caching web proxy with advanced filtering capabilities
217 for enhancing privacy, modifying web page data and HTTP headers, controlling
218 access, and removing ads and other obnoxious Internet junk. Privoxy has a
219 flexible configuration and can be customized to suit individual needs and
220 tastes. It has application for both stand-alone systems and multi-user
222 (license license:gpl2+)))
224 (define-public onionshare-cli
226 (name "onionshare-cli")
232 (url "https://github.com/micahflee/onionshare")
233 (commit (string-append "v" version))))
234 (file-name (git-file-name name version))
236 (base32 "1llvnvb676s2cs6a4y7isxdj75ddfvskw1p93v5m35vsw7f72kqz"))))
237 (build-system python-build-system)
239 `(("python-pytest" ,python-pytest)))
242 `(("python-click" ,python-click)
243 ("python-eventlet" ,python-eventlet)
244 ("python-flask" ,python-flask)
245 ("python-flask-httpauth" ,python-flask-httpauth)
246 ("python-flask-socketio" ,python-flask-socketio)
247 ("python-psutil" ,python-psutil)
248 ("python-pycryptodome" ,python-pycryptodome)
249 ("python-pysocks" ,python-pysocks)
250 ("python-requests" ,python-requests)
251 ("python-stem" ,python-stem)
252 ("python-unidecode" ,python-unidecode)
253 ("python-urllib3" ,python-urllib3)
257 (modify-phases %standard-phases
258 (add-after 'unpack 'bake-tor
259 (lambda* (#:key inputs #:allow-other-keys)
260 (substitute* (list "cli/onionshare_cli/common.py"
261 "desktop/src/onionshare/gui_common.py")
262 (("shutil\\.which\\(\\\"tor\\\"\\)")
263 (string-append "\"" (which "tor") "\"")))
265 (add-before 'build 'change-directory
266 (lambda _ (chdir "cli") #t))
269 (setenv "HOME" "/tmp")
270 ;; Greendns is not needed for testing, and if eventlet tries to
271 ;; load it, an OSError is thrown when getprotobyname is called.
272 ;; Thankfully there is an environment variable to disable the
273 ;; greendns import, so use it:
274 (setenv "EVENTLET_NO_GREENDNS" "yes")
275 (invoke "pytest" "-v" "./tests"))))))
276 (home-page "https://onionshare.org/")
277 (synopsis "Securely and anonymously share files")
278 (description "OnionShare lets you securely and anonymously share files,
279 host websites, and chat with friends using the Tor network.
281 This package contains @code{onionshare-cli}, a command-line interface to
283 ;; Bundled, minified jquery and socket.io are expat licensed.
284 (license (list license:gpl3+ license:expat))))
286 (define-public onionshare
287 (package (inherit onionshare-cli)
290 (substitute-keyword-arguments (package-arguments onionshare-cli)
292 `(modify-phases ,phases
293 (replace 'change-directory
294 (lambda _ (chdir "desktop/src") #t))
295 (add-after 'unpack 'patch-tests
297 ;; Disable tests that require starting servers, which will hang
299 ;; - test_autostart_and_autostop_timer_mismatch
300 ;; - test_autostart_timer
301 ;; - test_autostart_timer_too_short
302 ;; - test_autostop_timer_too_short
303 (substitute* "desktop/tests/test_gui_share.py"
304 (("( *)def test_autost(art|op)_(timer(_too_short)?|and_[^(]*)\\(" & >)
305 (string-append > "@pytest.mark.skip\n" &)))
306 ;; - test_13_quit_with_server_started_should_warn
307 (substitute* "desktop/tests/test_gui_tabs.py"
308 (("( *)def test_13" & >)
309 (string-append > "@pytest.mark.skip\n" &)))
310 ;; Remove multiline load-path adjustment, so that onionshare-cli
311 ;; modules are loaded from input
312 (use-modules (ice-9 regex)
314 (with-atomic-file-replacement "desktop/tests/conftest.py"
315 (let ((start-rx (make-regexp "^# Allow importing")))
318 (let ((line (read-line in 'concat)))
319 (if (regexp-exec start-rx line)
320 (begin ; slurp until closing paren
322 (let ((line (read-line in 'concat)))
323 (if (string=? line ")\n")
324 (dump-port in out) ; done
331 ;; Some tests need a writable homedir:
332 (setenv "HOME" "/tmp")
333 ;; Ensure installed modules can be found:
335 (string-append %output "/lib/python"
336 ,(version-major+minor (package-version python))
338 (getenv "PYTHONPATH")))
339 ;; Avoid `getprotobyname` issues:
340 (setenv "EVENTLET_NO_GREENDNS" "yes")
341 ;; Make Qt render "offscreen":
342 (setenv "QT_QPA_PLATFORM" "offscreen")
343 ;; Must be run from "desktop" dir:
345 (invoke "./tests/run.sh")))
346 (add-after 'install 'install-data
347 (lambda* (#:key outputs #:allow-other-keys)
348 (let* ((out (assoc-ref outputs "out"))
349 (share (string-append out "/share")))
350 (install-file "org.onionshare.OnionShare.svg"
351 (string-append share "/icons/hicolor/scalable/apps"))
352 (install-file "org.onionshare.OnionShare.desktop"
353 (string-append share "/applications"))
356 `(("python-pytest" ,python-pytest)))
359 `(("onionshare-cli" ,onionshare-cli)
360 ("python-shiboken-2" ,python-shiboken-2)
361 ("python-pyside-2" ,python-pyside-2)
362 ("python-qrcode" ,python-qrcode)
363 ;; The desktop client uses onionshare-cli like a python module. But
364 ;; propagating onionshare-cli's inputs is not great, since a user would
365 ;; not expect to have those installed when using onionshare-cli as a
366 ;; standalone utility. So add onionshare-cli's inputs here.
367 ,@(package-inputs onionshare-cli)))
368 (description "OnionShare lets you securely and anonymously share files,
369 host websites, and chat with friends using the Tor network.")))
378 (uri (pypi-uri name version))
381 "02rrlllz2ci6i6cs3iddyfns7ang9a54jrlygd2jw1f9s6418ll8"))))
382 (build-system python-build-system)
384 `(("python-stem" ,python-stem)))
387 (modify-phases %standard-phases
388 (add-after 'install 'install-man-page
389 (lambda* (#:key outputs #:allow-other-keys)
390 (let* ((out (assoc-ref outputs "out"))
391 (man (string-append out "/share/man")))
392 (install-file "nyx.1" (string-append man "/man1"))
394 (add-after 'install 'install-sample-configuration
395 (lambda* (#:key outputs #:allow-other-keys)
396 (let* ((out (assoc-ref outputs "out"))
397 (doc (string-append out "/share/doc/" ,name "-" ,version)))
398 (install-file "web/nyxrc.sample" doc)
400 ;; XXX The tests seem to require more of a real terminal than the build
401 ;; environment provides:
402 ;; _curses.error: setupterm: could not find terminal
403 ;; With TERM=linux, the tests try to move the cursor and still fail:
404 ;; _curses.error: cbreak() returned ERR
406 (home-page "https://nyx.torproject.org/")
407 (synopsis "Tor relay status monitor")
409 "Nyx monitors the performance of relays participating in the
410 @uref{https://www.torproject.org/, Tor anonymity network}. It displays this
411 information visually and in real time, using a curses-based terminal interface.
412 This makes Nyx well-suited for remote shell connections and servers without a
413 graphical display. It's like @command{top} for Tor, providing detailed
414 statistics and status reports on:
417 @item connections (with IP address, hostname, fingerprint, and consensus data),
418 @item bandwidth, processor, and memory usage,
419 @item the relay's current configuration,
424 Potential client and exit connections are scrubbed of sensitive information.")
425 (license license:gpl3+)))