Add comments
This commit is contained in:
parent
55c7e00ad6
commit
35a5dfc17a
1 changed files with 3 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ type netList []net.IPNet
|
||||||
|
|
||||||
const ipHeader = "x-forwarded-for"
|
const ipHeader = "x-forwarded-for"
|
||||||
|
|
||||||
|
// Check if any IPNet in the netList contains the given IP
|
||||||
func (n *netList) Contains(ip net.IP) bool {
|
func (n *netList) Contains(ip net.IP) bool {
|
||||||
for _, net := range *n {
|
for _, net := range *n {
|
||||||
if contains := net.Contains(ip); contains {
|
if contains := net.Contains(ip); contains {
|
||||||
|
|
@ -27,6 +28,8 @@ func (n *netList) Contains(ip net.IP) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Redirect to redirect url any request where the user is anon and the request
|
||||||
|
// does not appear to come from a safe origin
|
||||||
func RejectAnonMiddleware(redirect string, next http.Handler) http.Handler {
|
func RejectAnonMiddleware(redirect string, next http.Handler) http.Handler {
|
||||||
safeOriginNets := make(netList, 0, len(conf.Conf.AnonCIDRs))
|
safeOriginNets := make(netList, 0, len(conf.Conf.AnonCIDRs))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue