mirror of https://gitlab.com/bashrc2/epicyon
Some endpoints with basic info are available to crawlers
parent
4406bb768e
commit
afa3e99260
20
daemon.py
20
daemon.py
|
@ -12271,6 +12271,16 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
uaStr = self.headers['User-agent']
|
uaStr = self.headers['User-agent']
|
||||||
return uaStr
|
return uaStr
|
||||||
|
|
||||||
|
def _permittedCrawlerPath(self, path: str) -> bool:
|
||||||
|
"""Is the given path permitted to be crawled by a search engine?
|
||||||
|
this should only allow through basic information, such as nodeinfo
|
||||||
|
"""
|
||||||
|
if path == '/' or path == '/about' or \
|
||||||
|
path.startswith('/api/') or \
|
||||||
|
path.startswith('/nodeinfo/'):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def do_GET(self):
|
def do_GET(self):
|
||||||
callingDomain = self.server.domainFull
|
callingDomain = self.server.domainFull
|
||||||
|
|
||||||
|
@ -12299,9 +12309,10 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
uaStr = self._getUserAgent()
|
uaStr = self._getUserAgent()
|
||||||
|
|
||||||
if self._blockedUserAgent(callingDomain, uaStr):
|
if not self._permittedCrawlerPath(self.path):
|
||||||
self._400()
|
if self._blockedUserAgent(callingDomain, uaStr):
|
||||||
return
|
self._400()
|
||||||
|
return
|
||||||
|
|
||||||
refererDomain = self._getRefererDomain(uaStr)
|
refererDomain = self._getRefererDomain(uaStr)
|
||||||
|
|
||||||
|
@ -13698,6 +13709,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
GETstartTime)
|
GETstartTime)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# show a background image on the login or person options page
|
||||||
if '-background.' in self.path:
|
if '-background.' in self.path:
|
||||||
if self._showBackgroundImage(callingDomain, self.path,
|
if self._showBackgroundImage(callingDomain, self.path,
|
||||||
self.server.baseDir,
|
self.server.baseDir,
|
||||||
|
@ -13887,6 +13899,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'_GET', 'login shown done',
|
'_GET', 'login shown done',
|
||||||
self.server.debug)
|
self.server.debug)
|
||||||
|
|
||||||
|
# the newswire screen on mobile
|
||||||
if htmlGET and self.path.startswith('/users/') and \
|
if htmlGET and self.path.startswith('/users/') and \
|
||||||
self.path.endswith('/newswiremobile'):
|
self.path.endswith('/newswiremobile'):
|
||||||
if (authorized or
|
if (authorized or
|
||||||
|
@ -14656,6 +14669,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'_GET', 'post replies done',
|
'_GET', 'post replies done',
|
||||||
self.server.debug)
|
self.server.debug)
|
||||||
|
|
||||||
|
# roles on profile screen
|
||||||
if self.path.endswith('/roles') and usersInPath:
|
if self.path.endswith('/roles') and usersInPath:
|
||||||
if self._showRoles(authorized,
|
if self._showRoles(authorized,
|
||||||
callingDomain, self.path,
|
callingDomain, self.path,
|
||||||
|
|
Loading…
Reference in New Issue