Commits

Cameron Simpson committed e4c7b61

rig-adzapper: add -L option to specify listening ports

Comments (0)

Files changed (1)

bin-cs/rig-adzapper

 : ${VARLOG:=$HOME/var/log}
 : ${TMPDIR:=/tmp}
 
+dflt_listen=localhost:3128
+
 cmd=`basename "$0"`
 oargs=$*
-usage="Usage: $cmd [upstream-peers...] [tag=value...] [squid-options...]
+usage="Usage: $cmd [-L listen] [upstream-peers...] [tag=value...] [squid-options...]
+  -L listen             http_port specification; default: $dflt_listen
   upstream-peers        Upstream peer specifications of the form \"host:port\".
   tag=value             Tags to be written to the squid.conf as \"tag value\".
   squid-options         Passed to squid on invocation."
 directives=$tmppfx.tags
 trap 'rm -f "$tmppfx.*"' 0 1 3 15
 
+listen=
 zapdir=$LOGDIR/adzapper
 piddir=$VARRUN
 pidf=$piddir/squid.pid
 echo 'acl QUERY urlpath_regex cgi-bin \?'
 echo 'acl GMAP urlpath_regex google.com/[a-z]*\? google.com.au/[a-z]*\?'
 
+while [ $# -gt 0 ]
+do
+  case $1 in
+    -L) listen="$listen $2"; shift ;;
+    *)  break ;;
+  esac
+  shift
+done
+
+[ -n "$listen" ] || listen=$dflt_listen
+
 # emit cache_peer lines
 while [ $# -gt 0 ]
 do
   )
 done
 
+# unzapped
+for l in $listen
+do
+  echo "http_port $l"
+done
+# zapped
+echo "http_port localhost:8080"
+
 cat <<X
 url_rewrite_program $HOME/bin/squid_redirect
 url_rewrite_children 2
 cache_store_log /dev/null
 coredump_dir $zapdir
 cache_dir ufs $cachedir $ZAP_CACHESIZE 16 256
-# unzapped
-http_port localhost:3128
-# zapped
-http_port localhost:8080
 acl nobannerport myport 8080
 redirector_access allow nobannerport
 cache allow GMAP
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.