Package: apt-cacher Version: 1.5.3 Severity: wishlist Tags: patch Because I use it to 'transport' packages to locations without network, I need to be able to run apt-cacher in offline mode for certain hosts; though the need occurs only at times during which other clients won't be making requests, it is impractical to change the configuration all the time.
Below is a patch to add a offline_hosts/offline_hosts_6 setting to both the man-page and the script itself. Sorry about the messed-up diff paths, I wasn't working against the source package, if you want I can regenerate them. offline_hosts=* isn't supported because that would be almost identical to setting offline_mode=1 (unless you used a different offline_hosts and offline_hosts_6 setting) so that didn't seem to make sense. --- apt-cacher.1.orig 2006-06-18 13:01:51.989079705 +0200 +++ apt-cacher.1 2006-06-18 13:06:20.079079705 +0200 @@ -111,6 +111,15 @@ Avoid any outgoing connection, return files available in the cache and just return errors if they are missing. .TP +.B offline_hosts +For hosts listed in this list, behave as if offline_mode was set when they +start a request. If another request for the same file is already running, they +can piggyback on it, but they can't start new requests. Setting this list to * +is not supported, use offline_mode. +.TP +.B offline_hosts_6 +Like offline_hosts for IPv6. +.TP .B admin_email [EMAIL PROTECTED] The email address of the administrator is displayed in the info page and traffic reports. --- apt-cacher.orig 2006-06-18 12:44:05.979079705 +0200 +++ apt-cacher 2006-06-18 13:00:42.599079705 +0200 @@ -429,6 +429,8 @@ sub handle_connection { # now begin connection's personal stuff + my $offline_mode = $$cfg{offline_mode}; + debug_message("New HTTP connection open"); if($direct_mode) { @@ -477,6 +479,10 @@ ipv6_addr_in_list ($clientaddr, 'allowed_hosts_6'); $ip_fail = ipv6_addr_in_list ($clientaddr, 'denied_hosts_6'); } + if (!$offline_mode) + { + $offline_mode = ipv6_addr_in_list ($clientaddr, 'offline_hosts_6'); + } } elsif (defined ($clientaddr = ipv4_normalise ($client))) # IPv4? { @@ -491,6 +497,10 @@ ipv4_addr_in_list ($clientaddr, 'allowed_hosts'); $ip_fail = ipv4_addr_in_list ($clientaddr, 'denied_hosts'); } + if (!$offline_mode) + { + $offline_mode = ipv4_addr_in_list ($clientaddr, 'offline_hosts'); + } } else { @@ -689,7 +699,7 @@ if ($is_index_file) { debug_message("known as index file: $filename"); # in offline mode, deliver it as-is, otherwise check freshness - if (-f $cached_file && -f $cached_head && !$$cfg{offline_mode}) { + if (-f $cached_file && -f $cached_head && !$offline_mode) { if($$cfg{expire_hours} > 0) { my $now = time(); my @stat = stat($cached_file); @@ -787,7 +797,7 @@ } else { # bypass for offline mode, no forking, just report the "problem" - if($$cfg{offline_mode}) + if($offline_mode) { &sendrsp(503, "Apt-Cacher in Offline Mode"); next REQUEST; -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]