From d124b87875cb79b15755b5b061e1d53993eb7e18 Mon Sep 17 00:00:00 2001 From: Louis Bettens Date: Tue, 18 Jan 2022 10:30:11 +0100 Subject: [PATCH 1/3] python3Packages.cepa: init at 1.8.3 --- .../python-modules/cepa/default.nix | 32 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 ++ 2 files changed, 34 insertions(+) create mode 100644 pkgs/development/python-modules/cepa/default.nix diff --git a/pkgs/development/python-modules/cepa/default.nix b/pkgs/development/python-modules/cepa/default.nix new file mode 100644 index 000000000000..f198d8b058dd --- /dev/null +++ b/pkgs/development/python-modules/cepa/default.nix @@ -0,0 +1,32 @@ +{ lib, buildPythonPackage, fetchPypi, python, mock }: + +buildPythonPackage rec { + pname = "cepa"; + version = "1.8.3"; + + src = fetchPypi { + inherit pname version; + sha256 = "HcbwsyTTei7SyidGSOzo/SyWodL0QPWMDKF6/Ute3no="; + }; + + postPatch = '' + rm test/unit/installation.py + sed -i "/test.unit.installation/d" test/settings.cfg + # https://github.com/torproject/stem/issues/56 + sed -i '/MOCK_VERSION/d' run_tests.py + ''; + + checkInputs = [ mock ]; + + checkPhase = '' + touch .gitignore + ${python.interpreter} run_tests.py -u + ''; + + meta = with lib; { + description = "Controller library that allows applications to interact with Tor"; + homepage = "https://github.com/onionshare/cepa"; + license = licenses.lgpl3Only; + maintainers = with maintainers; [ lourkeur ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index cf58483ebdeb..2c50261fdfc7 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -1495,6 +1495,8 @@ in { coqpit = callPackage ../development/python-modules/coqpit { }; + cepa = callPackage ../development/python-modules/cepa { }; + cerberus = callPackage ../development/python-modules/cerberus { }; cert-chain-resolver = callPackage ../development/python-modules/cert-chain-resolver { }; From ccfbc1e98d700f17507d7b2c1acc5221baab10d2 Mon Sep 17 00:00:00 2001 From: Louis Bettens Date: Tue, 18 Jan 2022 15:16:04 +0100 Subject: [PATCH 2/3] snowflake: init at 2.0.1 --- pkgs/tools/networking/snowflake/default.nix | 21 +++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 2 files changed, 23 insertions(+) create mode 100644 pkgs/tools/networking/snowflake/default.nix diff --git a/pkgs/tools/networking/snowflake/default.nix b/pkgs/tools/networking/snowflake/default.nix new file mode 100644 index 000000000000..8535f18567da --- /dev/null +++ b/pkgs/tools/networking/snowflake/default.nix @@ -0,0 +1,21 @@ +{ lib, buildGoModule, fetchgit }: + +buildGoModule rec { + pname = "snowflake"; + version = "2.0.1"; + + src = fetchgit { + url = "https://git.torproject.org/pluggable-transports/${pname}"; + rev = "v${version}"; + hash = "sha256-ULkqsh0DeFI1GsaVaHGSjoEY38EktvDVC52Sx6cQLOE="; + }; + + vendorSha256 = "D5A19UHL1WEE1ODT80jKT+PJ5CTXPjc9Eg6v2Nfm4aw="; + + meta = with lib; { + description = "System to defeat internet censorship"; + homepage = "https://snowflake.torproject.org/"; + maintainers = with maintainers; [ lourkeur ]; + license = licenses.bsd3; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 99b7b76fb7a7..fb1f50663dbc 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1166,6 +1166,8 @@ with pkgs; mcaimi-st = callPackage ../applications/terminal-emulators/st/mcaimi-st.nix { }; siduck76-st = callPackage ../applications/terminal-emulators/st/siduck76-st.nix { }; + snowflake = callPackage ../tools/networking/snowflake { }; + stupidterm = callPackage ../applications/terminal-emulators/stupidterm { gtk = gtk3; }; From 23f87f4b69c8ce802af64ad340c8851f7db9f756 Mon Sep 17 00:00:00 2001 From: Louis Bettens Date: Tue, 18 Jan 2022 10:04:53 +0100 Subject: [PATCH 3/3] onionshare: 2.4 -> 2.5 --- .../networking/onionshare/default.nix | 28 ++++----- .../networking/onionshare/fix-paths-gui.patch | 39 ++++++++++--- .../networking/onionshare/fix-paths.patch | 57 +++++++++++++++---- 3 files changed, 88 insertions(+), 36 deletions(-) diff --git a/pkgs/applications/networking/onionshare/default.nix b/pkgs/applications/networking/onionshare/default.nix index 5b1a1fad5b1a..e7b661ae6ae7 100644 --- a/pkgs/applications/networking/onionshare/default.nix +++ b/pkgs/applications/networking/onionshare/default.nix @@ -8,7 +8,7 @@ , flask , flask-httpauth , flask-socketio -, stem +, cepa , psutil , pyqt5 , pycrypto @@ -21,15 +21,16 @@ , unidecode , tor , obfs4 +, snowflake }: let - version = "2.4"; + version = "2.5"; src = fetchFromGitHub { owner = "onionshare"; repo = "onionshare"; rev = "v${version}"; - sha256 = "sha256-Lclm7mIkaAkQpWcNILTRJtLA43dpiyHtWAeHS2r3+ZQ="; + sha256 = "xCAM+tjjyDg/gqAXr4YNPhM8R3n9r895jktisAGlpZo="; }; meta = with lib; { description = "Securely and anonymously send and receive files"; @@ -55,16 +56,9 @@ let license = licenses.gpl3Plus; maintainers = with maintainers; [ lourkeur ]; }; - stem' = stem.overridePythonAttrs (_: rec { - version = "1.8.1"; - src = fetchFromGitHub { - owner = "onionshare"; - repo = "stem"; - rev = version; - sha256 = "Dzpvx7CgAr5OtGmfubWAYDLqq5LkGqcwjr3bxpfL/3A="; - }; - }); + # TODO: package meek https://support.torproject.org/glossary/meek/ + meek = "/meek-not-available"; in rec { @@ -76,7 +70,7 @@ rec { # hardcode store paths of dependencies (substituteAll { src = ./fix-paths.patch; - inherit tor obfs4; + inherit tor meek obfs4 snowflake; inherit (tor) geoip; }) ]; @@ -86,7 +80,7 @@ rec { flask flask-httpauth flask-socketio - stem' + cepa psutil pycrypto pynacl @@ -109,8 +103,6 @@ rec { ''; disabledTests = [ - "test_firefox_like_behavior" - "test_if_unmodified_since" "test_get_tor_paths_linux" # expects /usr instead of /nix/store ] ++ lib.optionals stdenv.isDarwin [ # on darwin (and only on darwin) onionshare attempts to discover @@ -123,12 +115,12 @@ rec { onionshare-gui = buildPythonApplication { pname = "onionshare"; inherit version meta; - src = "${src}/desktop/src"; + src = "${src}/desktop"; patches = [ # hardcode store paths of dependencies (substituteAll { src = ./fix-paths-gui.patch; - inherit tor obfs4; + inherit tor meek obfs4 snowflake; inherit (tor) geoip; }) ]; diff --git a/pkgs/applications/networking/onionshare/fix-paths-gui.patch b/pkgs/applications/networking/onionshare/fix-paths-gui.patch index 841af8fa95af..4eb611c860db 100644 --- a/pkgs/applications/networking/onionshare/fix-paths-gui.patch +++ b/pkgs/applications/networking/onionshare/fix-paths-gui.patch @@ -1,25 +1,46 @@ --- a/onionshare/gui_common.py +++ b/onionshare/gui_common.py -@@ -391,29 +391,10 @@ class GuiCommon: +@@ -410,52 +410,12 @@ class GuiCommon: } def get_tor_paths(self): - if self.common.platform == "Linux": -- tor_path = shutil.which("tor") -- obfs4proxy_file_path = shutil.which("obfs4proxy") -- prefix = os.path.dirname(os.path.dirname(tor_path)) -- tor_geo_ip_file_path = os.path.join(prefix, "share/tor/geoip") -- tor_geo_ipv6_file_path = os.path.join(prefix, "share/tor/geoip6") -- elif self.common.platform == "Windows": +- base_path = self.get_resource_path("tor") +- if base_path and os.path.isdir(base_path): +- self.common.log( +- "GuiCommon", "get_tor_paths", "using paths in resources" +- ) +- tor_path = os.path.join(base_path, "tor") +- tor_geo_ip_file_path = os.path.join(base_path, "geoip") +- tor_geo_ipv6_file_path = os.path.join(base_path, "geoip6") +- obfs4proxy_file_path = os.path.join(base_path, "obfs4proxy") +- snowflake_file_path = os.path.join(base_path, "snowflake-client") +- meek_client_file_path = os.path.join(base_path, "meek-client") +- else: +- # Fallback to looking in the path +- self.common.log("GuiCommon", "get_tor_paths", "using paths from PATH") +- tor_path = shutil.which("tor") +- obfs4proxy_file_path = shutil.which("obfs4proxy") +- snowflake_file_path = shutil.which("snowflake-client") +- meek_client_file_path = shutil.which("meek-client") +- prefix = os.path.dirname(os.path.dirname(tor_path)) +- tor_geo_ip_file_path = os.path.join(prefix, "share/tor/geoip") +- tor_geo_ipv6_file_path = os.path.join(prefix, "share/tor/geoip6") +- +- if self.common.platform == "Windows": - base_path = self.get_resource_path("tor") - tor_path = os.path.join(base_path, "Tor", "tor.exe") - obfs4proxy_file_path = os.path.join(base_path, "Tor", "obfs4proxy.exe") +- snowflake_file_path = os.path.join(base_path, "Tor", "snowflake-client.exe") +- meek_client_file_path = os.path.join(base_path, "Tor", "meek-client.exe") - tor_geo_ip_file_path = os.path.join(base_path, "Data", "Tor", "geoip") - tor_geo_ipv6_file_path = os.path.join(base_path, "Data", "Tor", "geoip6") - elif self.common.platform == "Darwin": - base_path = self.get_resource_path("tor") - tor_path = os.path.join(base_path, "tor") - obfs4proxy_file_path = os.path.join(base_path, "obfs4proxy") +- snowflake_file_path = os.path.join(base_path, "snowflake-client") +- meek_client_file_path = os.path.join(base_path, "meek-client") - tor_geo_ip_file_path = os.path.join(base_path, "geoip") - tor_geo_ipv6_file_path = os.path.join(base_path, "geoip6") - elif self.common.platform == "BSD": @@ -27,10 +48,14 @@ - tor_geo_ip_file_path = "/usr/local/share/tor/geoip" - tor_geo_ipv6_file_path = "/usr/local/share/tor/geoip6" - obfs4proxy_file_path = "/usr/local/bin/obfs4proxy" +- meek_client_file_path = "/usr/local/bin/meek-client" +- snowflake_file_path = "/usr/local/bin/snowflake-client" + tor_path = "@tor@/bin/tor" + tor_geo_ip_file_path = "@geoip@/share/tor/geoip" + tor_geo_ipv6_file_path = "@geoip@/share/tor/geoip6" + obfs4proxy_file_path = "@obfs4@/bin/obfs4proxy" ++ meek_client_file_path = "@meek@/bin/meek-client" ++ snowflake_file_path = "@snowflake@/bin/snowflake-client" return ( tor_path, diff --git a/pkgs/applications/networking/onionshare/fix-paths.patch b/pkgs/applications/networking/onionshare/fix-paths.patch index 9280ec4d255a..fec4b4e0395b 100644 --- a/pkgs/applications/networking/onionshare/fix-paths.patch +++ b/pkgs/applications/networking/onionshare/fix-paths.patch @@ -1,41 +1,76 @@ --- a/onionshare_cli/common.py +++ b/onionshare_cli/common.py -@@ -308,33 +308,10 @@ class Common: +@@ -318,67 +318,12 @@ class Common: return path - + def get_tor_paths(self): - if self.platform == "Linux": - tor_path = shutil.which("tor") - if not tor_path: - raise CannotFindTor() - obfs4proxy_file_path = shutil.which("obfs4proxy") +- snowflake_file_path = shutil.which("snowflake-client") +- meek_client_file_path = shutil.which("meek-client") - prefix = os.path.dirname(os.path.dirname(tor_path)) - tor_geo_ip_file_path = os.path.join(prefix, "share/tor/geoip") - tor_geo_ipv6_file_path = os.path.join(prefix, "share/tor/geoip6") - elif self.platform == "Windows": +- # In Windows, the Tor binaries are in the onionshare package, not the onionshare_cli package - base_path = self.get_resource_path("tor") +- base_path = base_path.replace("onionshare_cli", "onionshare") - tor_path = os.path.join(base_path, "Tor", "tor.exe") +- +- # If tor.exe isn't there, mayber we're running from the source tree +- if not os.path.exists(tor_path): +- base_path = os.path.join(os.getcwd(), "onionshare", "resources", "tor") +- +- tor_path = os.path.join(base_path, "Tor", "tor.exe") +- if not os.path.exists(tor_path): +- raise CannotFindTor() +- - obfs4proxy_file_path = os.path.join(base_path, "Tor", "obfs4proxy.exe") +- snowflake_file_path = os.path.join(base_path, "Tor", "snowflake-client.exe") +- meek_client_file_path = os.path.join(base_path, "Tor", "meek-client.exe") - tor_geo_ip_file_path = os.path.join(base_path, "Data", "Tor", "geoip") - tor_geo_ipv6_file_path = os.path.join(base_path, "Data", "Tor", "geoip6") +- - elif self.platform == "Darwin": -- tor_path = shutil.which("tor") -- if not tor_path: -- raise CannotFindTor() -- obfs4proxy_file_path = shutil.which("obfs4proxy") -- prefix = os.path.dirname(os.path.dirname(tor_path)) -- tor_geo_ip_file_path = os.path.join(prefix, "share/tor/geoip") -- tor_geo_ipv6_file_path = os.path.join(prefix, "share/tor/geoip6") +- # Let's see if we have tor binaries in the onionshare GUI package +- base_path = self.get_resource_path("tor") +- base_path = base_path.replace("onionshare_cli", "onionshare") +- tor_path = os.path.join(base_path, "tor") +- if os.path.exists(tor_path): +- obfs4proxy_file_path = os.path.join(base_path, "obfs4proxy") +- snowflake_file_path = os.path.join(base_path, "snowflake-client") +- meek_client_file_path = os.path.join(base_path, "meek-client") +- tor_geo_ip_file_path = os.path.join(base_path, "geoip") +- tor_geo_ipv6_file_path = os.path.join(base_path, "geoip6") +- else: +- # Fallback to looking in the path +- tor_path = shutil.which("tor") +- if not os.path.exists(tor_path): +- raise CannotFindTor() +- +- obfs4proxy_file_path = shutil.which("obfs4proxy") +- snowflake_file_path = shutil.which("snowflake-client") +- meek_client_file_path = shutil.which("meek-client") +- prefix = os.path.dirname(os.path.dirname(tor_path)) +- tor_geo_ip_file_path = os.path.join(prefix, "share/tor/geoip") +- tor_geo_ipv6_file_path = os.path.join(prefix, "share/tor/geoip6") +- - elif self.platform == "BSD": - tor_path = "/usr/local/bin/tor" - tor_geo_ip_file_path = "/usr/local/share/tor/geoip" - tor_geo_ipv6_file_path = "/usr/local/share/tor/geoip6" - obfs4proxy_file_path = "/usr/local/bin/obfs4proxy" +- snowflake_file_path = "/usr/local/bin/snowflake-client" +- meek_client_file_path = "/usr/local/bin/meek-client" + tor_path = "@tor@/bin/tor" + tor_geo_ip_file_path = "@geoip@/share/tor/geoip" + tor_geo_ipv6_file_path = "@geoip@/share/tor/geoip6" + obfs4proxy_file_path = "@obfs4@/bin/obfs4proxy" - ++ snowflake_file_path = "@snowflake@/bin/snowflake-client" ++ meek_client_file_path = "@meek@/bin/meek-client" + return ( tor_path, -