feat(block): adds bridge_block_scriptzteam module
This commit is contained in:
parent
64d74c0a57
commit
c34dab7b9a
3 changed files with 46 additions and 0 deletions
|
@ -16,6 +16,7 @@ from app.terraform.block.bridge_dnsc import BlockBridgeDnscAutomation
|
||||||
from app.terraform.block.bridge_github import BlockBridgeGitHubAutomation
|
from app.terraform.block.bridge_github import BlockBridgeGitHubAutomation
|
||||||
from app.terraform.block.bridge_gitlab import BlockBridgeGitlabAutomation
|
from app.terraform.block.bridge_gitlab import BlockBridgeGitlabAutomation
|
||||||
from app.terraform.block.bridge_roskomsvoboda import BlockBridgeRoskomsvobodaAutomation
|
from app.terraform.block.bridge_roskomsvoboda import BlockBridgeRoskomsvobodaAutomation
|
||||||
|
from app.terraform.block.block_scriptzteam import BlockBridgeScriptzteamAutomation
|
||||||
from app.terraform.block_external import BlockExternalAutomation
|
from app.terraform.block_external import BlockExternalAutomation
|
||||||
from app.terraform.block_ooni import BlockOONIAutomation
|
from app.terraform.block_ooni import BlockOONIAutomation
|
||||||
from app.terraform.block_roskomsvoboda import BlockRoskomsvobodaAutomation
|
from app.terraform.block_roskomsvoboda import BlockRoskomsvobodaAutomation
|
||||||
|
@ -47,6 +48,7 @@ jobs = {
|
||||||
BlockBridgeGitHubAutomation,
|
BlockBridgeGitHubAutomation,
|
||||||
BlockBridgeGitlabAutomation,
|
BlockBridgeGitlabAutomation,
|
||||||
BlockBridgeRoskomsvobodaAutomation,
|
BlockBridgeRoskomsvobodaAutomation,
|
||||||
|
BlockBridgeScriptzteamAutomation,
|
||||||
BlockExternalAutomation,
|
BlockExternalAutomation,
|
||||||
BlockOONIAutomation,
|
BlockOONIAutomation,
|
||||||
BlockRoskomsvobodaAutomation,
|
BlockRoskomsvobodaAutomation,
|
||||||
|
@ -132,6 +134,8 @@ def run_job(job_cls: Type[BaseAutomation], *,
|
||||||
# to be logged for investigation. Catching more specific exceptions would just mean that
|
# to be logged for investigation. Catching more specific exceptions would just mean that
|
||||||
# others go unrecorded and are difficult to debug.
|
# others go unrecorded and are difficult to debug.
|
||||||
except Exception as exc: # pylint: disable=broad-except
|
except Exception as exc: # pylint: disable=broad-except
|
||||||
|
if logging.getLogger().level == logging.DEBUG:
|
||||||
|
raise exc
|
||||||
trace = TracebackException.from_exception(exc)
|
trace = TracebackException.from_exception(exc)
|
||||||
success = False
|
success = False
|
||||||
logs = "\n".join(trace.format())
|
logs = "\n".join(trace.format())
|
||||||
|
|
20
app/terraform/block/block_scriptzteam.py
Normal file
20
app/terraform/block/block_scriptzteam.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import requests
|
||||||
|
|
||||||
|
from app.terraform.block.bridge_bridgelines import BlockBridgelinesAutomation
|
||||||
|
|
||||||
|
|
||||||
|
class BlockBridgeScriptzteamAutomation(BlockBridgelinesAutomation):
|
||||||
|
"""
|
||||||
|
Automation task to rotate bridges discovered by scriptzteam.
|
||||||
|
"""
|
||||||
|
|
||||||
|
short_name = "block_bridge_scriptzteam"
|
||||||
|
description = "Import bridges discovered by scriptzteam from GitHub"
|
||||||
|
frequency = 300 # They only update every couple of days as of February 2023
|
||||||
|
|
||||||
|
def fetch(self) -> None:
|
||||||
|
r = requests.get(
|
||||||
|
"https://raw.githubusercontent.com/scriptzteam/Tor-Bridges-Collector/main/bridges-obfs4")
|
||||||
|
r.encoding = "utf-8"
|
||||||
|
contents = r.text
|
||||||
|
self._lines = contents.splitlines()
|
22
app/terraform/block/bridge_bridgelines.py
Normal file
22
app/terraform/block/bridge_bridgelines.py
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
import logging
|
||||||
|
from abc import ABC
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
from app.terraform.block.bridge import BlockBridgeAutomation
|
||||||
|
|
||||||
|
|
||||||
|
class BlockBridgelinesAutomation(BlockBridgeAutomation, ABC):
|
||||||
|
|
||||||
|
_lines: List[str]
|
||||||
|
|
||||||
|
def parse(self) -> None:
|
||||||
|
for line in self._lines:
|
||||||
|
parts = line.split(" ")
|
||||||
|
try:
|
||||||
|
ip_address = parts[1].split(":")[0]
|
||||||
|
fingerprint = parts[2]
|
||||||
|
self.ips.append(ip_address)
|
||||||
|
self.fingerprints.append(fingerprint)
|
||||||
|
logging.debug(f"Added blocked bridge with IP {ip_address} and fingerprint {fingerprint}")
|
||||||
|
except IndexError:
|
||||||
|
logging.warning("A parsing error occured.")
|
Loading…
Add table
Add a link
Reference in a new issue