cloudproxy: forwards: more list filter conditional keys

This commit is contained in:
Yousong Zhou
2021-04-06 13:02:33 +08:00
parent 6ec27d22b5
commit 148481f03e
2 changed files with 17 additions and 1 deletions
+4 -1
View File
@@ -51,7 +51,10 @@ type ForwardListInput struct {
ProxyAgentId string
ProxyEndpointId string
Type string
Type string
RemoteAddr string
RemotePort *int
BindPortReq *int
Opaque string
}
+13
View File
@@ -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
}