Skip to content

Commit e5c691f

Browse files
vanguards: init at 0.3.1
add derivation for vanguards, a set of scripts that increase security for tor hidden services by protecting against guard discovery attacks resources: https://github.com/mikeperry-tor/vanguards https://spec.torproject.org/vanguards-spec/index.html?highlight=vanguards
1 parent de305ae commit e5c691f

File tree

3 files changed

+95
-0
lines changed

3 files changed

+95
-0
lines changed

maintainers/maintainer-list.nix

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7799,6 +7799,12 @@
77997799
githubId = 24463229;
78007800
name = "Forden";
78017801
};
7802+
ForgottenBeast = {
7803+
email = "[email protected]";
7804+
github = "ForgottenBeast";
7805+
githubId = 5754552;
7806+
name = "ForgottenBeast";
7807+
};
78027808
forkk = {
78037809
email = "[email protected]";
78047810
github = "Forkk";
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
python312Packages,
3+
fetchFromGitHub,
4+
lib,
5+
}:
6+
python312Packages.buildPythonApplication rec {
7+
pname = "vanguards";
8+
version = "0.3.1-unstable-2023-10-31";
9+
10+
dependencies = [ python312Packages.stem ];
11+
#tries to access the network during the tests, which fails
12+
doCheck = false;
13+
14+
src = fetchFromGitHub {
15+
owner = "mikeperry-tor";
16+
repo = "vanguards";
17+
rev = "8132fa0e556fbcbb3538ff9b48a2180c0c5e8fbd";
18+
sha256 = "sha256-XauSTgoH6zXv2DXyX2lQc6gy6Ysm41fKnyuWZ3hj7kI=";
19+
};
20+
patches = [ ./python-3.12.patch ];
21+
postPatch = ''
22+
# fix import cycle issue
23+
substituteInPlace src/vanguards/main.py --replace-fail \
24+
'import stem.response.events' 'import stem.socket; import stem.control; import stem.response.events'
25+
'';
26+
27+
meta = {
28+
maintainers = with lib.maintainers; [ ForgottenBeast ];
29+
mainProgram = "vanguards";
30+
license = lib.licenses.mit;
31+
homepage = "https://github.com/mikeperry-tor/vanguards";
32+
description = "Protects TOR hidden services against guard node attacks";
33+
longDescription = ''
34+
Runs alongside tor and interacts with its control port
35+
in order to protect and alert against guard node attacks on hidden services
36+
'';
37+
};
38+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
Origin: https://github.com/mikeperry-tor/vanguards/pull/105/commits/183d24775521feb3ed61b681088347279c3fc84c
2+
From: Dave Jones <[email protected]>
3+
Date: Wed, 28 Aug 2024 12:54:24 +0100
4+
Subject: [PATCH] Python 3.12 compatibility
5+
6+
Python 3.12 removes the deprecated `SafeConfigParser` class. This patch
7+
switches the code to using ConfigParser and read_file from Python 3.x,
8+
and patches 2.7's SafeConfigParser to a compatible definition.
9+
---
10+
src/vanguards/config.py | 11 +++++++----
11+
1 file changed, 7 insertions(+), 4 deletions(-)
12+
13+
diff --git a/src/vanguards/config.py b/src/vanguards/config.py
14+
index 1c33391..b8e3f9c 100644
15+
--- a/src/vanguards/config.py
16+
+++ b/src/vanguards/config.py
17+
@@ -16,9 +16,12 @@
18+
from .logger import plog
19+
20+
try:
21+
- from configparser import SafeConfigParser, Error
22+
+ from configparser import ConfigParser, Error
23+
except ImportError:
24+
from ConfigParser import SafeConfigParser, Error
25+
+ class ConfigParser(SafeConfigParser):
26+
+ def read_file(self, f, source=None):
27+
+ return self.readfp(f, source)
28+
29+
################# Global options ##################
30+
31+
@@ -209,7 +212,7 @@ def set_options_from_module(config, module, section):
32+
config.set(section, param, str(val))
33+
34+
def generate_config():
35+
- config = SafeConfigParser(allow_no_value=True)
36+
+ config = ConfigParser(allow_no_value=True)
37+
set_options_from_module(config, sys.modules[__name__], "Global")
38+
set_options_from_module(config, vanguards, "Vanguards")
39+
set_options_from_module(config, bandguards, "Bandguards")
40+
@@ -219,9 +222,9 @@ def generate_config():
41+
return config
42+
43+
def apply_config(config_file):
44+
- config = SafeConfigParser(allow_no_value=True)
45+
+ config = ConfigParser(allow_no_value=True)
46+
47+
- config.readfp(open(config_file, "r"))
48+
+ config.read_file(open(config_file, "r"))
49+
50+
get_options_for_module(config, sys.modules[__name__], "Global")
51+
get_options_for_module(config, vanguards, "Vanguards")

0 commit comments

Comments
 (0)