# HG changeset patch # User Mahlon E. Smith # Date 1433892976 25200 # Node ID ba41bfbe87a2d799adf5e7763c3d58c0c5c76af9 # Parent 6dc2d52e4b13b8498159834d63cfc5f65fbc9a75 Updates to support the newer Squid rewrite syntax. diff -r 6dc2d52e4b13 -r ba41bfbe87a2 README --- a/README Tue Jun 09 12:01:57 2015 -0700 +++ b/README Tue Jun 09 16:36:16 2015 -0700 @@ -51,8 +51,7 @@ if you find that to be more efficient for your environment. Adjust to taste. - url_rewrite_concurrency 60 - url_rewrite_children 5 + url_rewrite_children 5 startup=1 idle=2 concurrency=50 Using volta diff -r 6dc2d52e4b13 -r ba41bfbe87a2 examples/lua-example.lua --- a/examples/lua-example.lua Tue Jun 09 12:01:57 2015 -0700 +++ b/examples/lua-example.lua Tue Jun 09 16:36:16 2015 -0700 @@ -13,6 +13,6 @@ -- how easy it is to do custom stuff. -- if os.time() % 2 == 0 then - return string.format( "%d:http://example.com%s", redir, request.path ) + return string.format( "OK status=%d url=http://example.com%s", redir, request.path ) end diff -r 6dc2d52e4b13 -r ba41bfbe87a2 examples/rules.txt --- a/examples/rules.txt Tue Jun 09 12:01:57 2015 -0700 +++ b/examples/rules.txt Tue Jun 09 16:36:16 2015 -0700 @@ -10,7 +10,7 @@ google.com * 302:https://www.google.com # Transparently alter all uploaded images on imgur to be my face: :) -i.imgur.com \.(gif|png|jpg)$ http://www.martini.nu/images/mahlon.jpg +i.imgur.com \.(gif|png|jpg)$ http://www.martini.nu/img/mahlon.jpg # Expand a local, non qualified hostname to a FQDN (useful alongside the # 'dns_defnames' squid setting to enforce browser proxy behaviors): diff -r 6dc2d52e4b13 -r ba41bfbe87a2 parser.rl --- a/parser.rl Tue Jun 09 12:01:57 2015 -0700 +++ b/parser.rl Tue Jun 09 16:36:16 2015 -0700 @@ -1,6 +1,6 @@ /* vim: set noet nosta sw=4 ts=4 ft=ragel : */ /* -Copyright (c) 2011, Mahlon E. Smith +Copyright (c) 2011-2015, Mahlon E. Smith All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff -r 6dc2d52e4b13 -r ba41bfbe87a2 process.c --- a/process.c Tue Jun 09 12:01:57 2015 -0700 +++ b/process.c Tue Jun 09 16:36:16 2015 -0700 @@ -132,8 +132,8 @@ return; } - if ( request && request->chid ) printf( "%s", request->chid ); - printf( "\n" ); + if ( request && request->chid ) printf( "%s ", request->chid ); + printf( "ERR\n" ); fflush( stdout ); finish_parsed( rule ); @@ -152,7 +152,18 @@ if ( rule == NULL || v.debugmode >= 5 ) return; if ( request->chid ) printf( "%s", request->chid ); - if ( rule->redir ) printf( "%s:", rule->redir ); + printf( "OK " ); + + /* Redirect */ + if ( rule->redir ) { + printf( "status=%s url=", rule->redir ); + } + + /* Rewrite */ + else { + printf( "rewrite-url=" ); + } + printf( "%s%s", (rule->scheme ? rule->scheme : request->scheme), rule->host ); if ( rule->port ) printf( ":%s", rule->port ); printf( "%s", rule->path ? rule->path : request->path ); diff -r 6dc2d52e4b13 -r ba41bfbe87a2 volta.h --- a/volta.h Tue Jun 09 12:01:57 2015 -0700 +++ b/volta.h Tue Jun 09 16:36:16 2015 -0700 @@ -58,7 +58,7 @@ */ #ifdef DEBUG -#include +#include #endif /* Default line size we accept from squid, longer lines (huge URLs?) malloc. */