Adding ipdenylist annotation (#8795)
* feat: Add support for IP Deny List * fixed gomod * Update package * go mod tidy * Revert "go mod tidy" This reverts commit e6a837e1e76d72115e8727a33d2f4c1cd7249f1f. * update ginko version * Updates e2e tests * fix test typo
This commit is contained in:
parent
bbf7c79f96
commit
8ed3a27e25
15 changed files with 3568 additions and 0 deletions
|
|
@ -41,6 +41,7 @@ const (
|
|||
customHTTPErrors = "custom-http-errors"
|
||||
skipAccessLogUrls = "skip-access-log-urls"
|
||||
whitelistSourceRange = "whitelist-source-range"
|
||||
denylistSourceRange = "denylist-source-range"
|
||||
proxyRealIPCIDR = "proxy-real-ip-cidr"
|
||||
bindAddress = "bind-address"
|
||||
httpRedirectCode = "http-redirect-code"
|
||||
|
|
@ -100,6 +101,7 @@ func ReadConfig(src map[string]string) config.Configuration {
|
|||
to := config.NewDefault()
|
||||
errors := make([]int, 0)
|
||||
skipUrls := make([]string, 0)
|
||||
denyList := make([]string, 0)
|
||||
whiteList := make([]string, 0)
|
||||
proxyList := make([]string, 0)
|
||||
hideHeadersList := make([]string, 0)
|
||||
|
|
@ -169,6 +171,11 @@ func ReadConfig(src map[string]string) config.Configuration {
|
|||
skipUrls = splitAndTrimSpace(val, ",")
|
||||
}
|
||||
|
||||
if val, ok := conf[denylistSourceRange]; ok {
|
||||
delete(conf, denylistSourceRange)
|
||||
denyList = append(denyList, splitAndTrimSpace(val, ",")...)
|
||||
}
|
||||
|
||||
if val, ok := conf[whitelistSourceRange]; ok {
|
||||
delete(conf, whitelistSourceRange)
|
||||
whiteList = append(whiteList, splitAndTrimSpace(val, ",")...)
|
||||
|
|
@ -395,6 +402,7 @@ func ReadConfig(src map[string]string) config.Configuration {
|
|||
|
||||
to.CustomHTTPErrors = filterErrors(errors)
|
||||
to.SkipAccessLogURLs = skipUrls
|
||||
to.DenylistSourceRange = denyList
|
||||
to.WhitelistSourceRange = whiteList
|
||||
to.ProxyRealIPCIDR = proxyList
|
||||
to.BindAddressIpv4 = bindAddressIpv4List
|
||||
|
|
|
|||
|
|
@ -149,6 +149,7 @@ func TestMergeConfigMapToStruct(t *testing.T) {
|
|||
|
||||
def = config.NewDefault()
|
||||
def.LuaSharedDicts = defaultLuaSharedDicts
|
||||
def.DenylistSourceRange = []string{"2.2.2.2/32"}
|
||||
def.WhitelistSourceRange = []string{"1.1.1.1/32"}
|
||||
def.DisableIpv6DNS = true
|
||||
|
||||
|
|
@ -161,6 +162,7 @@ func TestMergeConfigMapToStruct(t *testing.T) {
|
|||
def.Checksum = fmt.Sprintf("%v", hash)
|
||||
|
||||
to = ReadConfig(map[string]string{
|
||||
"denylist-source-range": "2.2.2.2/32",
|
||||
"whitelist-source-range": "1.1.1.1/32",
|
||||
"disable-ipv6-dns": "true",
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue