mirror of https://gitlab.com/bashrc2/epicyon
Tidying
parent
011f968a18
commit
3a16200dbe
33
daemon.py
33
daemon.py
|
@ -366,7 +366,7 @@ from fitnessFunctions import fitness_performance
|
|||
from fitnessFunctions import fitness_thread
|
||||
from fitnessFunctions import sorted_watch_points
|
||||
from fitnessFunctions import html_watch_points_graph
|
||||
from siteactive import site_is_active
|
||||
from siteactive import referer_is_active
|
||||
import os
|
||||
|
||||
|
||||
|
@ -1106,19 +1106,11 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self._400()
|
||||
self.server.masto_api_is_active = False
|
||||
return True
|
||||
|
||||
referer_url = http_prefix + '://' + referer_domain
|
||||
if referer_domain + '/' in ua_str:
|
||||
referer_url = referer_url + ua_str.split(referer_domain)[1]
|
||||
if ' ' in referer_url:
|
||||
referer_url = referer_url.split(' ')[0]
|
||||
if ';' in referer_url:
|
||||
referer_url = referer_url.split(';')[0]
|
||||
if ')' in referer_url:
|
||||
referer_url = referer_url.split(')')[0]
|
||||
if not site_is_active(referer_url, calling_site_timeout):
|
||||
if not referer_is_active(http_prefix,
|
||||
referer_domain, ua_str,
|
||||
calling_site_timeout):
|
||||
print('mastodon api referer url is not active ' +
|
||||
referer_url)
|
||||
referer_domain)
|
||||
self._400()
|
||||
self.server.masto_api_is_active = False
|
||||
return True
|
||||
|
@ -1236,18 +1228,11 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.nodeinfo_is_active = False
|
||||
return True
|
||||
|
||||
referer_url = http_prefix + '://' + referer_domain
|
||||
if referer_domain + '/' in ua_str:
|
||||
referer_url = referer_url + ua_str.split(referer_domain)[1]
|
||||
if ' ' in referer_url:
|
||||
referer_url = referer_url.split(' ')[0]
|
||||
if ';' in referer_url:
|
||||
referer_url = referer_url.split(';')[0]
|
||||
if ')' in referer_url:
|
||||
referer_url = referer_url.split(')')[0]
|
||||
if not site_is_active(referer_url, calling_site_timeout):
|
||||
if not referer_is_active(http_prefix,
|
||||
referer_domain, ua_str,
|
||||
calling_site_timeout):
|
||||
print('nodeinfo referer url is not active ' +
|
||||
referer_url)
|
||||
referer_domain)
|
||||
self._400()
|
||||
self.server.nodeinfo_is_active = False
|
||||
return True
|
||||
|
|
|
@ -120,3 +120,18 @@ def site_is_active(url: str, timeout: int) -> bool:
|
|||
except BaseException:
|
||||
print('EX: site_is_active ' + str(loc))
|
||||
return False
|
||||
|
||||
|
||||
def referer_is_active(http_prefix: str,
|
||||
referer_domain: str, ua_str: str,
|
||||
calling_site_timeout: int) -> bool:
|
||||
"""Returns true if the given referer is an active website
|
||||
"""
|
||||
referer_url = http_prefix + '://' + referer_domain
|
||||
if referer_domain + '/' in ua_str:
|
||||
referer_url = referer_url + ua_str.split(referer_domain)[1]
|
||||
ending_chars = (' ', ';', ')')
|
||||
for end_ch in ending_chars:
|
||||
if end_ch in referer_url:
|
||||
referer_url = referer_url.split(end_ch)[0]
|
||||
return site_is_active(referer_url, calling_site_timeout)
|
||||
|
|
Loading…
Reference in New Issue