I'm experimenting with the redirector, but I'm not sure how it
works yet. As far as I can see it supplies the requested URL
on stdin, along with the client IP, ident info if present, and
method.
I don't see any way of getting at the other HTTP headers. They're
not in the environment - I got the redirector to print it out.
What I want to do is intercept "Host:" headers, and rewrite the URLs
to go elsewhere (like demon are doing - so that www.pizzabox.vt.com/
is mapped to www.vt.com/~pizzabox/, for example)
Here's the trivial redirector I'm using while learning, followed by the
output.
What basic understanding am I missing?
#include <stdio.h>
#define MAX_LINE 65536
char line[MAX_LINE];
int main(int argc, char **argv)
{
FILE *log;
char *s;
for (;;) {
line[MAX_LINE-1] = '\0';
s = fgets(line, MAX_LINE-1, stdin);
if (s != NULL) {
fwrite(line, strlen(line), 1, stdout);
fflush(stdout);
log = fopen("/tmp/redir.log", "a");
if (log != NULL) {
fwrite(line, strlen(line), 1, log);
fflush(log);
fclose(log);
system("/usr/bin/printenv >> /tmp/redir.log");
}
} else exit(1);
}
}
The squid cache is running on megapop.vt.com:80 in accelerator mode
and passes all request to port 81 on the same machine.
Here's what is logged for a typical fetch:
http://megapop.vt.com:81/lynx/keystroke_commands/bookmark_help.html 204.117.188.8/- - GET
USER=squid
HOME=/usr/local/squid
EXINIT=set autoindent
PAGER=more
LC_CTYPE=ISO8859-1
VISUAL=/usr/contrib/bin/jove
LOGNAME=squid
NAME=Squid HTTP Proxy
WWW_HOME=http://www.bsdi.com/welcome.html
TERM=vt100
BLOCKSIZE=1k
LESSCHARSET=latin1
PATH=/usr/bin:/bin:/usr/local/squid/bin
RNINIT=/home/gtoal/.rninit
SHELL=/bin/csh
XAPPLRESDIR=/home/gtoal/app-defaults/Class/
PWD=/usr/local/squid/bin
TERMCAP=vt100|dec-vt100|vt100-am|vt100am:do=^J:co#80:li#24:cl=50\E[;H\E[2J:sf=2*\ED:le=^H:bs:am:cm=5\E[%i%d;%dH:nd=2\E[C:up=2\E[A:ce=3\E[K:cd=50\E[J:so=2\E[7m:se=2\E[m:us=2\E[4m:ue=2\E[m:md=2\E[1m:mr=2\E[7m:mb=2\E[5m:me=2\E[m:is=\E[1;24r\E[24;1H:if=/usr/share/tabset/vt100:rs=\E>\E[?3l\E[?4l\E[?5l\E[?7h\E[?8h:ks=\E[?1h\E=:ke=\E[?1l\E>:ku=\EOA:kd=\EOB:kr=\EOC:kl=\EOD:kb=^H:ho=\E[H:k1=\EOP:k2=\EOQ:k3=\EOR:k4=\EOS:pt:sr=2*\EM:vt#3:xn:sc=\E7:rc=\E8:cs=\E[%i%d;%dr:
EDITOR=/usr/contrib/bin/jove
Any ideas?
Graham
Received on Wed May 07 1997 - 13:30:38 MDT
This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:35:08 MST