gnu: emacs-consult: Fix grammar.
[jackhill/guix/guix.git] / gnu / packages / tor.scm
index a82654b..d85c11a 100644 (file)
@@ -1,12 +1,15 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014, 2015 Mark H Weaver <mhw@netris.org>
-;;; Copyright © 2016, 2017, 2018 Efraim Flashner <efraim@flashner.co.il>
-;;; Copyright © 2016, 2017 ng0 <ng0@n0.is>
-;;; Copyright © 2017, 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
-;;; Copyright © 2017, 2018, 2019 Eric Bavier <bavier@member.fsf.org>
+;;; Copyright © 2016, 2017, 2018, 2020, 2021 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2016, 2017 Nikita <nikita@n0.is>
+;;; Copyright © 2017–2021 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2017, 2018, 2019, 2021 Eric Bavier <bavier@posteo.net>
 ;;; Copyright © 2017 Rutger Helling <rhelling@mykolab.com>
 ;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
+;;; Copyright © 2020 Vincent Legoll <vincent.legoll@gmail.com>
+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
+;;; Copyright © 2020 André Batista <nandre@riseup.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -26,6 +29,7 @@
 (define-module (gnu packages tor)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
+  #:use-module (guix utils)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix build-system gnu)
 (define-public tor
   (package
     (name "tor")
-    (version "0.4.1.6")
+    (version "0.4.5.7")
     (source (origin
              (method url-fetch)
              (uri (string-append "https://dist.torproject.org/tor-"
                                  version ".tar.gz"))
              (sha256
               (base32
-               "0wgdid8w7srd218hh4rwslzdx2ickxw1pg18p2wry1r6wi65521a"))))
+               "0x7hhl0svfc4yh9xvq7kkzgmwjcw1ak9i0794wjg4biy2fmclzs4"))))
     (build-system gnu-build-system)
+    (arguments
+     `(#:configure-flags
+       (list "--enable-lzma"
+             "--enable-zstd")
+       #:phases
+       (modify-phases %standard-phases
+         (add-before 'check 'skip-practracker
+           ;; This is a style linter.  It doesn't get to throw fatal errors.
+           (lambda _
+             (setenv "TOR_DISABLE_PRACTRACKER" "set")
+             #t)))))
     (native-inputs
      `(("pkg-config" ,pkg-config)
-       ("python" ,python-2)))           ; for tests
+       ("python" ,python)))             ; for tests
     (inputs
-     `(("zlib" ,zlib)
-       ("openssl" ,openssl)
-       ("libevent" ,libevent)
+     `(("libevent" ,libevent)
        ("libseccomp" ,libseccomp)
+       ("openssl" ,openssl)
        ("xz" ,xz)
+       ("zlib" ,zlib)
        ("zstd" ,zstd "lib")))
     (home-page "https://www.torproject.org/")
     (synopsis "Anonymous network router to improve privacy on the Internet")
@@ -80,11 +95,37 @@ location.  Tor works with many of your existing applications, including
 web browsers, instant messaging clients, remote login, and other
 applications based on the TCP protocol.
 
