mirror of https://gitlab.com/bashrc2/epicyon
Get referer domain
parent
7845d53408
commit
336a71f162
23
daemon.py
23
daemon.py
|
@ -6647,7 +6647,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
return
|
return
|
||||||
self._404()
|
self._404()
|
||||||
|
|
||||||
def _showCachedAvatar(self, callingDomain: str, path: str,
|
def _showCachedAvatar(self, refererDomain: str, path: str,
|
||||||
baseDir: str,
|
baseDir: str,
|
||||||
GETstartTime, GETtimings: {}) -> None:
|
GETstartTime, GETtimings: {}) -> None:
|
||||||
"""Shows an avatar image obtained from the cache
|
"""Shows an avatar image obtained from the cache
|
||||||
|
@ -6664,7 +6664,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self._set_headers_etag(mediaFilename,
|
self._set_headers_etag(mediaFilename,
|
||||||
mimeType,
|
mimeType,
|
||||||
mediaBinary, None,
|
mediaBinary, None,
|
||||||
self.server.domainFull,
|
refererDomain,
|
||||||
False, None)
|
False, None)
|
||||||
self._write(mediaBinary)
|
self._write(mediaBinary)
|
||||||
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
||||||
|
@ -11205,7 +11205,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
'share files shown')
|
'share files shown')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _showAvatarOrBanner(self, callingDomain: str, path: str,
|
def _showAvatarOrBanner(self, refererDomain: str, path: str,
|
||||||
baseDir: str, domain: str,
|
baseDir: str, domain: str,
|
||||||
GETstartTime, GETtimings: {}) -> bool:
|
GETstartTime, GETtimings: {}) -> bool:
|
||||||
"""Shows an avatar or banner or profile background image
|
"""Shows an avatar or banner or profile background image
|
||||||
|
@ -11259,7 +11259,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
mediaBinary = avFile.read()
|
mediaBinary = avFile.read()
|
||||||
self._set_headers_etag(avatarFilename, mediaImageType,
|
self._set_headers_etag(avatarFilename, mediaImageType,
|
||||||
mediaBinary, None,
|
mediaBinary, None,
|
||||||
None, True,
|
refererDomain, True,
|
||||||
lastModifiedTimeStr)
|
lastModifiedTimeStr)
|
||||||
self._write(mediaBinary)
|
self._write(mediaBinary)
|
||||||
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
self._benchmarkGETtimings(GETstartTime, GETtimings,
|
||||||
|
@ -11627,6 +11627,17 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
self._400()
|
self._400()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# which domain is the GET request coming from?
|
||||||
|
refererDomain = None
|
||||||
|
if self.headers.get('referer'):
|
||||||
|
refererDomain, refererPort = \
|
||||||
|
getDomainFromActor(self.headers['referer'])
|
||||||
|
refererDomain = getFullDomain(refererDomain, refererPort)
|
||||||
|
elif self.headers.get('Referer'):
|
||||||
|
refererDomain, refererPort = \
|
||||||
|
getDomainFromActor(self.headers['Referer'])
|
||||||
|
refererDomain = getFullDomain(refererDomain, refererPort)
|
||||||
|
|
||||||
if self._blockedUserAgent(callingDomain):
|
if self._blockedUserAgent(callingDomain):
|
||||||
self._400()
|
self._400()
|
||||||
return
|
return
|
||||||
|
@ -13027,7 +13038,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
# cached avatar images
|
# cached avatar images
|
||||||
# Note that this comes before the busy flag to avoid conflicts
|
# Note that this comes before the busy flag to avoid conflicts
|
||||||
if self.path.startswith('/avatars/'):
|
if self.path.startswith('/avatars/'):
|
||||||
self._showCachedAvatar(self.server.domainFull, self.path,
|
self._showCachedAvatar(refererDomain, self.path,
|
||||||
self.server.baseDir,
|
self.server.baseDir,
|
||||||
GETstartTime, GETtimings)
|
GETstartTime, GETtimings)
|
||||||
return
|
return
|
||||||
|
@ -13038,7 +13049,7 @@ class PubServer(BaseHTTPRequestHandler):
|
||||||
|
|
||||||
# show avatar or background image
|
# show avatar or background image
|
||||||
# Note that this comes before the busy flag to avoid conflicts
|
# Note that this comes before the busy flag to avoid conflicts
|
||||||
if self._showAvatarOrBanner(callingDomain, self.path,
|
if self._showAvatarOrBanner(refererDomain, self.path,
|
||||||
self.server.baseDir,
|
self.server.baseDir,
|
||||||
self.server.domain,
|
self.server.domain,
|
||||||
GETstartTime, GETtimings):
|
GETstartTime, GETtimings):
|
||||||
|
|
Loading…
Reference in New Issue