Ralph,
I have sent this already, but it doesn't appear to have got through.
Apologies if this is a duplication.
Thanks for this, I hadn't considered the possibility of *having* to use
a proxy to reach a remote host.
I have rolled another patch which I think achieves what you need, but
IMHO is a bit cleaner :)
Could you try it and let me know.
Thanks,
Mark
diff --git a/apt-cacher2 b/apt-cacher2
index 572b8c6..fd3e68d 100755
--- a/apt-cacher2
+++ b/apt-cacher2
@@ -527,31 +527,39 @@ sub handle_connection {
$path =~ s!^//!/!;
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
- PeerPort=> 80, # Default,
- # 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");
- exit(4);
- }
- # Both host and port need to be matched. In inetd mode daemon_port
- # is read from inetd.conf by get_inetd_port(). CGI mode shouldn't
- # get absolute URLs.
- if ($sock->sockhost =~ $sock->peerhost &&
- $sock->peerport == $$cfg{daemon_port}) { # Host is this host
- debug_message("Host in Absolute URI is this server");
- $path =~ s!^http://[^/]+!!; # Remove prefix and hostname
+ if ($$cfg{use_proxy}) {
+ # Host may not be reachable without proxy. Just have to trust
+ # proxy to do the right thing
+ $path =~ s!^http:/!!; # Remove prefix
+ debug_message("Passing absolute URI to HTTP proxy");
}
- else { # Proxy request
- debug_message("Host in Absolute URI is not this server");
- $path =~ s!^http:/!!; # Remove absolute prefix
+ else {
+ # Check host or proxy
+ debug_message("Checking host $1 in absolute URI");
+ my $sock = IO::Socket::INET->new(PeerAddr=> "$1", # possibly
with port
+ PeerPort=> 80, # Default,
+ # 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");
+ exit(4);
+ }
+ # Both host and port need to be matched. In inetd mode
daemon_port
+ # is read from inetd.conf by get_inetd_port(). CGI mode
shouldn't
+ # get absolute URLs.
+ if ($sock->sockhost =~ $sock->peerhost &&
+ $sock->peerport == $$cfg{daemon_port}) { # Host is this host
+ debug_message("Host in Absolute URI is this server");
+ $path =~ s!^http://[^/]+!!; # Remove prefix and hostname
+ }
+ else { # Proxy request
+ debug_message("Host in Absolute URI is not this server");
+ $path =~ s!^http:/!!; # Remove absolute prefix
+ }
+ $sock->shutdown(2); # Close
}
- $sock->shutdown(2); # Close
}
debug_message("Resolved request is $path");
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]