Skip to content

Commit f19f054

Browse files
authored
Merge pull request #64 from nginxinc/ps-dev-geoip2
Allow parsing of geoip2 module
2 parents a4dc80b + d66d76d commit f19f054

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
@@ -546,6 +546,10 @@ var directives = map[string][]uint{
546546
ngxHTTPMainConf | ngxConfBlock | ngxConfTake12,
547547
ngxStreamMainConf | ngxConfBlock | ngxConfTake12,
548548
},
549+
"geoip2": {
550+
ngxHTTPMainConf | ngxConfBlock | ngxConfTake1,
551+
ngxStreamMainConf | ngxConfBlock | ngxConfTake1,
552+
},
549553
"geoip_city": {
550554
ngxHTTPMainConf | ngxConfTake12,
551555
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)