author | Mahlon E. Smith <mahlon@martini.nu> |
Wed, 28 Sep 2011 09:04:16 -0700 | |
changeset 8 | 8d0f25ef038e |
parent 2 | 8c88756f81b0 |
child 10 | d07309450285 |
permissions | -rw-r--r-- |
0
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
1 |
/* vim: set noet nosta sw=4 ts=4 ft=ragel : */ |
2
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
2 |
/* |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
3 |
Copyright (c) 2011, Mahlon E. Smith <mahlon@martini.nu> |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
4 |
All rights reserved. |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
5 |
Redistribution and use in source and binary forms, with or without |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
6 |
modification, are permitted provided that the following conditions are met: |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
7 |
|
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
8 |
* Redistributions of source code must retain the above copyright |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
9 |
notice, this list of conditions and the following disclaimer. |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
10 |
|
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
11 |
* Redistributions in binary form must reproduce the above copyright |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
12 |
notice, this list of conditions and the following disclaimer in the |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
13 |
documentation and/or other materials provided with the distribution. |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
14 |
|
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
15 |
* Neither the name of Mahlon E. Smith nor the names of his |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
16 |
contributors may be used to endorse or promote products derived |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
17 |
from this software without specific prior written permission. |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
18 |
|
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
19 |
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
20 |
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
21 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
22 |
DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
23 |
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
24 |
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
25 |
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
26 |
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
27 |
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
28 |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
29 |
*/ |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
30 |
|
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
31 |
/* |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
32 |
Squid docs: |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
33 |
--------------------------------------------------------------------------- |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
34 |
TAG: url_rewrite_program |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
35 |
Specify the location of the executable for the URL rewriter. |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
36 |
Since they can perform almost any function there isn't one included. |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
37 |
|
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
38 |
For each requested URL rewriter will receive on line with the format |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
39 |
|
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
40 |
URL <SP> client_ip "/" fqdn <SP> user <SP> method [<SP> kvpairs]<NL> |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
41 |
|
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
42 |
In the future, the rewriter interface will be extended with |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
43 |
key=value pairs ("kvpairs" shown above). Rewriter programs |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
44 |
should be prepared to receive and possibly ignore additional |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
45 |
whitespace-separated tokens on each input line. |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
46 |
|
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
47 |
And the rewriter may return a rewritten URL. The other components of |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
48 |
the request line does not need to be returned (ignored if they are). |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
49 |
|
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
50 |
The rewriter can also indicate that a client-side redirect should |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
51 |
be performed to the new URL. This is done by prefixing the returned |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
52 |
URL with "301:" (moved permanently) or 302: (moved temporarily). |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
53 |
|
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
54 |
By default, a URL rewriter is not used. |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
55 |
--------------------------------------------------------------------------- |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
56 |
*/ |
0
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
57 |
|
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
58 |
#include "volta.h" |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
59 |
|
1
823d42546cea
Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents:
0
diff
changeset
|
60 |
%%{ |
823d42546cea
Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents:
0
diff
changeset
|
61 |
machine redirector; |
823d42546cea
Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents:
0
diff
changeset
|
62 |
|
2
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
63 |
action parse_error { |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
64 |
debug( 2, LOC, "parse error\n" ); |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
65 |
return( NULL ); |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
66 |
} |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
67 |
|
1
823d42546cea
Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents:
0
diff
changeset
|
68 |
action yay { |
2
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
69 |
printf( "I saw: %s", p+1 ); |
1
823d42546cea
Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents:
0
diff
changeset
|
70 |
} |
823d42546cea
Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents:
0
diff
changeset
|
71 |
|
823d42546cea
Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents:
0
diff
changeset
|
72 |
# http://, ftp://, https://, etc |
823d42546cea
Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents:
0
diff
changeset
|
73 |
proto = alpha{3,5} . '://'; |
823d42546cea
Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents:
0
diff
changeset
|
74 |
|
823d42546cea
Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents:
0
diff
changeset
|
75 |
# http://mahlon:password@example.com or http://mahlon@example.com |
823d42546cea
Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents:
0
diff
changeset
|
76 |
# username optional password |
823d42546cea
Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents:
0
diff
changeset
|
77 |
creds = ( alnum | [+._\-] )+ . ( ':' . any+ )? . '@'; |
823d42546cea
Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents:
0
diff
changeset
|
78 |
|
2
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
79 |
main := ( proto . creds ) | proto @yay '\n'; |
1
823d42546cea
Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents:
0
diff
changeset
|
80 |
}%% |
823d42546cea
Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents:
0
diff
changeset
|
81 |
%% write data; |
823d42546cea
Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents:
0
diff
changeset
|
82 |
|
823d42546cea
Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents:
0
diff
changeset
|
83 |
/* |
0
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
84 |
%%{ |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
85 |
machine redirector; |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
86 |
|
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
87 |
action yay { |
2
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
88 |
printf( "I saw: %s", p+1 ); |
0
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
89 |
} |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
90 |
|
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
91 |
# http://, ftp://, https://, etc |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
92 |
proto = alpha{3,5} . '://'; |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
93 |
|
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
94 |
# http://mahlon:password@example.com or http://mahlon@example.com |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
95 |
# username optional password |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
96 |
creds = ( alnum | [+._\-] )+ . ( ':' . any+ )? . '@'; |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
97 |
|
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
98 |
main := ( proto . creds ) | proto @yay '\n'; |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
99 |
}%% |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
100 |
%% write data; |
1
823d42546cea
Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents:
0
diff
changeset
|
101 |
*/ |
0
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
102 |
|
2
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
103 |
|
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
104 |
/* |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
105 |
%%{ |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
106 |
machine foo; |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
107 |
|
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
108 |
OPEN = 0; |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
109 |
CLOSE = 1; |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
110 |
|
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
111 |
main := |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
112 |
start: |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
113 |
door_closed: ( |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
114 |
OPEN -> door_open -> final |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
115 |
), |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
116 |
door_open: ( |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
117 |
CLOSE -> door_closed |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
118 |
); |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
119 |
}%% |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
120 |
*/ |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
121 |
|
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
122 |
struct request * |
0
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
123 |
parse( char *p ) |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
124 |
{ |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
125 |
/* initial machine state */ |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
126 |
short int cs = 0; |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
127 |
|
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
128 |
/* the client request object */ |
2
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
129 |
request c_request; |
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
130 |
request *cp_request = &c_request; |
0
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
131 |
|
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
132 |
/* |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
133 |
char ip[ INET_ADDRSTRLEN ]; |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
134 |
inet_pton( AF_INET, "127.0.0.1", &cp_request->ip ); |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
135 |
inet_ntop( AF_INET, &cp_request->ip, ip, INET_ADDRSTRLEN ); |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
136 |
*/ |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
137 |
|
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
138 |
/* initalize state machine with current line */ |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
139 |
char *pe = p + strlen(p) + 1; |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
140 |
|
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
141 |
/* enter state machine */ |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
142 |
%% write init; |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
143 |
%% write exec; |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
144 |
|
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
145 |
/* reset the request */ |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
146 |
/* c_request = reset_request; */ |
2
8c88756f81b0
Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
147 |
return( cp_request ); |
0
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
148 |
} |
eac7211fe522
Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
149 |