Skip to content

Commit

Permalink
Fix search by IP fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Herms committed Jan 15, 2021
1 parent 5f54792 commit 8681dcc
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions pkg/frontend/frontend.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,7 @@ func (fe *Frontend) processQuery(r *http.Request) (*result, error) {
case string:
keyComponents = append(keyComponents, fmt.Sprintf("%s=%s", label, (*valuePtrs[i].(*interface{})).(string)))
case net.IP:
addr := (*valuePtrs[i].(*interface{})).(net.IP)
if addr.To4() == nil {
keyComponents = append(keyComponents, fmt.Sprintf("%s=IPv6StringToNum(%s)", label, addr.String()))
} else {
keyComponents = append(keyComponents, fmt.Sprintf("%s=IPv4ToIPv6(IPv4StringToNum(%s))", label, addr.String()))
}

keyComponents = append(keyComponents, fmt.Sprintf("%s=%s", label, (*valuePtrs[i].(*interface{})).(net.IP).String()))
}
}

Expand Down Expand Up @@ -363,7 +357,11 @@ func (fe *Frontend) fieldsToQuery(fields url.Values) (string, error) {
}

if len(fields[fieldName]) == 1 {
conditions = append(conditions, fmt.Sprintf("%s = '%s'", statement, fields[fieldName][0]))
if fieldName == "nexthop" || fieldName == "src_ip_addr" || fieldName == "dst_ip_addr" || fieldName == "agent" {
conditions = append(conditions, fmt.Sprintf("%s = '%s'", statement, fields[fieldName][0]))
} else {
conditions = append(conditions, fmt.Sprintf("%s = '%s'", statement, fields[fieldName][0]))
}
} else {
values := make([]string, 0)
for _, v := range fields[fieldName] {
Expand Down

0 comments on commit 8681dcc

Please sign in to comment.