mirror of https://gitlab.com/bashrc2/epicyon
Blocking based on nicknames
parent
6533924ea3
commit
b04aff30cc
16
inbox.py
16
inbox.py
|
@ -63,6 +63,7 @@ from utils import get_actor_from_post
|
||||||
from utils import data_dir
|
from utils import data_dir
|
||||||
from utils import is_dm
|
from utils import is_dm
|
||||||
from utils import has_actor
|
from utils import has_actor
|
||||||
|
from utils import evil_nickname
|
||||||
from status import get_status_number
|
from status import get_status_number
|
||||||
from httpsig import get_digest_algorithm_from_headers
|
from httpsig import get_digest_algorithm_from_headers
|
||||||
from httpsig import verify_post_headers
|
from httpsig import verify_post_headers
|
||||||
|
@ -1460,6 +1461,8 @@ def _is_valid_dm(base_dir: str, nickname: str, domain: str, port: int,
|
||||||
get_nickname_from_actor(sending_actor)
|
get_nickname_from_actor(sending_actor)
|
||||||
if not sending_actor_nickname:
|
if not sending_actor_nickname:
|
||||||
return False
|
return False
|
||||||
|
if evil_nickname(sending_actor_nickname):
|
||||||
|
return False
|
||||||
sending_actor_domain, _ = \
|
sending_actor_domain, _ = \
|
||||||
get_domain_from_actor(sending_actor)
|
get_domain_from_actor(sending_actor)
|
||||||
if not sending_actor_domain:
|
if not sending_actor_domain:
|
||||||
|
@ -3412,6 +3415,19 @@ def run_inbox_queue(server,
|
||||||
curr_session = session
|
curr_session = session
|
||||||
if queue_json.get('actor'):
|
if queue_json.get('actor'):
|
||||||
if isinstance(queue_json['actor'], str):
|
if isinstance(queue_json['actor'], str):
|
||||||
|
# blocking based upon nickname
|
||||||
|
sender_nickname = get_nickname_from_actor(queue_json['actor'])
|
||||||
|
if evil_nickname(sender_nickname):
|
||||||
|
if os.path.isfile(queue_filename):
|
||||||
|
try:
|
||||||
|
os.remove(queue_filename)
|
||||||
|
except OSError:
|
||||||
|
print('EX: run_inbox_queue 11 unable to delete ' +
|
||||||
|
str(queue_filename))
|
||||||
|
if queue:
|
||||||
|
queue.pop(0)
|
||||||
|
continue
|
||||||
|
|
||||||
sender_domain, _ = get_domain_from_actor(queue_json['actor'])
|
sender_domain, _ = get_domain_from_actor(queue_json['actor'])
|
||||||
if sender_domain:
|
if sender_domain:
|
||||||
if sender_domain.endswith('.onion') and \
|
if sender_domain.endswith('.onion') and \
|
||||||
|
|
11
utils.py
11
utils.py
|
@ -995,6 +995,17 @@ def evil_incarnate() -> []:
|
||||||
return ['fedilist.com', 'gab.com', 'gabfed.com', 'spinster.xyz']
|
return ['fedilist.com', 'gab.com', 'gabfed.com', 'spinster.xyz']
|
||||||
|
|
||||||
|
|
||||||
|
def evil_nickname(sending_actor_nickname: str) -> bool:
|
||||||
|
"""sender nicknames which are automatically rejected
|
||||||
|
"""
|
||||||
|
evil_nicks = ('hitler', '1488')
|
||||||
|
nickname_lower = sending_actor_nickname.lower()
|
||||||
|
for nick in evil_nicks:
|
||||||
|
if nick in nickname_lower:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def contains_invalid_chars(json_str: str) -> bool:
|
def contains_invalid_chars(json_str: str) -> bool:
|
||||||
"""Does the given json string contain invalid characters?
|
"""Does the given json string contain invalid characters?
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue