From: Jo-Philipp Wich Date: Wed, 5 Nov 2008 23:05:09 +0000 (+0000) Subject: * luci/applications: add polipo proxy support X-Git-Tag: 0.9.0~1005 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=6d31daf97e8a3e5158901271c10c57633cd4366f;p=oweals%2Fluci.git * luci/applications: add polipo proxy support --- diff --git a/applications/luci-polipo/Makefile b/applications/luci-polipo/Makefile new file mode 100644 index 000000000..f7fac7740 --- /dev/null +++ b/applications/luci-polipo/Makefile @@ -0,0 +1,2 @@ +include ../../build/config.mk +include ../../build/module.mk diff --git a/applications/luci-polipo/ipkg/postinst b/applications/luci-polipo/ipkg/postinst new file mode 100755 index 000000000..16408879a --- /dev/null +++ b/applications/luci-polipo/ipkg/postinst @@ -0,0 +1,4 @@ +#!/bin/sh +[ -n "${IPKG_INSTROOT}" ] || { + ( . /etc/uci-defaults/luci-polipo ) && rm -f /etc/uci-defaults/luci-polipo +} diff --git a/applications/luci-polipo/luasrc/controller/polipo.lua b/applications/luci-polipo/luasrc/controller/polipo.lua new file mode 100644 index 000000000..c3965ee2e --- /dev/null +++ b/applications/luci-polipo/luasrc/controller/polipo.lua @@ -0,0 +1,28 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2008 Aleksandar Krsteski + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- +module("luci.controller.polipo", package.seeall) + +function index() + if not luci.fs.isfile("/etc/config/polipo") then + return + end + + require("luci.i18n") + luci.i18n.loadc("polipo") + local i18n = luci.i18n.translate + + local p = entry({"admin", "services", "polipo"}, cbi("polipo"), i18n("polipo", "Polipo")) + p.dependent = true + p.i18n = "polipo" +end diff --git a/applications/luci-polipo/luasrc/i18n/polipo.en.lua b/applications/luci-polipo/luasrc/i18n/polipo.en.lua new file mode 100644 index 000000000..23b18363c --- /dev/null +++ b/applications/luci-polipo/luasrc/i18n/polipo.en.lua @@ -0,0 +1,43 @@ +polipo = 'Polipo' +polipo_cache = 'On-Disk Cache' +polipo_cache_cacheisshared = 'Shared cache' +polipo_cache_cacheisshared_desc = 'Enable if cache (proxy) is shared by multiple users.' +polipo_cache_desc = 'To enable polipo on-disk cache cleaning (highly recommended), you should add a cron job in Scheduled Tasks services that will execute /usr/sbin/polipo_purge script. For example to perform disk cache cleanup every day at 6:00 in the morning you should add the following line in Scheduled Tasks "0 6 * * * /usr/sbin/polipo_purge" (without quotes).' +polipo_cache_diskcacheroot = 'Disk cache location' +polipo_cache_diskcacheroot_desc = 'Location where polipo will cache files permanently. Use of external storage devices is recommended, because the cache can grow considerably. Leave it empty to disable on-disk cache.' +polipo_cache_diskcachetruncatesize = 'Truncate cache files size (in bytes)' +polipo_cache_diskcachetruncatesize_desc = 'Size to which cached files should be truncated. (default value: 1048576)' +polipo_cache_diskcachetruncatetime = 'Truncate cache files time' +polipo_cache_diskcachetruncatetime_desc = 'Time after which cached files will be truncated. (default value: 4d12h)' +polipo_cache_diskcacheunlinktime = 'Delete cache files time' +polipo_cache_diskcacheunlinktime_desc = 'Time after which cached files will be deleted. (default value: 32d)' +polipo_desc = 'Polipo is a small and fast caching web proxy.' +polipo_general = 'General' +polipo_general_allowedclients = 'Allowed clients' +polipo_general_allowedclients_desc = 'When listen address is set to 0.0.0.0 or :: (IPv6), you must list clients that are allowed to connect. The format is IP address or network address (192.168.1.123, 192.168.1.0/24, 2001:660:116::/48 (IPv6)).' +polipo_general_chunkhighmark = 'In RAM cache size (in bytes)' +polipo_general_chunkhighmark_desc = 'How much RAM should Polipo use for its cache.' +polipo_general_dnsnameserver = 'DNS server address' +polipo_general_dnsnameserver_desc = 'Set the DNS server address to use, if you want Polipo to use different DNS server than the host system.' +polipo_general_dnsqueryipv6 = 'Query DNS for IPv6' +polipo_general_dnsqueryipv6_desc = 'false = Do not query IPv6; reluctantly = Query both, prefer IPv4; happily = Query both, prefer IPv6; true = Query only IPv6' +polipo_general_dnsusegethostbyname = 'Query DNS by hostname' +polipo_general_dnsusegethostbyname_desc = 'false = Never use system DNS resolver; reluctantly = Query DNS directly, if DNS server is unavailable fail to system DNS resolver; happily = Query DNS directly, if host could not be found fallback to system DNS resolver; true = Always use system DNS resolver' +polipo_general_logfacility = 'Syslog facility' +polipo_general_logfile = 'Log file location' +polipo_general_logfile_desc = 'Use of external storage device is recommended, because the log file is written frequently and can grow considerably.' +polipo_general_logsyslog = 'Log to syslog' +polipo_general_parentauthcredentials = 'Parent proxy authentication' +polipo_general_parentauthcredentials_desc = 'Basic HTTP authentication supported. Provide username and password in username:password format.' +polipo_general_parentproxy = 'Parent proxy address' +polipo_general_parentproxy_desc = 'Parent proxy address (in host:port format), to which Polipo will forward the requests.' +polipo_general_proxyaddress = 'Listen address' +polipo_general_proxyaddress_desc = 'The interface on which Polipo will listen. To listen on all interfaces use 0.0.0.0 or :: (IPv6).' +polipo_general_proxyport = 'Listen port' +polipo_general_proxyport_desc = 'Port on which Polipo will listen. (default value: 8123)' +polipo_pmm = 'Poor Man's Multiplexing' +polipo_pmm_desc = 'Poor Man's Multiplexing (PMM) is a technique that simulates multiplexing by requesting an instance in multiple segments. It tries to lower the latency caused by the weakness of HTTP protocol. NOTE: some sites may not work with PMM enabled.' +polipo_pmm_pmmfirstsize = 'First PMM segment size (in bytes)' +polipo_pmm_pmmfirstsize_desc = 'Size of the first PMM segment. If not defined, it defaults to twice the PMM segment size.' +polipo_pmm_pmmsize = 'PMM segments size (in bytes)' +polipo_pmm_pmmsize_desc = 'To enable PMM, PMM segment size must be set to some positive value.' diff --git a/applications/luci-polipo/luasrc/model/cbi/polipo.lua b/applications/luci-polipo/luasrc/model/cbi/polipo.lua new file mode 100644 index 000000000..81cfa50de --- /dev/null +++ b/applications/luci-polipo/luasrc/model/cbi/polipo.lua @@ -0,0 +1,67 @@ +--[[ +LuCI - Lua Configuration Interface + +Copyright 2008 Aleksandar Krsteski + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +$Id$ +]]-- +m = Map("polipo") + +-- General section +s = m:section(NamedSection, "general", "polipo") + +-- General settings +s:option(Flag, "enabled", translate("enable")) +s:option(Value, "proxyAddress") +s:option(Value, "proxyPort").optional = true +s:option(DynamicList, "allowedClients") +s:option(Flag, "logSyslog") +s:option(Value, "logFacility"):depends("logSyslog", "1") +v = s:option(Value, "logFile") +v:depends("logSyslog", "") +v.rmempty = true +s:option(Value, "chunkHighMark") + +-- DNS and proxy settings +s:option(Value, "dnsNameServer").optional = true +s:option(Value, "parentProxy").optional = true +s:option(Value, "parentAuthCredentials").optional = true +l = s:option(ListValue, "dnsQueryIPv6") +l.optional = true +l.default = "happily" +l:value("") +l:value("true") +l:value("reluctantly") +l:value("happily") +l:value("false") +l = s:option(ListValue, "dnsUseGethostbyname") +l.optional = true +l.default = "reluctantly" +l:value("") +l:value("true") +l:value("reluctantly") +l:value("happily") +l:value("false") + +-- Dsik cache section +s = m:section(NamedSection, "cache", "polipo") + +-- Dsik cache settings +s:option(Value, "diskCacheRoot").rmempty = true +s:option(Flag, "cacheIsShared") +s:option(Value, "diskCacheTruncateSize").optional = true +s:option(Value, "diskCacheTruncateTime").optional = true +s:option(Value, "diskCacheUnlinkTime").optional = true + +-- Poor man's multiplexing section +s = m:section(NamedSection, "pmm", "polipo") +s:option(Value, "pmmSize").rmempty = true +s:option(Value, "pmmFirstSize").optional = true + +return m diff --git a/applications/luci-polipo/root/etc/uci-defaults/luci-polipo b/applications/luci-polipo/root/etc/uci-defaults/luci-polipo new file mode 100644 index 000000000..8a033f8c3 --- /dev/null +++ b/applications/luci-polipo/root/etc/uci-defaults/luci-polipo @@ -0,0 +1,7 @@ +#!/bin/sh + +uci batch <<-EOF + add ucitrack polipo + set ucitrack.@polipo[-1].init=polipo + commit ucitrack +EOF diff --git a/applications/luci-polipo/root/usr/sbin/polipo_purge b/applications/luci-polipo/root/usr/sbin/polipo_purge new file mode 100755 index 000000000..ce7c88559 --- /dev/null +++ b/applications/luci-polipo/root/usr/sbin/polipo_purge @@ -0,0 +1,18 @@ +#!/bin/sh + +DAEMON=/usr/sbin/polipo +PIDFILE=`uci get polipo.daemon.pidFile` +CFGFILE=/var/etc/polipo.conf + +[ -e "$PIDFILE" ] && { + PID=`cat $PID_FILE` + + # send Polipo USR1 signal to write its in-memory cache to disk + kill -USR1 $PID + sleep 2 + # start polipo with -x flag to purge the on-disk cache + polipo -c $CFGFILE -x + # send Polipo USR2 signal to discard its in-memory cache + kill -USR2 $PID +} +