volta.h
author Mahlon E. Smith <mahlon@laika.com>
Mon, 31 Oct 2011 17:17:07 -0700
changeset 13 23a242d7b7fa
parent 12 191b3c25974a
child 14 51eb85ae4de4
permissions -rw-r--r--
1st iteration of volta actually doing something. Process the request, find the best matching rule, and rewrite the request. Without the DB queries, volta was parsing over 750k requests a second. Currently, it's down to 129.5 with 1161 rules in place. Yikes. I may need to re-evaluate some design choices here.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
     1
/* vim: set noet nosta sw=4 ts=4 ft=c : */
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
*/
0
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    30
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    31
#ifndef _VOLTA_H
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    32
#define _VOLTA_H
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    33
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    34
#ifndef PROG
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    35
#define PROG    "volta"
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    36
#endif
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    37
#define VERSION "$Version$" /* expanded by mercurial */
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    38
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    39
#include <stdio.h>
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    40
#include <stdlib.h>
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    41
#include <stdarg.h>
2
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
    42
#include <errno.h>
0
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    43
#include <string.h>
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    44
#include <unistd.h>
1
823d42546cea Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents: 0
diff changeset
    45
#include <time.h>
4
5701b7859a31 Groundwork for automatic database initialization and schema upgrades.
Mahlon E. Smith <mahlon@laika.com>
parents: 2
diff changeset
    46
#include <sys/stat.h>
10
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    47
#include <signal.h>
0
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    48
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    49
#include <sys/types.h>
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    50
#include <sys/socket.h>
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    51
#include <netinet/in.h>
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    52
#include <arpa/inet.h>
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    53
2
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
    54
#ifdef DEBUG
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
    55
#include <google/profiler.h>
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
    56
#endif
0
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    57
2
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
    58
/* Default line size we accept from squid, longer lines (huge URLs?) malloc. */
0
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    59
#define LINE_BUFSIZE 2048
10
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    60
/* Ceiling for how many bytes can be allocated at one for a single line. */
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    61
#define LINE_MAX 256000 /* 250k */
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    62
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    63
/* Redirect types */
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    64
#define REDIR_TEMPORARY   0
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    65
#define REDIR_PERMANENT   1
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    66
#define REDIR_TRANSPARENT 2
0
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
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
/* Aid debugging */
823d42546cea Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents: 0
diff changeset
    69
#define LOC __FILE__, __LINE__
4
5701b7859a31 Groundwork for automatic database initialization and schema upgrades.
Mahlon E. Smith <mahlon@laika.com>
parents: 2
diff changeset
    70
10
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    71
/*
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    72
 * a global struct for easy access to common vars 
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    73
 *
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    74
 */
4
5701b7859a31 Groundwork for automatic database initialization and schema upgrades.
Mahlon E. Smith <mahlon@laika.com>
parents: 2
diff changeset
    75
struct v_globals {
5701b7859a31 Groundwork for automatic database initialization and schema upgrades.
Mahlon E. Smith <mahlon@laika.com>
parents: 2
diff changeset
    76
	unsigned short int debugmode; /* debug level */
5701b7859a31 Groundwork for automatic database initialization and schema upgrades.
Mahlon E. Smith <mahlon@laika.com>
parents: 2
diff changeset
    77
	char dbname[128];             /* path to database file */
5701b7859a31 Groundwork for automatic database initialization and schema upgrades.
Mahlon E. Smith <mahlon@laika.com>
parents: 2
diff changeset
    78
	struct sqlite3 *db;           /* database handle */
10
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    79
13
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
    80
	/* prepared statements */
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
    81
	struct {
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
    82
		struct sqlite3_stmt *match_request;
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
    83
		struct sqlite3_stmt *get_rewrite_rule;
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
    84
	} db_stmt;
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
    85
10
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    86
	struct {
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    87
		time_t start;            /* start time */
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    88
		unsigned long int lines; /* line count for determining speed */
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    89
	} timer;
4
5701b7859a31 Groundwork for automatic database initialization and schema upgrades.
Mahlon E. Smith <mahlon@laika.com>
parents: 2
diff changeset
    90
};
5701b7859a31 Groundwork for automatic database initialization and schema upgrades.
Mahlon E. Smith <mahlon@laika.com>
parents: 2
diff changeset
    91
