ensure decisions from CAPI have proper case (#848)

This commit is contained in:
Thibault "bui" Koechlin 2021-07-02 11:23:46 +02:00 committed by GitHub
parent ca3e9ea487
commit b6ee006078
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -276,6 +276,14 @@ func (a *apic) PullTop() error {
var start_ip, start_sfx, end_ip, end_sfx int64
var sz int
/*CAPI might send lower case scopes, unify it.*/
switch strings.ToLower(*decision.Scope) {
case "ip":
*decision.Scope = types.Ip
case "range":
*decision.Scope = types.Range
}
/*if the scope is IP or Range, convert the value to integers */
if strings.ToLower(*decision.Scope) == "ip" || strings.ToLower(*decision.Scope) == "range" {
sz, start_ip, start_sfx, end_ip, end_sfx, err = types.Addr2Ints(*decision.Value)