On Mon, Oct 22, 2007 at 04:04:05PM +0200, Ralph Rößner wrote:
> Mark,
>
> I have applied your patch, and it does indeed fix things for us. Thank
> you for looking into this problem.
>
> My only caveat is that with your patch, in the presence of a configured
> http proxy, the check against the "local" hostname/port is never made.
> I cannot verify this with our setup but my guess is that your patch
> might produce problems in an (inetd mode x multi-IP host x configured
> proxy) setup.
Yes, I spent a while thinking about this. This whole area (handling
absolute URLs and preventing circular requests) is quite problematic and
the cause of many of the hangs that have been reported, I think.
My tack is that we trust a configured upstream proxy to do the right
thing. If we want to be more specific we could have another option to
control which hosts are passed to the upstream proxy, but I don't really
fancy that.
My first attempt at a solution to your problem was to open a socket to
the http_proxy rather than the requested host. It seemed excessive to do
this every time, so I changed to the patch I sent you.
My original patch was:
diff --git a/apt-cacher2 b/apt-cacher2
index 572b8c6..9ac3341 100755
--- a/apt-cacher2
+++ b/apt-cacher2
@@ -529,14 +529,20 @@ sub handle_connection {
if ($path =~ m!^http://([^/]+)!) { # Absolute URI
# Check host or proxy
debug_message("Checking host $1 in absolute URI");
- my $sock = IO::Socket::INET->new(PeerAddr=> "$1", # possibly with
port
+ my $upstream = $1;
+ if ($$cfg{use_proxy}) {
+ # Check http_proxy instead if used
+ debug_message("Contacting upstream proxy $$cfg{http_proxy}");
+ $upstream = $$cfg{http_proxy};
+ }
+ my $sock = IO::Socket::INET->new(PeerAddr=> "$upstream", # possibly
with port
PeerPort=> 80, # Default,
- # overridden if
port
- # also in PeerAddr
+ # overridden if port
+ # also in PeerAddr
Proto => "tcp");
if (!defined $sock) {
- info_message("Unable to connect to $1");
- &sendrsp(404, "Unable to connect to $1");
+ info_message("Unable to connect to $upstream");
+ &sendrsp(404, "Unable to connect to $upstream");
exit(4);
}
# Both host and port need to be matched. In inetd mode daemon_port
Does that seem better to you?
Mark
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]