From 148481f03edf7da0f5587cfc2c54ecb4a404d7d3 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Fri, 2 Apr 2021 14:53:25 +0800 Subject: [PATCH] cloudproxy: forwards: more list filter conditional keys --- pkg/apis/cloudproxy/forwards.go | 5 ++++- pkg/cloudproxy/models/forwards.go | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pkg/apis/cloudproxy/forwards.go b/pkg/apis/cloudproxy/forwards.go index f78fcf4ffe..ded71b9f94 100644 --- a/pkg/apis/cloudproxy/forwards.go +++ b/pkg/apis/cloudproxy/forwards.go @@ -51,7 +51,10 @@ type ForwardListInput struct { ProxyAgentId string ProxyEndpointId string - Type string + Type string + RemoteAddr string + RemotePort *int + BindPortReq *int Opaque string } diff --git a/pkg/cloudproxy/models/forwards.go b/pkg/cloudproxy/models/forwards.go index 64cc8aa78b..5949c57a36 100644 --- a/pkg/cloudproxy/models/forwards.go +++ b/pkg/cloudproxy/models/forwards.go @@ -358,6 +358,7 @@ func (man *SForwardManager) ListItemFilter( ) (*sqlchemy.SQuery, error) { filters := [][2]string{ [2]string{"type", input.Type}, + [2]string{"remote_addr", input.RemoteAddr}, [2]string{"proxy_endpoint_id", input.ProxyEndpointId}, [2]string{"proxy_agent_id", input.ProxyAgentId}, [2]string{"opaque", input.Opaque}, @@ -367,6 +368,18 @@ func (man *SForwardManager) ListItemFilter( q = q.Equals(filter[0], v) } } + intFilters := []struct { + name string + val *int + }{ + {"remote_port", input.RemotePort}, + {"bind_port_req", input.BindPortReq}, + } + for _, filter := range intFilters { + if v := filter.val; v != nil { + q = q.Equals(filter.name, *v) + } + } return q, nil }