+This package is the full featured @code{tor} which is needed for running
+relays, bridges or directory authorities. If you just want to access the Tor
+network or to setup an onion service you may install @code{tor-client}
+instead.")
+    (license license:bsd-3)))
+
+(define-public tor-client
+  (package
+    (inherit tor)
+    (name "tor-client")
+    (arguments
+     (substitute-keyword-arguments (package-arguments tor)
+       ((#:configure-flags flags)
+        (append flags
+                '("--disable-module-relay")))))
+    (synopsis "Client to the anonymous Tor network")
+    (description
+     "Tor protects you by bouncing your communications around a distributed
+network of relays run by volunteers all around the world: it prevents
+somebody watching your Internet connection from learning what sites you
+visit, and it prevents the sites you visit from learning your physical
+location.  Tor works with many of your existing applications, including
+web browsers, instant messaging clients, remote login, and other
+applications based on the TCP protocol.
+
 To @code{torify} applications (to take measures to ensure that an application,
 which has not been designed for use with Tor such as ssh, will use only Tor for
 internet connectivity, and also ensures that there are no leaks from DNS, UDP or
-the application layer) you need to install @code{torsocks}.")
-    (license license:bsd-3)))
+the application layer) you need to install @code{torsocks}.
+
+This package only provides a client to the Tor Network.")))
 
 (define-public torsocks
   (package
@@ -121,7 +162,7 @@ rejects UDP traffic from the application you're using.")
 (define-public privoxy
   (package
     (name "privoxy")
-    (version "3.0.28")
+    (version "3.0.32")
     (source (origin
              (method url-fetch)
              (uri (string-append "mirror://sourceforge/ijbswa/Sources/"
@@ -129,20 +170,45 @@ rejects UDP traffic from the application you're using.")
                                  version "-stable-src.tar.gz"))
              (sha256
               (base32
-               "0jl2yav1qzqnaqnnx8i6i53ayckkimcrs3l6ryvv7bda6v08rmxm"))))
+               "1mzfxwnvnf1jkvfcrsivm6mjwdzjrc3h89qziz0mwi32ih0f87f6"))))
     (build-system gnu-build-system)
     (arguments
      '(;; The default 'sysconfdir' is $out/etc; change that to
        ;; $out/etc/privoxy.
        #:configure-flags (list (string-append "--sysconfdir="
                                               (assoc-ref %outputs "out")
-                                              "/etc/privoxy"))
-       #:tests? #f))
+                                              "/etc/privoxy")
+                               "--localstatedir=/var"
+                               "--with-brotli"
+                               "--with-openssl")
+       #:tests? #f                      ; no test suite
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'patch-default-logging
+           (lambda _
+             (with-fluids ((%default-port-encoding "ISO-8859-1"))
+               ;; Do not create /var/run nor /var/log/privoxy/logfile.
+               (substitute* "GNUmakefile.in"
+                 (("(logfile \\|\\| exit )1" _ match)
+                  (string-append match "0"))
+                 (("(\\$\\(DESTDIR\\)\\$\\(SHARE_DEST\\)) \\\\" _ match)
+                  match)
+                 ((".*\\$\\(LOG_DEST\\) \\$\\(DESTDIR\\)\\$\\(PID_DEST\\).*")
+                  ""))
+               ;; Disable logging in the default configuration to allow for
+               ;; non-root users using it as is.
+               (substitute* "config"
+                 (("^logdir") "#logdir")
+                 (("^logfile") "#logfile")))
+             #t)))))
     (inputs
-     `(("w3m" ,w3m)
+     `(("brotli" ,brotli)
+       ("openssl" ,openssl)
        ("pcre" ,pcre)
-       ("zlib" ,zlib)
-       ("autoconf" ,autoconf)
+       ("w3m" ,w3m)
+       ("zlib" ,zlib)))
+    (native-inputs
+     `(("autoconf" ,autoconf)
        ("automake" ,automake)))
     (home-page "https://www.privoxy.org")
     (synopsis "Web proxy with advanced filtering capabilities for enhancing privacy")
@@ -155,65 +221,153 @@ tastes.  It has application for both stand-alone systems and multi-user
 networks.")
     (license license:gpl2+)))
 
-(define-public onionshare
+(define-public onionshare-cli
   (package
-    (name "onionshare")
-    (version "2.2")
+    (name "onionshare-cli")
+    (version "2.3.1")
     (source
       (origin
         (method git-fetch)
         (uri (git-reference
-              (url "https://github.com/micahflee/onionshare.git")
+              (url "https://github.com/micahflee/onionshare")
               (commit (string-append "v" version))))
         (file-name (git-file-name name version))
         (sha256
-         (base32 "0m8ygxcyp3nfzzhxs2dfnpqwh1vx0aws44lszpnnczz4fks3a5j4"))))
+         (base32 "1llvnvb676s2cs6a4y7isxdj75ddfvskw1p93v5m35vsw7f72kqz"))))
     (build-system python-build-system)
-    (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         (add-after 'unpack 'fix-install-path
-           (lambda* (#:key outputs #:allow-other-keys)
-             (let* ((out        (assoc-ref outputs "out"))
-                    (onionshare (string-append out "/share/onionshare")))
-               (substitute* '("setup.py" "onionshare/common.py")
-                 (("sys.prefix,") (string-append "'" out "',")))
-               (substitute* "setup.py"
-                 ;; For the nautilus plugin.
-                 (("/usr/share/nautilus") "share/nautilus"))
-               (substitute* "install/org.onionshare.OnionShare.desktop"
-                 (("/usr") out))
-               #t)))
-         (delete 'check)
-         (add-before 'strip 'check
-           ;; After all the patching we run the tests after installing.
-           (lambda _
-             (setenv "HOME" "/tmp")     ; Some tests need a writable homedir
-             (invoke "pytest" "tests/")
-             #t)))))
     (native-inputs
      `(("python-pytest" ,python-pytest)))
     (inputs
-     `(("python-pycrypto" ,python-pycrypto)
+     ;; TODO: obfs4proxy
+     `(("python-click" ,python-click)
+       ("python-eventlet" ,python-eventlet)
        ("python-flask" ,python-flask)
        ("python-flask-httpauth" ,python-flask-httpauth)
-       ("python-nautilus" ,python-nautilus)
-       ("python-sip" ,python-sip)
-       ("python-stem" ,python-stem)
+       ("python-flask-socketio" ,python-flask-socketio)
+       ("python-psutil" ,python-psutil)
+       ("python-pycryptodome" ,python-pycryptodome)
        ("python-pysocks" ,python-pysocks)
-       ("python-pyqt" ,python-pyqt)))
+       ("python-requests" ,python-requests)
+       ("python-stem" ,python-stem)
+       ("python-unidecode" ,python-unidecode)
+       ("python-urllib3" ,python-urllib3)
+       ("tor" ,tor)))
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'bake-tor
+           (lambda* (#:key inputs #:allow-other-keys)
+             (substitute* (list "cli/onionshare_cli/common.py"
+                                "desktop/src/onionshare/gui_common.py")
+               (("shutil\\.which\\(\\\"tor\\\"\\)")
+                (string-append "\"" (which "tor") "\"")))
+             #t))
+         (add-before 'build 'change-directory
+           (lambda _ (chdir "cli") #t))
+         (replace 'check
+           (lambda _
+             (setenv "HOME" "/tmp")
+             ;; Greendns is not needed for testing, and if eventlet tries to
+             ;; load it, an OSError is thrown when getprotobyname is called.
+             ;; Thankfully there is an environment variable to disable the
+             ;; greendns import, so use it:
+             (setenv "EVENTLET_NO_GREENDNS" "yes")
+             (invoke "pytest" "-v" "./tests"))))))
     (home-page "https://onionshare.org/")
     (synopsis "Securely and anonymously share files")
-    (description "OnionShare is a tool for securely and anonymously sending
-and receiving files using Tor onion services.  It works by starting a web
-server directly on your computer and making it accessible as an unguessable
-Tor web address that others can load in a Tor-enabled web browser to download
-files from you, or upload files to you.  It doesn't require setting up a
-separate server, using a third party file-sharing service, or even logging
-into an account.")
-    ;; Bundled, minified jquery is expat licensed.
+    (description "OnionShare lets you securely and anonymously share files,
+host websites, and chat with friends using the Tor network.
+
+This package contains @code{onionshare-cli}, a command-line interface to
+OnionShare.")
+    ;; Bundled, minified jquery and socket.io are expat licensed.
     (license (list license:gpl3+ license:expat))))
 
+(define-public onionshare
+  (package (inherit onionshare-cli)
+    (name "onionshare")
+    (arguments
+     (substitute-keyword-arguments (package-arguments onionshare-cli)
+      ((#:phases phases)
+       `(modify-phases ,phases
+         (replace 'change-directory
+           (lambda _ (chdir "desktop/src") #t))
+         (add-after 'unpack 'patch-tests
+           (lambda _
+             ;; Disable tests that require starting servers, which will hang
+             ;; during build:
+             ;; - test_autostart_and_autostop_timer_mismatch
+             ;; - test_autostart_timer
+             ;; - test_autostart_timer_too_short
+             ;; - test_autostop_timer_too_short
+             (substitute* "desktop/tests/test_gui_share.py"
+               (("( *)def test_autost(art|op)_(timer(_too_short)?|and_[^(]*)\\(" & >)
+                (string-append > "@pytest.mark.skip\n" &)))
+             ;; - test_13_quit_with_server_started_should_warn
+             (substitute* "desktop/tests/test_gui_tabs.py"
+               (("( *)def test_13" & >)
+                (string-append > "@pytest.mark.skip\n" &)))
+             ;; Remove multiline load-path adjustment, so that onionshare-cli
+             ;; modules are loaded from input
+             (use-modules (ice-9 regex)
+                          (ice-9 rdelim))
+             (with-atomic-file-replacement "desktop/tests/conftest.py"
+               (let ((start-rx (make-regexp "^# Allow importing")))
+                 (lambda (in out)
+                   (let loop ()
+                     (let ((line (read-line in 'concat)))
+                       (if (regexp-exec start-rx line)
+                           (begin      ; slurp until closing paren
+                             (let slurp ()
+                               (let ((line (read-line in 'concat)))
+                                 (if (string=? line ")\n")
+                                     (dump-port in out) ; done
+                                     (slurp)))))
+                           (begin
+                             (display line out)
+                             (loop))))))))))
+         (replace 'check
+           (lambda _
+             ;; Some tests need a writable homedir:
+             (setenv "HOME" "/tmp")
+             ;; Ensure installed modules can be found:
+             (setenv "PYTHONPATH"
+                     (string-append %output "/lib/python"
+                                    ,(version-major+minor (package-version python))
+                                    "/site-packages:"
+                                    (getenv "PYTHONPATH")))
+             ;; Avoid `getprotobyname` issues:
+             (setenv "EVENTLET_NO_GREENDNS" "yes")
+             ;; Make Qt render "offscreen":
+             (setenv "QT_QPA_PLATFORM" "offscreen")
+             ;; Must be run from "desktop" dir:
+             (chdir "..")
+             (invoke "./tests/run.sh")))
+         (add-after 'install 'install-data
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (share (string-append out "/share")))
+               (install-file "org.onionshare.OnionShare.svg"
+                             (string-append share "/icons/hicolor/scalable/apps"))
+               (install-file "org.onionshare.OnionShare.desktop"
+                             (string-append share "/applications"))
+               #t)))))))
+    (native-inputs
+     `(("python-pytest" ,python-pytest)))
+    (inputs
+     ;; TODO: obfs4proxy
+     `(("onionshare-cli" ,onionshare-cli)
+       ("python-shiboken-2" ,python-shiboken-2)
+       ("python-pyside-2" ,python-pyside-2)
+       ("python-qrcode" ,python-qrcode)
+       ;; The desktop client uses onionshare-cli like a python module.  But
+       ;; propagating onionshare-cli's inputs is not great, since a user would
+       ;; not expect to have those installed when using onionshare-cli as a
+       ;; standalone utility.  So add onionshare-cli's inputs here.
+       ,@(package-inputs onionshare-cli)))
+    (description "OnionShare lets you securely and anonymously share files,
+host websites, and chat with friends using the Tor network.")))
+
 (define-public nyx
   (package
     (name "nyx")