aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--cmd/gopherproxy/main.go11
-rw-r--r--gopherproxy.go4
3 files changed, 9 insertions, 7 deletions
diff --git a/README.md b/README.md
index 1898572..2e2cc24 100644
--- a/README.md
+++ b/README.md
@@ -32,6 +32,7 @@ Arguments:
32- `-uri=<uri>`: The default address to open in the proxy (default: "floodgap.com") 32- `-uri=<uri>`: The default address to open in the proxy (default: "floodgap.com")
33- `-robots-file=<file>`: robots.txt file to serve to protect Gopher sites from web crawlers (default: "robots.txt") 33- `-robots-file=<file>`: robots.txt file to serve to protect Gopher sites from web crawlers (default: "robots.txt")
34- `-robots-debug=<true|false>`: Print output about clients ignoring robots.txt (this includes regular browsers) (default: false) 34- `-robots-debug=<true|false>`: Print output about clients ignoring robots.txt (this includes regular browsers) (default: false)
35- `-vips-concurrency=<n>: Concurrency level of libvips (i.e. number of worker threads)`
35 36
36 37
37## Development 38## Development
diff --git a/cmd/gopherproxy/main.go b/cmd/gopherproxy/main.go
index e9dea18..e699d14 100644
--- a/cmd/gopherproxy/main.go
+++ b/cmd/gopherproxy/main.go
@@ -10,15 +10,16 @@ import (
10var ( 10var (
11 // TODO: Allow config file and environment vars 11 // TODO: Allow config file and environment vars
12 // (opt -> env -> config -> default) 12 // (opt -> env -> config -> default)
13 bind = flag.String("bind", "0.0.0.0:8000", "[int]:port to bind to") 13 bind = flag.String("bind", "0.0.0.0:8000", "[int]:port to bind to")
14 robotsfile = flag.String("robots-file", "robots.txt", "robots.txt file") 14 robotsfile = flag.String("robots-file", "robots.txt", "robots.txt file")
15 robotsdebug = flag.Bool("robots-debug", false, "print output about ignored robots.txt") 15 robotsdebug = flag.Bool("robots-debug", false, "print output about ignored robots.txt")
16 uri = flag.String("uri", "floodgap.com", "<host>:[port] to proxy to") 16 uri = flag.String("uri", "floodgap.com", "<host>:[port] to proxy to")
17 vipsconcurrency = flag.Int("vips-concurrency", 1, "Concurrency level of libvips")
17) 18)
18 19
19func main() { 20func main() {
20 flag.Parse() 21 flag.Parse()
21 22
22 // Use a config struct 23 // Use a config struct
23 log.Fatal(gopherproxy.ListenAndServe(*bind, *robotsfile, *robotsdebug, *uri)) 24 log.Fatal(gopherproxy.ListenAndServe(*bind, *robotsfile, *robotsdebug, *vipsconcurrency, *uri))
24} 25}
diff --git a/gopherproxy.go b/gopherproxy.go
index 0ecfa14..0134f88 100644
--- a/gopherproxy.go
+++ b/gopherproxy.go
@@ -242,7 +242,7 @@ func FontHandler(woff2 bool, fontdata []byte) http.HandlerFunc {
242// specified by the request. The robots argument is a pointer to 242// specified by the request. The robots argument is a pointer to
243// a robotstxt.RobotsData struct for testing user agents against 243// a robotstxt.RobotsData struct for testing user agents against
244// a configurable robots.txt file. 244// a configurable robots.txt file.
245func ListenAndServe(bind, robotsfile string, robotsdebug bool, uri string) error { 245func ListenAndServe(bind, robotsfile string, robotsdebug bool, vipsconcurrency int, uri string) error {
246 var ( 246 var (
247 tpl *template.Template 247 tpl *template.Template
248 robotsdata *robotstxt.RobotsData 248 robotsdata *robotstxt.RobotsData
@@ -329,7 +329,7 @@ func ListenAndServe(bind, robotsfile string, robotsdebug bool, uri string) error
329 } 329 }
330 330
331 vips.Startup(&vips.Config{ 331 vips.Startup(&vips.Config{
332 ConcurrencyLevel: 0, 332 ConcurrencyLevel: vipsconcurrency,
333 }) 333 })
334 334
335 http.HandleFunc("/", GopherHandler(tpl, robotsdata, AssetHashList{stylehash, jshash, fontwhash, fontw2hash}, robotsdebug, uri)) 335 http.HandleFunc("/", GopherHandler(tpl, robotsdata, AssetHashList{stylehash, jshash, fontwhash, fontw2hash}, robotsdebug, uri))