1{
2 lib,
3 stdenv,
4 aiohttp,
5 async-timeout,
6 attrs,
7 buildPythonPackage,
8 cryptography,
9 fetchFromGitHub,
10 pytest-aiohttp,
11 pytest-codspeed,
12 pytestCheckHook,
13 pythonAtLeast,
14 pythonOlder,
15 setuptools,
16}:
17
18buildPythonPackage rec {
19 pname = "snitun";
20 version = "0.45.0";
21 pyproject = true;
22
23 disabled = pythonOlder "3.10";
24
25 src = fetchFromGitHub {
26 owner = "NabuCasa";
27 repo = "snitun";
28 tag = version;
29 hash = "sha256-LAl6En7qMiGeKciY6UIOgtfaCdHqx/T/ohv9vQvk9gE=";
30 };
31
32 postPatch = ''
33 substituteInPlace pyproject.toml \
34 --replace-fail 'version = "0.0.0"' 'version = "${version}"'
35 '';
36
37 build-system = [ setuptools ];
38
39 dependencies = [
40 aiohttp
41 async-timeout
42 attrs
43 cryptography
44 ];
45
46 nativeCheckInputs = [
47 pytest-aiohttp
48 pytest-codspeed
49 pytestCheckHook
50 ];
51
52 disabledTests = [
53 # AssertionError: Expected 'fileno' to not have been called. Called 1 times.
54 "test_client_stop_no_wait"
55 ]
56 ++ lib.optionals stdenv.hostPlatform.isDarwin [
57 "test_multiplexer_data_channel_abort_full" # https://github.com/NabuCasa/snitun/issues/61
58 # port binding conflicts
59 "test_snitun_single_runner_timeout"
60 "test_snitun_single_runner_throttling"
61 # ConnectionResetError: [Errno 54] Connection reset by peer
62 "test_peer_listener_timeout"
63 ]
64 ++ lib.optionals (pythonAtLeast "3.12") [
65 # blocking
66 "test_flow_client_peer"
67 "test_close_client_peer"
68 "test_init_connector"
69 "test_flow_connector"
70 "test_close_connector_remote"
71 "test_init_connector_whitelist"
72 "test_init_multiplexer_server"
73 "test_init_multiplexer_client"
74 "test_init_multiplexer_server_throttling"
75 "test_init_multiplexer_client_throttling"
76 "test_multiplexer_ping"
77 "test_multiplexer_ping_error"
78 "test_multiplexer_init_channel_full"
79 "test_multiplexer_close_channel_full"
80 "test_init_dual_peer_with_multiplexer"
81 ];
82
83 pythonImportsCheck = [ "snitun" ];
84
85 meta = with lib; {
86 description = "SNI proxy with TCP multiplexer";
87 changelog = "https://github.com/NabuCasa/snitun/releases/tag/${src.tag}";
88 homepage = "https://github.com/nabucasa/snitun";
89 license = licenses.gpl3Only;
90 maintainers = with maintainers; [ Scriptkiddi ];
91 platforms = platforms.linux;
92 };
93}