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