Skip to content
Browse files

Implement blocking of direct access to images from outside

Closing #6
  • Loading branch information...
1 parent e50cb4b commit ad0ac05586a0d63054e222325ec2a5749ba5aeeb @hellais hellais committed Apr 4, 2012
Showing with 12 additions and 0 deletions.
  1. +12 −0 run.py
View
12 run.py
@@ -160,6 +160,18 @@ def process(self):
self.finish()
return server.NOT_DONE_YET
+ if self.uri.lower().endswith(('gif','jpg','png')):
+ # OMFG this is a monster!
+ # XXX refactor this into another "cleaner" place
+ if not 'referer' in myrequest.headers or ('referer' in myrequest.headers and \
+ not re.search(config.basehost, myrequest.headers['referer'])):
+ if 'referer' in myrequest.headers:
+ print re.search(config.basehost, myrequest.headers['referer'])
+ print "FUck you"
+ self.write(open('static/tor2web-small.png', 'r').read())
+ self.finish()
+ return server.NOT_DONE_YET
+
if config.debug:
print myrequest

0 comments on commit ad0ac05

Please sign in to comment.
Something went wrong with that request. Please try again.