Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[geo-ip] Crashes when mmdb files are not configured #18

Open
LaurenceJJones opened this issue Dec 27, 2024 · 0 comments · May be fixed by #19
Open

[geo-ip] Crashes when mmdb files are not configured #18

LaurenceJJones opened this issue Dec 27, 2024 · 0 comments · May be fixed by #19

Comments

@LaurenceJJones
Copy link
Collaborator

LaurenceJJones commented Dec 27, 2024

Currently the calls to lookup the IP in geoip causes a crash if they are not configured.

If they are not configured the module should just bypass and return an empty data.

"get:geo:iso": {
handle: func(_ apiPermission.ApiPermission, args ...string) (interface{}, error) {
if err := ArgsCheck(args, 1, 1); err != nil {
return nil, err
}
log.Infof("Checking IP %s", args[0])
val := net.ParseIP(args[0])
if val == nil {
return nil, fmt.Errorf("invalid IP")
}
record, err := a.GeoDatabase.GetCity(&val)
if err != nil && !errors.Is(err, geo.NotValidConfig) {
return nil, err
}
return geo.GetIsoCodeFromRecord(record), nil
},

The above code should call geoDatabase.isValid() as a pre-flight check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant