1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-18 19:51:17 +00:00

Merge pull request #155457 from lourkeur/update/onionshare

This commit is contained in:
Sandro 2022-01-24 01:08:11 +01:00 committed by GitHub
commit 140f7552b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 145 additions and 36 deletions

View file

@ -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;
})
];

View file

@ -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,

View file

@ -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,

View file

@ -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 ];
};
}

View file

@ -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;
};
}

View file

@ -1162,6 +1162,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;
};

View file

@ -1487,6 +1487,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 { };