33 |
33 |
34 void |
34 void |
35 process( char *line ) |
35 process( char *line ) |
36 { |
36 { |
37 request *p_request = parse( line ); |
37 request *p_request = parse( line ); |
|
38 rewrite *p_rewrite = prepare_rewrite( p_request ); |
38 |
39 |
39 /* count lines in debugmode */ |
40 /* count lines in debugmode */ |
40 if ( v.debugmode > 2 ) v.timer.lines++; |
41 if ( v.debugmode > 2 ) v.timer.lines++; |
41 |
42 |
42 /* If parsing failed for some reason, return a blank line to squid. */ |
43 /* If parsing failed or there wasn't a successful rewrite match, |
43 if ( p_request == NULL ) { |
44 * return a blank line to squid to allow the request to pass |
44 printf( "\n" ); |
45 * through unmolested. */ |
|
46 if ( p_request == NULL || p_rewrite == NULL ) { |
|
47 out( "\n" ); |
|
48 finish_request( p_request ); |
|
49 finish_rewrite( p_rewrite ); |
45 return; |
50 return; |
46 } |
51 } |
47 |
52 |
48 printf( "* %s", line ); |
53 if ( v.debugmode < 4 ) { |
49 printf( "%s%s%s%s\n\n", p_request->scheme, p_request->host, p_request->port, p_request->path ); |
54 if ( p_rewrite->redir == REDIR_TEMPORARY ) printf( "302:" ); |
|
55 if ( p_rewrite->redir == REDIR_PERMANENT ) printf( "301:" ); |
50 |
56 |
51 /* TODO: everything */ |
57 if ( p_request->scheme || p_rewrite->scheme ) |
|
58 printf( "%s", p_rewrite->scheme ? p_rewrite->scheme : p_request->scheme ); |
|
59 printf( "%s", p_rewrite->host ? p_rewrite->host : p_request->host ); |
|
60 printf( "%s", p_rewrite->path ? p_rewrite->path : p_request->path ); |
|
61 if ( p_request->port != 0 || p_rewrite->port != 0 ) |
|
62 printf( ":%d", p_rewrite->port ? p_rewrite->port : p_request->port ); |
|
63 printf("\n"); |
|
64 } |
|
65 else { |
|
66 debug( 5, LOC, "Rewrite match on %s/%s\n", p_request->host, p_request->path ); |
|
67 debug( 5, LOC, " --> %s/%s\n", p_rewrite->host, p_rewrite->path ); |
|
68 } |
52 |
69 |
53 cleanup_request( p_request ); |
70 |
|
71 /* unsigned long hst, net; */ |
|
72 /* hst = inet_lnaof( *(p_request->client_ip) ); */ |
|
73 /* net = inet_netof( *(p_request->client_ip) ); */ |
|
74 /* printf("%14s : net=0x%08lX host=0x%08lX\n", inet_ntoa( *(p_request->client_ip) ), net, hst); */ |
|
75 /* printf("%14s : net=%lu host=%lu\n", inet_ntoa( *(p_request->client_ip) ), net, hst); */ |
|
76 |
|
77 /* |
|
78 * create function bigint_to_inet(bigint) returns inet as $$ |
|
79 * select |
|
80 * (($1>>24&255)||'.'||($1>>16&255)||'.'||($1>>8&255)||'.'||($1>>0&255))::inet |
|
81 * $$ language sql; |
|
82 * */ |
|
83 |
|
84 /* |
|
85 char ip[ INET_ADDRSTRLEN ]; |
|
86 inet_ntop( AF_INET, p_request->client_ip, ip, INET_ADDRSTRLEN ); |
|
87 printf( "%s\n", ip ); |
|
88 */ |
|
89 |
|
90 finish_request( p_request ); |
|
91 finish_rewrite( p_rewrite ); |
54 return; |
92 return; |
55 } |
93 } |
56 |
94 |