diff -u -N -r ffproxy-1.3p2/BUGS ffproxy-1.4/BUGS --- ffproxy-1.3p2/BUGS Fri Jul 5 09:13:35 2002 +++ ffproxy-1.4/BUGS Sun Jul 20 09:58:57 2003 @@ -1,2 +1,2 @@ Send bug reports to -niklas.olmes@web.de +Niklas Olmes diff -u -N -r ffproxy-1.3p2/ChangeLog ffproxy-1.4/ChangeLog --- ffproxy-1.3p2/ChangeLog Mon May 12 00:40:32 2003 +++ ffproxy-1.4/ChangeLog Sun Jul 20 10:55:34 2003 @@ -1,3 +1,27 @@ +Version 1.4 +=========== + +* added IPv6 Support + * new config options + - use_ipv6 yes|no + - forward_proxy_ipv6 yes|no + * new command line option -4 (disable IPv6) + * PLEASE NOTE: ffproxy is not yet able to *bind* + to IPv6, this will be implemented soon after + this release + +* removed config.proxyip and added config.proxyhost: + now proxyhost is resolved on every access + (was resolved only once on startup before) + +* changed copyright notice in every .c File + (added new E-Mail Address and renewed (c)) + +* changed README and manpage (minor changes) + +* moved configuration settings in Makefile up to + the top of the file + Version 1.3p2 ============= diff -u -N -r ffproxy-1.3p2/Makefile ffproxy-1.4/Makefile --- ffproxy-1.3p2/Makefile Mon Aug 5 19:43:20 2002 +++ ffproxy-1.4/Makefile Sun Jul 20 09:57:57 2003 @@ -1,3 +1,12 @@ +# +# change the following lines to fit your needs +# +#CC = gcc -DDEBUG +#CFLAGS = -W -Wall -Werror -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wbad-function-cast -ansi -pedantic-errors -O2 +# +# remove the # in front of the next line if you're using linux +#CFLAGS = -DLINUX + SRCS = main.c print.c socket.c request.c http.c alloc.c filter.c db.c file.c dns.c signals.c access.c regex.c msg.c poll.c cache.c time.c OBJS = $(SRCS:.c=.o) @@ -12,15 +21,6 @@ install -c ffproxy ${PREFIX}/bin/ffproxy install -d ${PREFIX}/man/man8 install -c ffproxy.8 ${PREFIX}/man/man8/ffproxy.8 - -# -# change the following lines to fit your needs -# -#CC = gcc -DDEBUG -#CFLAGS = -W -Wall -Werror -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wbad-function-cast -ansi -pedantic-errors -O2 -# -# remove the # in front of the next line if you're using linux -#CFLAGS = -DLINUX proxy: $(OBJS) ${CC} ${CFLAGS} -o ffproxy $(OBJS) diff -u -N -r ffproxy-1.3p2/README ffproxy-1.4/README --- ffproxy-1.3p2/README Thu Jul 25 12:04:28 2002 +++ ffproxy-1.4/README Sun Jul 20 11:30:52 2003 @@ -7,14 +7,16 @@ by host, url, and header. Custom header entries can be filtered and added. It can even drop its privileges and chroot() to some directory. Logging to syslog() is supported, as is using another -auxiliary proxy server. +auxiliary proxy server. Contacting servers via IPv6 is supported +as well. -Website: http://faith.eu.org +Website: http://faith.eu.org/programs.html Compilation =========== * Edit Makefile to fit your needs. + (uncomment CFLAGS = -DLINUX if you're using Linux) * After making your changes, compile ffproxy with make. (see section `Bugs' at the very end of the file if ffproxy won't compile or crashes) @@ -132,4 +134,4 @@ it's possible that ffproxy won't run correctly or won't compile at all. I would appreciate to hear succes stories or receive error reports -from you. Send these to my e-mail address, niklas.olmes@web.de. +from you. Send these to my e-mail address, Niklas Olmes diff -u -N -r ffproxy-1.3p2/TODO ffproxy-1.4/TODO --- ffproxy-1.3p2/TODO Thu Jan 1 00:00:00 1970 +++ ffproxy-1.4/TODO Sun Jul 20 09:56:35 2003 @@ -0,0 +1,8 @@ +New Features to add: + + * allow ffproxy to *bind* to IPv6 + * change access.c so that IPv6 addresses will be recognized + + * add content filtering + +More ideas? Mail me. diff -u -N -r ffproxy-1.3p2/access.c ffproxy-1.4/access.c --- ffproxy-1.3p2/access.c Mon Aug 5 19:38:20 2002 +++ ffproxy-1.4/access.c Sun Jul 20 11:26:45 2003 @@ -1,7 +1,9 @@ /* - * ffproxy (c) 2002 Niklas Olmes http://faith.eu.org + * ffproxy (c) 2002, 2003 Niklas Olmes + * + * http://faith.eu.org * - * $Id: access.c,v 1.4 2002/07/25 12:24:10 niklas Exp $ + * $Id: access.c,v 1.6 2003/07/20 11:26:44 niklas Exp niklas $ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free diff -u -N -r ffproxy-1.3p2/alloc.c ffproxy-1.4/alloc.c --- ffproxy-1.3p2/alloc.c Mon Aug 5 19:38:20 2002 +++ ffproxy-1.4/alloc.c Sun Jul 20 11:25:05 2003 @@ -1,7 +1,9 @@ /* - * ffproxy (c) 2002 Niklas Olmes http://faith.eu.org + * ffproxy (c) 2002, 2003 Niklas Olmes + * + * http://faith.eu.org * - * $Id: alloc.c,v 1.3 2002/07/25 12:24:10 niklas Exp $ + * $Id: alloc.c,v 1.4 2003/07/20 10:38:23 niklas Exp $ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free diff -u -N -r ffproxy-1.3p2/cache.c ffproxy-1.4/cache.c --- ffproxy-1.3p2/cache.c Mon Aug 5 19:38:20 2002 +++ ffproxy-1.4/cache.c Sun Jul 20 11:25:05 2003 @@ -1,7 +1,9 @@ /* - * ffproxy (c) 2002 Niklas Olmes http://faith.eu.org + * ffproxy (c) 2002, 2003 Niklas Olmes + * + * http://faith.eu.org * - * $Id: cache.c,v 1.5 2002/08/05 19:25:31 niklas Exp $ + * $Id: cache.c,v 1.6 2003/07/20 10:38:23 niklas Exp $ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free diff -u -N -r ffproxy-1.3p2/cfg.h ffproxy-1.4/cfg.h --- ffproxy-1.3p2/cfg.h Thu Jul 25 12:53:52 2002 +++ ffproxy-1.4/cfg.h Sun Jul 20 09:51:54 2003 @@ -13,7 +13,7 @@ char dbdir[256]; char file[256]; - unsigned long proxyip; + char proxyhost[256]; unsigned int proxyport; int syslog; @@ -22,4 +22,6 @@ int online; int cache; unsigned long cache_max_file_size; + int use_ipv6; + int aux_proxy_ipv6; }; diff -u -N -r ffproxy-1.3p2/db.c ffproxy-1.4/db.c --- ffproxy-1.3p2/db.c Mon Aug 5 19:38:20 2002 +++ ffproxy-1.4/db.c Sun Jul 20 11:25:05 2003 @@ -1,7 +1,9 @@ /* - * ffproxy (c) 2002 Niklas Olmes http://faith.eu.org + * ffproxy (c) 2002, 2003 Niklas Olmes + * + * http://faith.eu.org * - * $Id: db.c,v 1.14 2002/07/25 12:59:15 niklas Exp $ + * $Id: db.c,v 1.15 2003/07/20 10:38:23 niklas Exp $ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free @@ -254,6 +256,12 @@ } else if (strcmp("port", obuf) == 0) { config.port = atoi(abuf); continue; + } else if (strcmp("use_ipv6", obuf) == 0) { + if (strcmp(abuf, "yes") == 0) + config.use_ipv6 = 1; + else + config.use_ipv6 = 0; + continue; } else if (strcmp("uid", obuf) == 0) { config.uid = atoi(abuf); continue; @@ -261,17 +269,24 @@ config.gid = atoi(abuf); continue; } else if (strcmp("chroot_dir", obuf) == 0) { - strncpy(config.chroot, abuf, sizeof(config.chroot) - 1); + (void) strncpy(config.chroot, abuf, sizeof(config.chroot) - 1); config.chroot[sizeof(config.chroot) - 1] = 0; continue; } else if (strcmp("forward_proxy", obuf) == 0) { - config.proxyip = resolve(abuf); + (void) strncpy(config.proxyhost, abuf, sizeof(config.proxyhost) - 1); + config.proxyhost[sizeof(config.proxyhost) - 1] = 0; continue; } else if (strcmp("forward_proxy_port", obuf) == 0) { config.proxyport = atoi(abuf); continue; + } else if (strcmp("forward_proxy_ipv6", obuf) == 0) { + if (strcmp(abuf, "yes") == 0) + config.aux_proxy_ipv6 = 1; + else + config.aux_proxy_ipv6 = 0; + continue; } else if (strcmp("db_files_path", obuf) == 0) { - strncpy(config.dbdir, abuf, sizeof(config.dbdir) - 1); + (void) strncpy(config.dbdir, abuf, sizeof(config.dbdir) - 1); config.dbdir[sizeof(config.dbdir) - 1] = 0; continue; } else if (strcmp("backlog_size", obuf) == 0) { @@ -297,6 +312,12 @@ continue; } else if (strcmp("cache_max_file_size", obuf) == 0) { config.cache_max_file_size = atoi(abuf) * 1024; + continue; + } else if (strcmp("use_ipv6", obuf) == 0) { + if (strcmp(abuf, "yes") == 0) + config.use_ipv6 = 1; + else + config.use_ipv6 = 0; continue; } else if (*obuf != '#') { warn("unknown option in config file %s: %s", config.file, obuf); diff -u -N -r ffproxy-1.3p2/dns.c ffproxy-1.4/dns.c --- ffproxy-1.3p2/dns.c Mon Aug 5 19:38:20 2002 +++ ffproxy-1.4/dns.c Sun Jul 20 11:25:05 2003 @@ -1,7 +1,9 @@ /* - * ffproxy (c) 2002 Niklas Olmes http://faith.eu.org + * ffproxy (c) 2002, 2003 Niklas Olmes + * + * http://faith.eu.org * - * $Id: dns.c,v 1.5 2002/07/25 12:24:10 niklas Exp $ + * $Id: dns.c,v 1.6 2003/07/20 10:38:23 niklas Exp $ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free diff -u -N -r ffproxy-1.3p2/ffproxy.8 ffproxy-1.4/ffproxy.8 --- ffproxy-1.3p2/ffproxy.8 Thu Jul 25 12:06:12 2002 +++ ffproxy-1.4/ffproxy.8 Sun Jul 20 11:25:10 2003 @@ -1,6 +1,7 @@ -.\" $Id: ffproxy.8,v 1.1 2002/07/25 11:50:19 niklas Exp $ -.\" Copyright (c) 2002 Niklas Olmes -.Dd July 25, 2002 +.\" $Id: ffproxy.8,v 1.3 2003/07/20 10:58:31 niklas Exp $ +.\" Copyright (c) 2002, 2003 Niklas Olmes +.\" http://faith.eu.org +.Dd July 20, 2003 .Dt ffproxy 8 .Sh NAME .Nm ffproxy @@ -17,6 +18,7 @@ .Op Fl f Ar configfile .Op Fl d .Op Fl s +.Op Fl 4 .Op Fl h .Op Fl v .Sh DESCRIPTION @@ -29,6 +31,7 @@ directory. Logging to .Xr syslogd 8 is supported, as is using another auxiliary proxy server. +Contacting IPv6 servers is supported since version 1.4. .Pp The following options are recognized. They specify general settings like IP to bind to or place of the db/ and html/ @@ -36,13 +39,14 @@ from the option by spaces, as are options from each other. Please notice that there is an alternative to command line options by using the command line option -f to specify a user configuration -to load. +file to load. See sample.conf for details and description. It may +contain options that are not available on command line. .Pp .Bl -tag -width "message" .It Fl p Ar port Bind to port. Default is 8080. .It Fl c Ar ip|hostname -Bind to IP (or hostname). Default is any IP. +Bind to IP (or hostname). Default is any IP. IPv6 is unsupported here. .It Fl l Ar childs Maximum number of child processes to be forked. That is, the maximum number of concurrent requests allowed. Default is 10. @@ -52,10 +56,14 @@ .It Fl r Ar dir Change root .Xr chroot 7 -to dir. Used in conjunction with -u and -g. +to dir. Used in conjunction with -u and -g. Because ffproxy +drops its privileges and chroots after reading the config files, +-D should be set to . (the current dir). Example: +/usr/local/bin/ffproxy -r /var/ffproxy -D . -u 50 -g 50 .It Fl x Ar ip|hostname Specify IP (or hostname) of an auxiliary proxy server that -ffproxy will forward requests to. Used together with -X. +ffproxy will forward requests to. Used together with -X. IPv6 +is supported. .It Fl X Ar port Port number of auxiliary proxy. .It Fl D Ar dir @@ -71,6 +79,8 @@ Run as daemon. .It Fl s Be silent. Don't log to syslog. +.It Fl 4 +Use IPv4 only. Do not try contacting servers via IPv6. .It Fl h Show usage information. .It Fl v @@ -134,6 +144,11 @@ .Sh RELOADING CONFIGURATION Send a SIGHUP to the pid of the ffproxy master process to let it reload db/ and html/ files. +If daemonized, ffproxy writes the pid file +.Pa ffproxy.pid +to the working directory, that is, the directory +specified by db_path or the command line parameter -D. +It defaults to the current directory. .Sh LOGGING By default, ffproxy logs incorrect and filtered requests. Connection attempts from disallowed hosts get logged, @@ -152,15 +167,32 @@ the files in db/ which specify filtering options and who is allowed to connect and use ffproxy .El +.Pp +If daemonized, ffproxy writes the pid of its master +process to the file named +.Pa ffproxy.pid +in its working directory. .Sh SEE ALSO .Pa README -file for some configuration examples +file for some configuration examples and general explanation .Pp .Pa sample.config for a sample configuration file .Pp +.Pa http://faith.eu.org/programs.html +for latest version and patches +.Pp .Xr regex 7 , .Xr re_format 7 , .Xr syslogd 8 , .Xr chroot 2 , .Xr kill 1 +.Sh VERSION +This manual documents ffproxy 1.4 (2003-07-20). +.Sh BUGS +Although contacting IPv6 servers is supported since version 1.4, +binding and listening to IPv6 is not yet supported. +.Pp +Send bug reports, comments, suggestions to +.Sh AUTHOR +Niklas Olmes diff -u -N -r ffproxy-1.3p2/file.c ffproxy-1.4/file.c --- ffproxy-1.3p2/file.c Mon Aug 5 19:38:20 2002 +++ ffproxy-1.4/file.c Sun Jul 20 11:25:05 2003 @@ -1,7 +1,9 @@ /* - * ffproxy (c) 2002 Niklas Olmes http://faith.eu.org + * ffproxy (c) 2002, 2003 Niklas Olmes + * + * http://faith.eu.org * - * $Id: file.c,v 1.3 2002/07/25 12:24:10 niklas Exp $ + * $Id: file.c,v 1.4 2003/07/20 10:38:23 niklas Exp $ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free diff -u -N -r ffproxy-1.3p2/filter.c ffproxy-1.4/filter.c --- ffproxy-1.3p2/filter.c Mon Aug 5 19:38:20 2002 +++ ffproxy-1.4/filter.c Sun Jul 20 11:25:05 2003 @@ -1,7 +1,9 @@ /* - * ffproxy (c) 2002 Niklas Olmes http://faith.eu.org + * ffproxy (c) 2002, 2003 Niklas Olmes + * + * http://faith.eu.org * - * $Id: filter.c,v 1.7 2002/07/25 12:24:10 niklas Exp $ + * $Id: filter.c,v 1.8 2003/07/20 10:38:23 niklas Exp $ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free diff -u -N -r ffproxy-1.3p2/http.c ffproxy-1.4/http.c --- ffproxy-1.3p2/http.c Mon May 12 00:41:54 2003 +++ ffproxy-1.4/http.c Sun Jul 20 11:25:05 2003 @@ -3,7 +3,7 @@ * * http://faith.eu.org * - * $Id: http.c,v 1.4 2003/05/12 00:41:40 niklas Exp niklas $ + * $Id: http.c,v 1.4 2003/05/12 00:41:40 niklas Exp $ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free diff -u -N -r ffproxy-1.3p2/main.c ffproxy-1.4/main.c --- ffproxy-1.3p2/main.c Mon May 12 00:41:41 2003 +++ ffproxy-1.4/main.c Sun Jul 20 11:25:05 2003 @@ -3,7 +3,7 @@ * * http://faith.eu.org * - * $Id: main.c,v 1.17 2003/05/12 00:41:40 niklas Exp niklas $ + * $Id: main.c,v 1.19 2003/07/20 10:54:37 niklas Exp $ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free @@ -39,8 +39,8 @@ static void usage(void); static void drop_privileges(void); -static const char version[] = "1.3p2"; -static const char rcsid[] = "$Id: main.c,v 1.17 2003/05/12 00:41:40 niklas Exp niklas $"; +static const char version[] = "1.4"; +static const char rcsid[] = "$Id: main.c,v 1.19 2003/07/20 10:54:37 niklas Exp $"; char loop_header[100]; struct cfg config; @@ -62,15 +62,17 @@ *config.chroot = '\0'; *config.dbdir = '\0'; *config.file = '\0'; - config.proxyip = 0L; + *config.proxyhost = '\0'; config.proxyport = 0; config.syslog = 1; config.logrequests = 0; config.online = 1; config.cache = 0; config.cache_max_file_size = 1024 * 2; + config.use_ipv6 = 1; + config.aux_proxy_ipv6 = 1; - while ((c = getopt(argc, argv, "vdc:p:x:X:l:u:g:r:D:f:sh")) != -1) { + while ((c = getopt(argc, argv, "vdc:p:x:X:l:u:g:r:D:f:s4h")) != -1) { switch (c) { case 'v': (void) printf("ffproxy version %s, %s\n", @@ -87,7 +89,8 @@ config.port = atoi(optarg); break; case 'x': - config.proxyip = resolve(optarg); + (void) strncpy(config.proxyhost, optarg, sizeof(config.proxyhost) - 1); + config.proxyhost[sizeof(config.proxyhost) - 1] = '\0'; break; case 'X': config.proxyport = atoi(optarg); @@ -116,6 +119,9 @@ case 's': config.syslog = 0; break; + case '4': + config.use_ipv6 = 0; + break; case 'h': default: usage(); @@ -160,15 +166,16 @@ usage(void) { (void) fprintf(stderr, "ffproxy %s -- (c) 2002, 2003 Niklas Olmes \n", version); - (void) fprintf(stderr, " \n"); - (void) fprintf(stderr, " GNU GPL. Website: http://faith.eu.org\n"); + (void) fprintf(stderr, " \n"); + (void) fprintf(stderr, " GNU GPL. Website: http://faith.eu.org/programs.html\n"); (void) fprintf(stderr, - "usage: ffproxy [-vdsh] [-c host|ip] [-p port] [-x host|ip] [-X port] [-l max]\n" + "usage: ffproxy [-vds4h] [-c host|ip] [-p port] [-x host|ip] [-X port] [-l max]\n" " [-u uid -g gid] [-r dir] [-D dir] [-f file]\n" "\n" " -v print version number\n" " -d become daemon\n" " -s silent. don't log to syslog.\n" + " -4 Use IPv4 only. Don't try contacting via IPv6.\n" " -h usage (this screen)\n" "\n" " -c host|ip bind to IP\n" diff -u -N -r ffproxy-1.3p2/msg.c ffproxy-1.4/msg.c --- ffproxy-1.3p2/msg.c Mon Aug 5 19:38:20 2002 +++ ffproxy-1.4/msg.c Sun Jul 20 11:25:05 2003 @@ -1,7 +1,9 @@ /* - * ffproxy (c) 2002 Niklas Olmes http://faith.eu.org + * ffproxy (c) 2002, 2003 Niklas Olmes + * + * http://faith.eu.org * - * $Id: msg.c,v 1.7 2002/07/25 12:24:10 niklas Exp $ + * $Id: msg.c,v 1.8 2003/07/20 10:38:23 niklas Exp $ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free diff -u -N -r ffproxy-1.3p2/poll.c ffproxy-1.4/poll.c --- ffproxy-1.3p2/poll.c Mon Aug 5 19:38:20 2002 +++ ffproxy-1.4/poll.c Sun Jul 20 11:25:05 2003 @@ -1,7 +1,9 @@ /* - * ffproxy (c) 2002 Niklas Olmes http://faith.eu.org + * ffproxy (c) 2002, 2003 Niklas Olmes + * + * http://faith.eu.org * - * $Id: poll.c,v 1.3 2002/07/25 12:24:10 niklas Exp $ + * $Id: poll.c,v 1.4 2003/07/20 10:38:23 niklas Exp $ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free diff -u -N -r ffproxy-1.3p2/print.c ffproxy-1.4/print.c --- ffproxy-1.3p2/print.c Mon Aug 5 19:38:20 2002 +++ ffproxy-1.4/print.c Sun Jul 20 11:25:05 2003 @@ -1,7 +1,9 @@ /* - * ffproxy (c) 2002 Niklas Olmes http://faith.eu.org + * ffproxy (c) 2002, 2003 Niklas Olmes + * + * http://faith.eu.org * - * $Id: print.c,v 1.8 2002/07/25 12:24:10 niklas Exp $ + * $Id: print.c,v 1.9 2003/07/20 10:38:23 niklas Exp $ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free diff -u -N -r ffproxy-1.3p2/regex.c ffproxy-1.4/regex.c --- ffproxy-1.3p2/regex.c Mon Aug 5 19:38:21 2002 +++ ffproxy-1.4/regex.c Sun Jul 20 11:25:05 2003 @@ -1,7 +1,9 @@ /* - * ffproxy (c) 2002 Niklas Olmes http://faith.eu.org + * ffproxy (c) 2002, 2003 Niklas Olmes + * + * http://faith.eu.org * - * $Id: regex.c,v 1.3 2002/07/25 12:24:10 niklas Exp $ + * $Id: regex.c,v 1.4 2003/07/20 10:38:23 niklas Exp $ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free diff -u -N -r ffproxy-1.3p2/request.c ffproxy-1.4/request.c --- ffproxy-1.3p2/request.c Mon May 12 00:41:51 2003 +++ ffproxy-1.4/request.c Sun Jul 20 11:25:05 2003 @@ -3,7 +3,7 @@ * * http://faith.eu.org * - * $Id: request.c,v 1.20 2003/05/12 00:41:40 niklas Exp niklas $ + * $Id: request.c,v 1.21 2003/07/20 10:38:23 niklas Exp $ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free @@ -180,13 +180,14 @@ #include #include #ifdef LINUX -#include + #include #else -#include + #include #endif #include #include +#include #include #include #include @@ -198,7 +199,6 @@ do_request(int cl, struct req * r) { extern struct cfg config; - struct sockaddr_in addr; unsigned long ip; int s; void *foo; @@ -206,36 +206,93 @@ char buf[4096]; len = 0; + ip = 0L; + s = 0; - (void) memset(&addr, 0, sizeof(addr)); - if (config.proxyip) { - addr.sin_addr.s_addr = config.proxyip; - addr.sin_port = htons(config.proxyport); - addr.sin_family = AF_INET; - } else { - if (config.online) { - if ((ip = resolve(r->host)) == INADDR_NONE) { - debug("do_request() => resolve failure for %s", r->host); - return E_RES; - } - } else - ip = 0L; - - addr.sin_addr.s_addr = ip; - addr.sin_port = htons(r->port); - addr.sin_family = AF_INET; - } if (config.online) { - if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) { - debug("do_request() => socket() failed for %s", r->host); - return E_CON; - } else if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &foo, sizeof(foo)) != 0) { - debug("do_request() => setsockopt() failed"); - return E_CON; - } else if (connect(s, (struct sockaddr *) & addr, sizeof(addr)) == -1) { - debug("do_request() => connect() failed"); - return E_CON; + if (config.use_ipv6 && (config.aux_proxy_ipv6 || *config.proxyhost == '\0')) { + struct addrinfo hints, *res, *res0; + char port[6]; + + debug("do_request() => trying ipv6"); + + port[0] = '\0'; + (void) memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + + if (*config.proxyhost != '\0' && config.proxyport) { + debug("do_request() => trying ipv6 for proxy %s port %d", config.proxyhost, config.proxyport); + (void) snprintf(port, 6, "%d", config.proxyport); + if (getaddrinfo(config.proxyhost, port, &hints, &res)) { + debug("do_request() => getaddrinfo() failed for proxy %s", config.proxyhost); + return E_CON; + } + } else { + (void) snprintf(port, 6, "%d", r->port); + if (getaddrinfo(r->host, port, &hints, &res)) { + debug("do_request() => getaddrinfo() failed for %s", r->host); + return E_CON; + } + } + + s = -1; + for (res0 = res; res; res = res->ai_next) { + if ((s = socket(res->ai_family, res->ai_socktype, res->ai_protocol)) < 0) + continue; + else if (connect(s, res->ai_addr, res->ai_addrlen) < 0) { + (void) close(s); + s = -1; + continue; + } else + break; + } + freeaddrinfo(res0); + + if (s == -1) { + if (*config.proxyhost != '\0' && config.proxyport) + debug("do_request() => socket() or connect() after getaddrinfo() failed for proxy %s port %d", + config.proxyhost, config.proxyport); + else + debug("do_request() => socket() or connect() after getaddrinfo() failed for %s port %d", r->host, r->port); + return E_CON; + } + } else { + struct sockaddr_in addr; + + debug("do_request() => not trying ipv6"); + + (void) memset(&addr, 0, sizeof(addr)); + + if (*config.proxyhost != '\0' && config.proxyport) { + debug("do_request() => using aux proxy w/o trying ipv6"); + if ((addr.sin_addr.s_addr = resolve(config.proxyhost)) == INADDR_NONE) { + debug("do_request() => resolve failure for proxy %s", config.proxyhost); + return E_RES; + } + addr.sin_port = htons(config.proxyport); + addr.sin_family = AF_INET; + } else { + if ((ip = resolve(r->host)) == INADDR_NONE) { + debug("do_request() => resolve failure for %s", r->host); + return E_RES; + } + addr.sin_addr.s_addr = ip; + addr.sin_port = htons(r->port); + addr.sin_family = AF_INET; + } + + if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) { + debug("do_request() => socket() failed for %s port %d", r->host, r->port); + return E_CON; + } else if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &foo, sizeof(foo)) != 0) { + debug("do_request() => setsockopt() failed for %s port %d", r->host, r->port); + return E_CON; + } else if (connect(s, (struct sockaddr *) & addr, sizeof(addr)) == -1) { + debug("do_request() => connect() failed for %s port %d", r->host, r->port); + return E_CON; + } } } else s = 0; @@ -254,7 +311,7 @@ "Host: %s:%d\r\n", ((r->type == GET) ? "GET" : ((r->type) == HEAD) ? "HEAD" : "POST"), - config.proxyip ? r->url : r->urlpath, + (*config.proxyhost && config.proxyport) != '\0' ? r->url : r->urlpath, r->vmajor, r->vminor, r->host, r->port); diff -u -N -r ffproxy-1.3p2/sample.config ffproxy-1.4/sample.config --- ffproxy-1.3p2/sample.config Mon May 12 00:06:42 2003 +++ ffproxy-1.4/sample.config Sun Jul 20 09:51:38 2003 @@ -4,7 +4,7 @@ # lines starting with '#' are comments # run as daemon? yes|no (default: no) #daemonize yes -daemonize yes +daemonize no # number of child processes, # that is, the maximum number of concurrent requests @@ -13,13 +13,20 @@ # bind to (IP or hostname), 0 is any IP (default) #bind_to 192.168.10.1 -#bind_to menuhin.dpmurdock.eu.org +#bind_to martyr.burden.eu.org bind_to 0 # listen on port (default: 8080) #port 1111 port 8080 +# use IPv6? (default: yes) +# NOTE: ffproxy 1.4 does not yet bind to IPv6, it will +# only try to contact servers via IPv6 if +# use_ipv6 is set to yes +#use_ipv6 no +use_ipv6 yes + # use syslog? (default: yes) #use_syslog no use_syslog yes @@ -40,10 +47,14 @@ # forward to proxy (auxiliary proxy) # (disabled by default) -#forward_proxy blackness.dpmurdock.eu.org -forward_proxy 0 +#forward_proxy blackness.burden.eu.org #forward_proxy_port 8082 forward_proxy_port 0 + +# try IPv6 for auxiliary proxy? (default yes) +# (use_ipv6 must be set to yes, too) +#forward_proxy_ipv6 no +forward_proxy_ipv6 yes # path to db/ and html/ directories # (default: current directory (./)) diff -u -N -r ffproxy-1.3p2/signals.c ffproxy-1.4/signals.c --- ffproxy-1.3p2/signals.c Mon Aug 5 19:38:21 2002 +++ ffproxy-1.4/signals.c Sun Jul 20 11:25:05 2003 @@ -1,7 +1,9 @@ /* - * ffproxy (c) 2002 Niklas Olmes http://faith.eu.org + * ffproxy (c) 2002, 2003 Niklas Olmes + * + * http://faith.eu.org * - * $Id: signals.c,v 1.4 2002/07/25 12:24:10 niklas Exp $ + * $Id: signals.c,v 1.5 2003/07/20 10:38:23 niklas Exp $ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free diff -u -N -r ffproxy-1.3p2/socket.c ffproxy-1.4/socket.c --- ffproxy-1.3p2/socket.c Mon Aug 5 19:38:21 2002 +++ ffproxy-1.4/socket.c Sun Jul 20 11:25:05 2003 @@ -1,7 +1,9 @@ /* - * ffproxy (c) 2002 Niklas Olmes http://faith.eu.org + * ffproxy (c) 2002, 2003 Niklas Olmes + * + * http://faith.eu.org * - * $Id: socket.c,v 1.9 2002/08/05 19:27:33 niklas Exp $ + * $Id: socket.c,v 1.10 2003/07/20 10:38:23 niklas Exp $ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free @@ -22,9 +24,9 @@ #include #include #ifdef LINUX -#include + #include #else -#include + #include #endif #include diff -u -N -r ffproxy-1.3p2/time.c ffproxy-1.4/time.c --- ffproxy-1.3p2/time.c Mon Aug 5 19:38:21 2002 +++ ffproxy-1.4/time.c Sun Jul 20 11:25:05 2003 @@ -1,7 +1,9 @@ /* - * ffproxy (c) 2002 Niklas Olmes http://faith.eu.org + * ffproxy (c) 2002, 2003 Niklas Olmes + * + * http://faith.eu.org * - * $Id: time.c,v 1.3 2002/07/25 12:24:10 niklas Exp $ + * $Id: time.c,v 1.4 2003/07/20 10:38:23 niklas Exp $ * * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free