extern struct v_globals v;        /* defined in main.c */
1
823d42546cea Dial in the Makefile and command line option parsing. Better debug
Mahlon E. Smith <mahlon@laika.com>
parents: 0
diff changeset
    92
10
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    93
/*
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    94
 * The parsed attributes from the request line, as given to us by squid.
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    95
 *
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    96
 */
0
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    97
typedef struct request {
10
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
    98
	char   *scheme;
0
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    99
	char   *host;
12
191b3c25974a Clean up redundant parser actions via preprocessor macros, add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   100
	char   *tld;
10
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   101
	char   *path;
13
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
   102
	unsigned short int port;
10
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   103
	struct in_addr *client_ip;
0
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   104
	char   *user;
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   105
	char   *method;
10
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   106
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   107
	struct {
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   108
		char *scheme_start;
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   109
		char *host_start;
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   110
		char *port_start;
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   111
		char *path_start;
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   112
		char *meth_start;
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   113
		char *c_ip_start;
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   114
		unsigned short int scheme_length;
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   115
		unsigned short int host_length;
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   116
		unsigned short int port_length;
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   117
		unsigned short int path_length;
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   118
		unsigned short int meth_length;
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   119
		unsigned short int c_ip_length;
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   120
	} tokens;
0
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   121
} request;
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   122
2
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
   123
/*
13
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
   124
 * The URL elements to rewrite a user's request into.
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
   125
 *
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
   126
 */
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
   127
typedef struct rewrite {
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
   128
	char *scheme;
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
   129
	char *host;
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
   130
	char *path;
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
   131
	unsigned short int port;
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
   132
	unsigned short int redir;
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
   133
} rewrite;
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
   134
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
   135
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
   136
/*
2
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
   137
 *
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
   138
 * Function prototypes
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
   139
 *
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
   140
 */
9
bdf20e6eefd7 Ansi-fy getopt function and variable declarations.
Mahlon E. Smith <mahlon@martini.nu>
parents: 4
diff changeset
   141
int getopt( int, char * const [], const char *);
2
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
   142
10
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   143
void usage( char * );
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   144
void debug( int, char *, int, const char *, ... );
12
191b3c25974a Clean up redundant parser actions via preprocessor macros, add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   145
void out( const char * );
191b3c25974a Clean up redundant parser actions via preprocessor macros, add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   146
void reverse_str( char * );
10
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   147
void report_speed( void );
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   148
char *slurp_file( char * );
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   149
char *extend_line( char *, const char * );
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   150
char *copy_string_token( char *, unsigned short int );
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   151
struct in_addr *copy_ipv4_token( char *, unsigned short int );
2
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
   152
13
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
   153
void shutdown_handler( int );
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
   154
void shutdown_actions( void );
2
8c88756f81b0 Ensure that parsing can't be subverted by requests larger than the
Mahlon E. Smith <mahlon@martini.nu>
parents: 1
diff changeset
   155
int accept_loop( void );
10
d07309450285 Get the ragel line parser properly tokenizing the input lines. Add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 9
diff changeset
   156
void process( char * );
11
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
   157
request *parse( char * );
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
   158
request *init_request( void );
9aa5114326e8 Carry the amalgamated sqlite3 around with volta, rather than requiring
Mahlon E. Smith <mahlon@martini.nu>
parents: 10
diff changeset
   159
void populate_request( request * );
12
191b3c25974a Clean up redundant parser actions via preprocessor macros, add a
Mahlon E. Smith <mahlon@martini.nu>
parents: 11
diff changeset
   160
void parse_tld( request * );
13
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
   161
void parse_port( request * );
23a242d7b7fa 1st iteration of volta actually doing something. Process the request,
Mahlon E. Smith <mahlon@laika.com>
parents: 12
diff changeset
   162
void finish_request( request * );
0
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   163
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   164
#endif
eac7211fe522 Initial commit of an experimental little Squid redirector.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   165