Skip to content

Commit

Permalink
vanguards: init at 0.3.1 (#377105)
Browse files Browse the repository at this point in the history
  • Loading branch information
FliegendeWurst authored Jan 28, 2025
2 parents 4920c34 + e5c691f commit 5ecbe31
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 0 deletions.
6 changes: 6 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7810,6 +7810,12 @@
githubId = 24463229;
name = "Forden";
};
ForgottenBeast = {
email = "[email protected]";
github = "ForgottenBeast";
githubId = 5754552;
name = "ForgottenBeast";
};
forkk = {
email = "[email protected]";
github = "Forkk";
Expand Down
38 changes: 38 additions & 0 deletions pkgs/by-name/va/vanguards/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
python312Packages,
fetchFromGitHub,
lib,
}:
python312Packages.buildPythonApplication rec {
pname = "vanguards";
version = "0.3.1-unstable-2023-10-31";

dependencies = [ python312Packages.stem ];
#tries to access the network during the tests, which fails
doCheck = false;

src = fetchFromGitHub {
owner = "mikeperry-tor";
repo = "vanguards";
rev = "8132fa0e556fbcbb3538ff9b48a2180c0c5e8fbd";
sha256 = "sha256-XauSTgoH6zXv2DXyX2lQc6gy6Ysm41fKnyuWZ3hj7kI=";
};
patches = [ ./python-3.12.patch ];
postPatch = ''
# fix import cycle issue
substituteInPlace src/vanguards/main.py --replace-fail \
'import stem.response.events' 'import stem.socket; import stem.control; import stem.response.events'
'';

meta = {
maintainers = with lib.maintainers; [ ForgottenBeast ];
mainProgram = "vanguards";
license = lib.licenses.mit;
homepage = "https://github.com/mikeperry-tor/vanguards";
description = "Protects TOR hidden services against guard node attacks";
longDescription = ''
Runs alongside tor and interacts with its control port
in order to protect and alert against guard node attacks on hidden services
'';
};
}
51 changes: 51 additions & 0 deletions pkgs/by-name/va/vanguards/python-3.12.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Origin: https://github.com/mikeperry-tor/vanguards/pull/105/commits/183d24775521feb3ed61b681088347279c3fc84c
From: Dave Jones <[email protected]>
Date: Wed, 28 Aug 2024 12:54:24 +0100
Subject: [PATCH] Python 3.12 compatibility

Python 3.12 removes the deprecated `SafeConfigParser` class. This patch
switches the code to using ConfigParser and read_file from Python 3.x,
and patches 2.7's SafeConfigParser to a compatible definition.
---
src/vanguards/config.py | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/vanguards/config.py b/src/vanguards/config.py
index 1c33391..b8e3f9c 100644
--- a/src/vanguards/config.py
+++ b/src/vanguards/config.py
@@ -16,9 +16,12 @@
from .logger import plog

try:
- from configparser import SafeConfigParser, Error
+ from configparser import ConfigParser, Error
except ImportError:
from ConfigParser import SafeConfigParser, Error
+ class ConfigParser(SafeConfigParser):
+ def read_file(self, f, source=None):
+ return self.readfp(f, source)

################# Global options ##################

@@ -209,7 +212,7 @@ def set_options_from_module(config, module, section):
config.set(section, param, str(val))

def generate_config():
- config = SafeConfigParser(allow_no_value=True)
+ config = ConfigParser(allow_no_value=True)
set_options_from_module(config, sys.modules[__name__], "Global")
set_options_from_module(config, vanguards, "Vanguards")
set_options_from_module(config, bandguards, "Bandguards")
@@ -219,9 +222,9 @@ def generate_config():
return config

def apply_config(config_file):
- config = SafeConfigParser(allow_no_value=True)
+ config = ConfigParser(allow_no_value=True)

- config.readfp(open(config_file, "r"))
+ config.read_file(open(config_file, "r"))

get_options_for_module(config, sys.modules[__name__], "Global")
get_options_for_module(config, vanguards, "Vanguards")

0 comments on commit 5ecbe31

Please sign in to comment.