From patchwork Fri Feb 16 23:04:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Peter_M=C3=BCller_via_Development?= X-Patchwork-Id: 1669 Return-Path: Received: from mail01.ipfire.org (unknown [172.28.1.200]) by web02.i.ipfire.org (Postfix) with ESMTP id 5B96D60FFE for ; Fri, 16 Feb 2018 13:15:23 +0100 (CET) X-Virus-Scanned: ClamAV at mail01.ipfire.org Received: from mail01.i.ipfire.org (localhost [IPv6:::1]) by mail01.ipfire.org (Postfix) with ESMTP id 46BDE10FE248; Fri, 16 Feb 2018 12:15:29 +0000 (GMT) Authentication-Results: mail01.ipfire.org; dmarc=none (p=none dis=none) header.from=lists.ipfire.org Authentication-Results: mail01.ipfire.org; spf=pass smtp.mailfrom=development-bounces@lists.ipfire.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=lists.ipfire.org; s=201801; t=1518783329; x=1521375329; bh=wGrAxclsqsBy1AqrVxvN2GzKfaEtF9+1tfDJw/n8R6Y=; h=To:Subject:Date:Message-Id:Content-Type:Cc:From:Reply-To:Sender: From:To:Cc:Date:Content-Type:Message-ID:In-Reply-To:Subject: Reply-To:Sender; b=WjGxfhj/mNus6Ed5gzNO6w8qU2vvr+qHU0Q2bSl7g30CdXjbd1zv+SAmrsSiZUONj yoOgS1ZPbfj09wKcJZdA0oT5e5zaGAXtjyAFARHUeyeYrwAP5rNOgF8qV5JMP4r4q/ vtXtqAsPLMVnJ69cCKuDJshoy08IdwvqvfDuy/ZxHaryjyCYfoM8lE0Z0Vp6uVVCi0 Grai7R1GwToE/Wikwh4EnkDEzRNU4RV6OD8pTO41ixCcy/fAFEsCIiOWrAtN04k9Zj FlmTHWaJtIDMDr6Rfvq8JzUBUYXDcW1DJSTcFM2mtoeBHycdTS1iQ1o7yDeGaLb5uc Cbh5ECMznAsKg== X-Virus-Scanned: ClamAV at mail01.ipfire.org Received: from whytea-e82.lan.e82 (p5DE86DC9.dip0.t-ipconnect.de [93.232.109.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail01.ipfire.org (Postfix) with ESMTPSA id 4BEE8108C399; Fri, 16 Feb 2018 12:05:54 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ipfire.org; s=201801; t=1518782756; x=1521374756; bh=wGrAxclsqsBy1AqrVxvN2GzKfaEtF9+1tfDJw/n8R6Y=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:From:To:Cc:Date: Content-Type:Message-ID:In-Reply-To:Subject:Reply-To:Sender; b=nyCz21MSDjYsTZeObkegfOMaE8TK4hnAgNJoFSVga0a9mbY6tbIQRU5mSvpMhDpQd d9g0yQYiJZ3xzfeQja1JNTwu6/swJyMAZGZ/JR51TxOfygPmiWBD78F48KzISc0o1i cJnoqowQ7cVFNlG1T3aHCKzDAKHpO+Gg0ipYuHpUpt0IWiJ3tBpPN+em2Z9zYFln2p DJ6ihgNqAVWJ6T8BajegkNDUWrTJLGEtsuwXZ1IpYSoSNNIMw5VgAq4H0L4NUy9fTp Dt4DrEpQV8ZGaxZZ0I7o3NTQGZRMEybHvOm9SZ71xhqhJT3cvOTcsxIEGmy/nPEbQ/ ttCc+yGEC8WBg== To: development@lists.ipfire.org Subject: [PATCH] squid: Add RAM-only Proxy functionality Date: Fri, 16 Feb 2018 13:04:50 +0100 Message-Id: <20180216120450.12580-1-daniel.weismueller@ipfire.org> X-Mailer: git-send-email 2.14.3 MIME-Version: 1.0 Cc: =?utf-8?q?Kim_W=C3=B6lfel?= , Oliver Fieker X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Daniel_Weism=C3=BCller?= via Development From: =?utf-8?q?Peter_M=C3=BCller_via_Development?= Reply-To: =?utf-8?q?Daniel_Weism=C3=BCller?= Errors-To: development-bounces@lists.ipfire.org Sender: "Development" As suggested by Oliver "giller" Fieker in bug 10592 I added the functionality to use the squid as ram-only cache. Further it defines the maximum_object_size_in_memory as 2% of the in the webif defined "Memory cache size". The maximum_object_size_in_memory should have a useful size of the defined memory cache and I don't want to create another variable which muste be fulled in by the user. Signed-off-by: Daniel Weismüller Suggested-by: Oliver "giller" Fieker Suggested-by: Kim Wölfel Acked-by: Michael Tremer Cc: Stefan Schantl Signed-off-by: Daniel Weismüller --- html/cgi-bin/proxy.cgi | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/html/cgi-bin/proxy.cgi b/html/cgi-bin/proxy.cgi index 6aa14e15a..8379cf86d 100644 --- a/html/cgi-bin/proxy.cgi +++ b/html/cgi-bin/proxy.cgi @@ -401,8 +401,7 @@ if (($proxysettings{'ACTION'} eq $Lang::tr{'save'}) || ($proxysettings{'ACTION'} $errormessage = $Lang::tr{'proxy errmsg filedescriptors'}; goto ERROR; } - if (!($proxysettings{'CACHE_MEM'} =~ /^\d+/) || - ($proxysettings{'CACHE_MEM'} < 1)) + if (!($proxysettings{'CACHE_MEM'} =~ /^\d+/)) { $errormessage = $Lang::tr{'advproxy errmsg mem cache size'}; goto ERROR; @@ -3174,7 +3173,7 @@ END } } - if ($proxysettings{'CACHE_SIZE'} > 0) + if (($proxysettings{'CACHE_SIZE'} > 0) || ($proxysettings{'CACHE_MEM'} > 0)) { print FILE "\n"; @@ -3271,7 +3270,12 @@ cache_dir aufs /var/log/cache $proxysettings{'CACHE_SIZE'} $proxysettings{'L1_DI END ; } else { - print FILE "cache deny all\n\n"; + if ($proxysettings{'CACHE_MEM'} > 0) { + # always 2% of CACHE_MEM defined as max object size + print FILE "maximum_object_size_in_memory " . int($proxysettings{'CACHE_MEM'} * 1024 * 0.02) . " KB\n\n"; + } else { + print FILE "cache deny all\n\n"; + } } print FILE <