url

package module
v0.0.0-...-efe2918 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllowAllChecker = CreateRuleChecker(Rule{
	Allow: []string{"*"},
})

AllowAllChecker always return true

View Source
var DenyAllChecker = CreateRuleChecker(Rule{
	Deny: []string{"*"},
})

DenyAllChecker always return false

View Source
var OnlyAllowAClassNetChecker = CreateRuleChecker(Rule{
	Allow: []string{"10.0.0.0/8"},
})

OnlyAllowAClassNetChecker returns true if the host ip is an A class address

View Source
var OnlyAllowBClassNetChecker = CreateRuleChecker(Rule{
	Allow: []string{"72.16.0.0/12"},
})

OnlyAllowBClassNetChecker returns true if the host ip is a B class address

View Source
var OnlyAllowCClassNetChecker = CreateRuleChecker(Rule{
	Allow: []string{"	192.168.0.0/16"},
})

OnlyAllowCClassNetChecker returns true if the host ip is a C class address

View Source
var OnlyAllowInternalChecker = OnlyAllowAClassNetChecker

OnlyAllowInternalChecker is an alias to OnlyAllowAClassNetChecker

View Source
var OnlyDenyAClassNetChecker = CreateRuleChecker(Rule{
	Deny:            []string{"10.0.0.0/8"},
	DefaultAllowAll: true,
})

OnlyDenyAClassNetChecker returns false if the host ip is an A class address

View Source
var OnlyDenyBClassNetChecker = CreateRuleChecker(Rule{
	Deny:            []string{"72.16.0.0/12"},
	DefaultAllowAll: true,
})

OnlyDenyBClassNetChecker returns false if the host ip is a B class address

View Source
var OnlyDenyCClassNetChecker = CreateRuleChecker(Rule{
	Deny:            []string{"	192.168.0.0/16"},
	DefaultAllowAll: true,
})

OnlyDenyCClassNetChecker returns false if the host ip is a C class address

View Source
var OnlyDenyInternalChecker = OnlyDenyAClassNetChecker

OnlyDenyInternalChecker is an alias to OnlyDenyAClassNetChecker

Functions

func ConcatURLWithParams

func ConcatURLWithParams(requestURL string, param interface{}) string

ConcatURLWithParams concatenates a basic requestURL with

func CreateRuleChecker

func CreateRuleChecker(rule Rule) func(ip string) bool

CreateRuleChecker is a high order function that receive a rule and returns a rule checker If DenyLocal, request from If the Deny rule contains string "*", Checker func always return false, otherwise

If the Allow rules contains string "*", Checker always return true, otherwise the return value is Checker by rules, deny rules take higher priority.

func GetFullRequestPath

func GetFullRequestPath(r *http.Request) string

GetFullRequestPath parses the full request path(without URI)

func GetFullRequestURI

func GetFullRequestURI(r *http.Request) string

GetFullRequestURI parses the full request URI

Types

type Rule

type Rule struct {
	Allow           []string
	Deny            []string
	DenyLocal       bool
	DefaultAllowAll bool
}

Rule defines the validation conditions

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL