-
Notifications
You must be signed in to change notification settings - Fork 12
/
reject_insecure.option.go
38 lines (32 loc) · 1.38 KB
/
reject_insecure.option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2020 The searKing Author. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package http
import "log"
// RejectInsecureWithErrorLog specifies an optional logger for errors
func RejectInsecureWithErrorLog(l *log.Logger) RejectInsecureOption {
return RejectInsecureOptionFunc(func(r *rejectInsecure) {
r.ErrorLog = l
})
}
// RejectInsecureWithForceHttp specifies whether to allow any request, as a shortcut circuit
func RejectInsecureWithForceHttp(forceHttp bool) RejectInsecureOption {
return RejectInsecureOptionFunc(func(r *rejectInsecure) {
r.ForceHttp = forceHttp
})
}
// RejectInsecureWithAllowedTlsCidrs specifies whether to allow any request which client or proxy's ip included
// a cidr is a CIDR notation IP address and prefix length,
// like "192.0.2.0/24" or "2001:db8::/32", as defined in
// RFC 4632 and RFC 4291.
func RejectInsecureWithAllowedTlsCidrs(allowedTLSCIDRs []string) RejectInsecureOption {
return RejectInsecureOptionFunc(func(r *rejectInsecure) {
r.AllowedTlsCidrs = allowedTLSCIDRs
})
}
// RejectInsecureWithWhitelistedPaths specifies whether to allow any request which http path matches
func RejectInsecureWithWhitelistedPaths(whitelistedPaths []string) RejectInsecureOption {
return RejectInsecureOptionFunc(func(r *rejectInsecure) {
r.WhitelistedPaths = whitelistedPaths
})
}