mirror of
https://github.com/willnorris/imageproxy.git
synced 2026-04-29 06:46:23 +02:00
add signature key flag to imageproxy command
This commit is contained in:
parent
a9efefc8e7
commit
7a0f78f4be
2 changed files with 58 additions and 8 deletions
|
|
@ -18,6 +18,7 @@ package main
|
|||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
|
@ -43,6 +44,7 @@ var whitelist = flag.String("whitelist", "", "comma separated list of allowed re
|
|||
var baseURL = flag.String("baseURL", "", "default base URL for relative remote URLs")
|
||||
var cacheDir = flag.String("cacheDir", "", "directory to use for file cache")
|
||||
var cacheSize = flag.Uint64("cacheSize", 100, "maximum size of file cache (in MB)")
|
||||
var signatureKey = flag.String("signatureKey", "", "HMAC key used in calculating request signatures")
|
||||
var version = flag.Bool("version", false, "print version information")
|
||||
|
||||
func main() {
|
||||
|
|
@ -68,6 +70,18 @@ func main() {
|
|||
if *whitelist != "" {
|
||||
p.Whitelist = strings.Split(*whitelist, ",")
|
||||
}
|
||||
if *signatureKey != "" {
|
||||
key := []byte(*signatureKey)
|
||||
if strings.HasPrefix(*signatureKey, "@") {
|
||||
file := strings.TrimPrefix(*signatureKey, "@")
|
||||
var err error
|
||||
key, err = ioutil.ReadFile(file)
|
||||
if err != nil {
|
||||
log.Fatalf("error reading signature file: %v", err)
|
||||
}
|
||||
}
|
||||
p.SignatureKey = key
|
||||
}
|
||||
if *baseURL != "" {
|
||||
var err error
|
||||
p.DefaultBaseURL, err = url.Parse(*baseURL)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue