Add optional HTTP BASIC authorization

Fixes #18.
This commit is contained in:
Andrew Gaul
2017-07-05 18:20:26 -07:00
parent 8ac256351f
commit 69b89413bd
4 changed files with 82 additions and 0 deletions

View File

@ -17,6 +17,8 @@ var (
key = flag.String("key", "", "proxy cert key path")
ca = flag.String("ca", "", "CA path")
caKey = flag.String("cakey", "", "CA key path")
user = flag.String("user", "", "proxy user name")
pass = flag.String("pass", "", "proxy password")
brotli = flag.Int("brotli", -1, "Brotli compression level (0-11, default 6)")
jpeg = flag.Int("jpeg", 50, "jpeg quality (1-100, 0 to disable)")
@ -45,6 +47,13 @@ func main() {
}
}
// TODO: require cert and key?
if (*user == "") != (*pass == "") {
log.Fatalln("must specify both user and pass")
} else {
p.SetAuthentication(*user, *pass)
}
if *jpeg != 0 {
p.AddTranscoder("image/jpeg", tc.NewJpeg(*jpeg))
}