diff --git a/daemon.py b/daemon.py index 4edfd9d21..8ccad81ff 100644 --- a/daemon.py +++ b/daemon.py @@ -267,7 +267,7 @@ from utils import get_occupation_skills from utils import get_occupation_name from utils import set_occupation_name from utils import load_translations_from_file -from utils import getLocalNetworkAddresses +from utils import get_local_network_addresses from utils import decoded_host from utils import isPublicPost from utils import get_locked_account @@ -1447,7 +1447,7 @@ class PubServer(BaseHTTPRequestHandler): # sent by an actor on a local network address? if not self.server.allow_local_network_access: - localNetworkPatternList = getLocalNetworkAddresses() + localNetworkPatternList = get_local_network_addresses() for localNetworkPattern in localNetworkPatternList: if localNetworkPattern in message_json['actor']: print('POST actor contains local network address ' + diff --git a/outbox.py b/outbox.py index 6e9d93ee3..6a38eaa39 100644 --- a/outbox.py +++ b/outbox.py @@ -19,7 +19,7 @@ from posts import sendToNamedAddressesThread from utils import has_object_stringType from utils import get_base_content_from_post from utils import has_object_dict -from utils import getLocalNetworkAddresses +from utils import get_local_network_addresses from utils import get_full_domain from utils import remove_id_ending from utils import get_domain_from_actor @@ -274,7 +274,7 @@ def postMessageToOutbox(session, translate: {}, # sent by an actor on a local network address? if not allow_local_network_access: - localNetworkPatternList = getLocalNetworkAddresses() + localNetworkPatternList = get_local_network_addresses() for localNetworkPattern in localNetworkPatternList: if localNetworkPattern in message_json['actor']: return False diff --git a/utils.py b/utils.py index 72cf7e327..f9b7d0d84 100644 --- a/utils.py +++ b/utils.py @@ -635,14 +635,14 @@ def get_link_prefixes() -> []: 'hyper://', 'gemini://', 'gopher://', 'briar:') -def remove_avatar_from_cache(base_dir: str, actorStr: str) -> None: +def remove_avatar_from_cache(base_dir: str, actor_str: str) -> None: """Removes any existing avatar entries from the cache This avoids duplicate entries with differing extensions """ avatar_filename_extensions = get_image_extensions() for extension in avatar_filename_extensions: avatar_filename = \ - base_dir + '/cache/avatars/' + actorStr + '.' + extension + base_dir + '/cache/avatars/' + actor_str + '.' + extension if os.path.isfile(avatar_filename): try: os.remove(avatar_filename) @@ -739,6 +739,8 @@ def get_status_number(published_str: str = None) -> (str, str): def evil_incarnate() -> []: + """Hardcoded blocked domains + """ return ('fedilist.com', 'gab.com', 'gabfed.com', 'spinster.xyz', 'kiwifarms.cc', 'djitter.com') @@ -832,7 +834,7 @@ def urlPermitted(url: str, federation_list: []): return False -def getLocalNetworkAddresses() -> []: +def get_local_network_addresses() -> []: """Returns patterns for local network address detection """ return ('localhost', '127.0.', '192.168', '10.0.') @@ -841,7 +843,7 @@ def getLocalNetworkAddresses() -> []: def isLocalNetworkAddress(ipAddress: str) -> bool: """ """ - localIPs = getLocalNetworkAddresses() + localIPs = get_local_network_addresses() for ipAddr in localIPs: if ipAddress.startswith(ipAddr): return True @@ -862,7 +864,7 @@ def _isDangerousString(content: str, allow_local_network_access: bool, contentSections = content.split(startChar) invalidPartials = () if not allow_local_network_access: - invalidPartials = getLocalNetworkAddresses() + invalidPartials = get_local_network_addresses() for markup in contentSections: if endChar not in markup: continue