main
Bob Mottram 2020-06-11 13:04:42 +01:00
parent 136949752f
commit d352b27dd8
2 changed files with 19 additions and 23 deletions

View File

@ -1359,14 +1359,12 @@ def receiveAnnounce(recentPostsCache: {},
messageJson['type'])
return False
prefixes = ('https://', 'http://', 'dat://', 'i2p://', 'gnunet://',
'hyper://', 'gemini://', 'gopher://')
# is the domain of the announce actor blocked?
objectDomain = \
messageJson['object'].replace('https://', '')
objectDomain = objectDomain.replace('http://', '')
objectDomain = objectDomain.replace('i2p://', '')
objectDomain = objectDomain.replace('gnunet://', '')
objectDomain = objectDomain.replace('dat://', '')
objectDomain = objectDomain.replace('hyper://', '')
objectDomain = messageJson['object']
for prefix in prefixes:
objectDomain = objectDomain.replace(prefix, '')
if '/' in objectDomain:
objectDomain = objectDomain.split('/')[0]
if isBlockedDomain(baseDir, objectDomain):

View File

@ -228,30 +228,28 @@ def getDomainFromActor(actor: str) -> (str, int):
"""Returns the domain name from an actor url
"""
port = None
prefixes = ('https://', 'http://', 'dat://', 'i2p://', 'gnunet://',
'hyper://', 'gemini://', 'gopher://')
if '/profile/' in actor:
domain = actor.split('/profile/')[0].replace('https://', '')
domain = domain.replace('http://', '').replace('i2p://', '')
domain = domain.replace('dat://', '').replace('hyper://', '')
domain = domain.replace('gnunet://', '')
domain = actor.split('/profile/')[0]
for prefix in prefixes:
domain = domain.replace(prefix, '')
else:
if '/channel/' in actor:
domain = actor.split('/channel/')[0].replace('https://', '')
domain = domain.replace('http://', '').replace('i2p://', '')
domain = domain.replace('dat://', '').replace('hyper://', '')
domain = domain.replace('gnunet://', '')
domain = actor.split('/channel/')[0]
for prefix in prefixes:
domain = domain.replace(prefix, '')
else:
if '/users/' not in actor:
domain = actor.replace('https://', '').replace('http://', '')
domain = domain.replace('i2p://', '')
domain = domain.replace('dat://', '').replace('hyper://', '')
domain = domain.replace('gnunet://', '')
domain = actor
for prefix in prefixes:
domain = domain.replace(prefix, '')
if '/' in actor:
domain = domain.split('/')[0]
else:
domain = actor.split('/users/')[0].replace('https://', '')
domain = domain.replace('http://', '').replace('i2p://', '')
domain = domain.replace('dat://', '').replace('hyper://', '')
domain = domain.replace('gnunet://', '')
domain = actor.split('/users/')[0]
for prefix in prefixes:
domain = domain.replace(prefix, '')
if ':' in domain:
portStr = domain.split(':')[1]
if not portStr.isdigit():