mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-05-11 21:12:39 +02:00
add whitelist of allowed remote hosts
This commit is contained in:
parent
95fdd8b79f
commit
deaf0abd50
2 changed files with 28 additions and 0 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue