add whitelist of allowed remote hosts

This commit is contained in:
Will Norris 2013-12-04 03:12:56 -08:00
parent 95fdd8b79f
commit deaf0abd50
2 changed files with 28 additions and 0 deletions

View file

@ -5,12 +5,14 @@ import (
"fmt"
"log"
"net/http"
"strings"
"github.com/willnorris/go-imageproxy/cache"
"github.com/willnorris/go-imageproxy/proxy"
)
var port = flag.Int("port", 8080, "port to listen on")
var whitelist = flag.String("whitelist", "", "comma separated list of allowed remote hosts")
func main() {
flag.Parse()
@ -19,6 +21,9 @@ func main() {
p := proxy.NewProxy(nil)
p.Cache = cache.NewMemoryCache()
if *whitelist != "" {
p.Whitelist = strings.Split(*whitelist, ",")
}
server := &http.Server{
Addr: fmt.Sprintf(":%d", *port),
Handler: p,