Skip to content

Commit d66d76d

Browse files
committed
Allow parsing of geoip2 module
https://docs.nginx.com/nginx/admin-guide/security-controls/controlling-access-by-geoip/ we officially recommend using GeoIP2 for allow/restricting based on location and should handle it in crossplane as well.
1 parent f0d33ae commit d66d76d

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

analyze.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,10 @@ var directives = map[string][]uint{
545545
ngxHTTPMainConf | ngxConfBlock | ngxConfTake12,
546546
ngxStreamMainConf | ngxConfBlock | ngxConfTake12,
547547
},
548+
"geoip2": {
549+
ngxHTTPMainConf | ngxConfBlock | ngxConfTake1,
550+
ngxStreamMainConf | ngxConfBlock | ngxConfTake1,
551+
},
548552
"geoip_city": {
549553
ngxHTTPMainConf | ngxConfTake12,
550554
ngxStreamMainConf | ngxConfTake12,

analyze_map.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ var mapBodies = map[string]mapParameterMasks{
3838
"split_clients": {
3939
defaultMasks: ngxConfTake1,
4040
},
41+
"geoip2": {
42+
defaultMasks: ngxConf1More,
43+
},
4144
}
4245

4346
// analyzeMapBody validates the body of a map-like directive. Map-like directives are block directives

analyze_map_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,16 @@ func TestAnalyzeMapBody(t *testing.T) {
165165
term: ";",
166166
wantErr: &ParseError{What: "invalid number of parameters", BlockCtx: "split_clients"},
167167
},
168+
"valid geoip2": {
169+
mapDirective: "geoip2",
170+
parameter: &Directive{
171+
Directive: "$geoip2_data_continent_code",
172+
Args: []string{"continent", "code"},
173+
Line: 5,
174+
Block: Directives{},
175+
},
176+
term: ";",
177+
},
168178
"missing semicolon": {
169179
mapDirective: "map",
170180
parameter: &Directive{

0 commit comments

Comments
 (0)