|
@ -6,8 +6,9 @@ START=50 |
|
|
CFGFILE=/var/etc/tinyproxy.conf |
|
|
CFGFILE=/var/etc/tinyproxy.conf |
|
|
|
|
|
|
|
|
section_enabled() { |
|
|
section_enabled() { |
|
|
|
|
|
local enabled |
|
|
config_get_bool enabled "$1" 'enabled' 0 |
|
|
config_get_bool enabled "$1" 'enabled' 0 |
|
|
[ $enabled -gt 0 ] |
|
|
|
|
|
|
|
|
[ "$enabled" -gt 0 ] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
start() { |
|
|
start() { |
|
@ -22,55 +23,58 @@ stop() { |
|
|
start_proxy() { |
|
|
start_proxy() { |
|
|
section_enabled "$1" || return 1 |
|
|
section_enabled "$1" || return 1 |
|
|
|
|
|
|
|
|
mkdir -m0755 -p /var/etc |
|
|
|
|
|
echo '### AUTOGENERATED CONFIGURATION' > $CFGFILE |
|
|
|
|
|
echo '### DO NOT EDIT' >> $CFGFILE |
|
|
|
|
|
echo '### SEE /etc/config/tinyproxy INSTEAD' >> $CFGFILE |
|
|
|
|
|
echo '' >> $CFGFILE |
|
|
|
|
|
|
|
|
mkdir -p /var/etc |
|
|
|
|
|
chmod 0755 /var/etc |
|
|
|
|
|
{ |
|
|
|
|
|
echo '### AUTOGENERATED CONFIGURATION' |
|
|
|
|
|
echo '### DO NOT EDIT' |
|
|
|
|
|
echo '### SEE /etc/config/tinyproxy INSTEAD' |
|
|
|
|
|
echo '' |
|
|
|
|
|
|
|
|
proxy_atom "$1" User >> $CFGFILE |
|
|
|
|
|
proxy_atom "$1" Group >> $CFGFILE |
|
|
|
|
|
proxy_atom "$1" Port 8888 >> $CFGFILE |
|
|
|
|
|
proxy_atom "$1" Listen >> $CFGFILE |
|
|
|
|
|
proxy_atom "$1" Bind >> $CFGFILE |
|
|
|
|
|
proxy_atom "$1" Timeout >> $CFGFILE |
|
|
|
|
|
|
|
|
proxy_atom "$1" User |
|
|
|
|
|
proxy_atom "$1" Group |
|
|
|
|
|
proxy_atom "$1" Port 8888 |
|
|
|
|
|
proxy_atom "$1" Listen |
|
|
|
|
|
proxy_atom "$1" Bind |
|
|
|
|
|
proxy_atom "$1" Timeout |
|
|
|
|
|
|
|
|
proxy_string "$1" ErrorFile_400 "ErrorFile 400" >> $CFGFILE |
|
|
|
|
|
proxy_string "$1" ErrorFile_403 "ErrorFile 403" >> $CFGFILE |
|
|
|
|
|
proxy_string "$1" ErrorFile_404 "ErrorFile 404" >> $CFGFILE |
|
|
|
|
|
proxy_string "$1" ErrorFile_408 "ErrorFile 408" >> $CFGFILE |
|
|
|
|
|
proxy_string "$1" ErrorFile_503 "ErrorFile 503" >> $CFGFILE |
|
|
|
|
|
|
|
|
proxy_string "$1" ErrorFile_400 "ErrorFile 400" |
|
|
|
|
|
proxy_string "$1" ErrorFile_403 "ErrorFile 403" |
|
|
|
|
|
proxy_string "$1" ErrorFile_404 "ErrorFile 404" |
|
|
|
|
|
proxy_string "$1" ErrorFile_408 "ErrorFile 408" |
|
|
|
|
|
proxy_string "$1" ErrorFile_503 "ErrorFile 503" |
|
|
|
|
|
|
|
|
proxy_string "$1" DefaultErrorFile >> $CFGFILE |
|
|
|
|
|
proxy_string "$1" StatHost StatHost 127.0.0.1 >> $CFGFILE |
|
|
|
|
|
proxy_string "$1" StatFile >> $CFGFILE |
|
|
|
|
|
proxy_string "$1" LogFile >> $CFGFILE |
|
|
|
|
|
|
|
|
proxy_string "$1" DefaultErrorFile |
|
|
|
|
|
proxy_string "$1" StatHost StatHost 127.0.0.1 |
|
|
|
|
|
proxy_string "$1" StatFile |
|
|
|
|
|
proxy_string "$1" LogFile |
|
|
|
|
|
|
|
|
proxy_flag "$1" Syslog >> $CFGFILE |
|
|
|
|
|
|
|
|
proxy_flag "$1" Syslog |
|
|
|
|
|
|
|
|
proxy_atom "$1" LogLevel >> $CFGFILE |
|
|
|
|
|
|
|
|
proxy_atom "$1" LogLevel |
|
|
|
|
|
|
|
|
proxy_flag "$1" XTinyproxy >> $CFGFILE |
|
|
|
|
|
|
|
|
proxy_flag "$1" XTinyproxy |
|
|
|
|
|
|
|
|
proxy_atom "$1" MaxClients >> $CFGFILE |
|
|
|
|
|
proxy_atom "$1" MinSpareServers >> $CFGFILE |
|
|
|
|
|
proxy_atom "$1" MaxSpareServers >> $CFGFILE |
|
|
|
|
|
proxy_atom "$1" StartServers >> $CFGFILE |
|
|
|
|
|
proxy_atom "$1" MaxRequestsPerChild >> $CFGFILE |
|
|
|
|
|
proxy_list "$1" Allow >> $CFGFILE |
|
|
|
|
|
|
|
|
proxy_atom "$1" MaxClients |
|
|
|
|
|
proxy_atom "$1" MinSpareServers |
|
|
|
|
|
proxy_atom "$1" MaxSpareServers |
|
|
|
|
|
proxy_atom "$1" StartServers |
|
|
|
|
|
proxy_atom "$1" MaxRequestsPerChild |
|
|
|
|
|
proxy_list "$1" Allow |
|
|
|
|
|
|
|
|
proxy_string "$1" ViaProxyName >> $CFGFILE |
|
|
|
|
|
proxy_string "$1" Filter >> $CFGFILE |
|
|
|
|
|
|
|
|
proxy_string "$1" ViaProxyName |
|
|
|
|
|
proxy_string "$1" Filter |
|
|
|
|
|
|
|
|
proxy_flag "$1" FilterURLs >> $CFGFILE |
|
|
|
|
|
proxy_flag "$1" FilterExtended >> $CFGFILE |
|
|
|
|
|
proxy_flag "$1" FilterCaseSensitive >> $CFGFILE |
|
|
|
|
|
proxy_flag "$1" FilterDefaultDeny Yes No >> $CFGFILE |
|
|
|
|
|
|
|
|
proxy_flag "$1" FilterURLs |
|
|
|
|
|
proxy_flag "$1" FilterExtended |
|
|
|
|
|
proxy_flag "$1" FilterCaseSensitive |
|
|
|
|
|
proxy_flag "$1" FilterDefaultDeny Yes No |
|
|
|
|
|
|
|
|
proxy_list "$1" Anonymous '"' >> $CFGFILE |
|
|
|
|
|
proxy_list "$1" ConnectPort >> $CFGFILE |
|
|
|
|
|
|
|
|
proxy_list "$1" Anonymous '"' |
|
|
|
|
|
proxy_list "$1" ConnectPort |
|
|
|
|
|
|
|
|
config_foreach write_upstream upstream |
|
|
config_foreach write_upstream upstream |
|
|
|
|
|
} > "$CFGFILE" |
|
|
|
|
|
|
|
|
service_start /usr/sbin/tinyproxy -c "$CFGFILE" |
|
|
service_start /usr/sbin/tinyproxy -c "$CFGFILE" |
|
|
} |
|
|
} |
|
@ -85,11 +89,11 @@ write_upstream() { |
|
|
config_get target "$1" target |
|
|
config_get target "$1" target |
|
|
[ -n "$target" ] && target=' "'"$target"'"' |
|
|
[ -n "$target" ] && target=' "'"$target"'"' |
|
|
|
|
|
|
|
|
[ "$type" == "proxy" -a -n "$via" ] && \ |
|
|
|
|
|
echo "upstream $via$target" >> $CFGFILE |
|
|
|
|
|
|
|
|
[ "$type" = "proxy" ] && [ -n "$via" ] && \ |
|
|
|
|
|
echo "upstream $via$target" |
|
|
|
|
|
|
|
|
[ "$type" == "reject" -a -n "$target" ] && \ |
|
|
|
|
|
echo "no upstream$target" >> $CFGFILE |
|
|
|
|
|
|
|
|
[ "$type" = "reject" ] && [ -n "$target" ] && \ |
|
|
|
|
|
echo "no upstream$target" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
proxy_atom() { |
|
|
proxy_atom() { |
|
@ -111,9 +115,9 @@ proxy_string() { |
|
|
config_get _value "$SECTION" "$OPTION" |
|
|
config_get _value "$SECTION" "$OPTION" |
|
|
[ -z "$_value" ] && _value="$DEFAULT" |
|
|
[ -z "$_value" ] && _value="$DEFAULT" |
|
|
[ -n "$_value" ] && echo "${ALIAS:-${OPTION}} "'"'"$_value"'"' |
|
|
[ -n "$_value" ] && echo "${ALIAS:-${OPTION}} "'"'"$_value"'"' |
|
|
[ -n "$_value" -a "$OPTION" = "LogFile" ] && { |
|
|
|
|
|
touch $_value |
|
|
|
|
|
chmod 666 $_value |
|
|
|
|
|
|
|
|
[ -n "$_value" ] && [ "$OPTION" = "LogFile" ] && { |
|
|
|
|
|
touch "$_value" |
|
|
|
|
|
chmod 666 "$_value" |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|