Skip to content
Snippets Groups Projects
Commit b88755b3 authored by Klas Arvidsson's avatar Klas Arvidsson
Browse files

squid filter program update

parent 59cebc2c
No related branches found
No related tags found
No related merge requests found
...@@ -14,15 +14,18 @@ hostname = socket.gethostname() ...@@ -14,15 +14,18 @@ hostname = socket.gethostname()
def block_response(url): def block_response(url):
quoted_url = urllib.parse.quote(url) quoted_url = urllib.parse.quote(url)
if re.match('.*\.s?html([#?].*)?', url): if re.match('.*\.s?html([#?].*)?', url) or re.match('.*/[^./]*', url):
return 'OK status=307 url="{}?requested={}"'.format(errorpage, quoted_url) return 'OK status=307 url="{}?requested={}"'.format(errorpage, quoted_url)
else: else:
return 'OK status=307 url="{}"'.format(emptypage) return 'OK status=307 url="{}"'.format(emptypage)
# return "OK status=302 url=\"" + errorpage + "\"" # Note:
# "status" can only be used in the "Using an HTTP redirector" case, # With a redirector squid ask the client to fetch another page.
# not in the "Using a re-writer to mangle the URL as it passes" case # With a re-writer squid ask the web server to fetch the new page.
# RTFM: https://wiki.squid-cache.org/Features/Redirectors # "status" can only be used in the "Using an HTTP redirector" case,
# not in the "Using a re-writer to mangle the URL as it passes" case.
# See:
# https://wiki.squid-cache.org/Features/Redirectors
def modify_url(line, ruleset): def modify_url(line, ruleset):
### [channel-ID <SP>] URL <SP> client_ip "/" fqdn <SP> user <SP> method [<SP> kv-pairs]<NL> ### [channel-ID <SP>] URL <SP> client_ip "/" fqdn <SP> user <SP> method [<SP> kv-pairs]<NL>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment