MCPcopy
hub / github.com/safing/portmaster / processQuery

Method processQuery

service/network/database.go:121–182  ·  view source on GitHub ↗
(q *query.Query, it *iterator.Iterator)

Source from the content-addressed store, hash-verified

119}
120
121func (s *StorageInterface) processQuery(q *query.Query, it *iterator.Iterator) {
122 var matches bool
123 pid, scope, _, ok := parseDBKey(q.DatabaseKeyPrefix())
124 if !ok {
125 it.Finish(nil)
126 return
127 }
128
129 if pid == "" {
130 // processes
131 for _, proc := range process.All() {
132 func() {
133 proc.Lock()
134 defer proc.Unlock()
135 matches = q.Matches(proc)
136 }()
137 if matches {
138 it.Next <- proc
139 }
140 }
141 }
142
143 if scope == dbScopeNone || scope == dbScopeDNS {
144 // dns scopes only
145 for _, dnsConn := range dnsConns.clone() {
146 if !dnsConn.DataIsComplete() {
147 continue
148 }
149
150 func() {
151 dnsConn.Lock()
152 defer dnsConn.Unlock()
153 matches = q.Matches(dnsConn)
154 }()
155
156 if matches {
157 it.Next <- dnsConn
158 }
159 }
160 }
161
162 if scope == dbScopeNone || scope == dbScopeIP {
163 // connections
164 for _, conn := range conns.clone() {
165 if !conn.DataIsComplete() {
166 continue
167 }
168
169 func() {
170 conn.Lock()
171 defer conn.Unlock()
172 matches = q.Matches(conn)
173 }()
174
175 if matches {
176 it.Next <- conn
177 }
178 }

Callers 1

QueryMethod · 0.95

Calls 9

AllFunction · 0.92
DatabaseKeyPrefixMethod · 0.80
cloneMethod · 0.80
DataIsCompleteMethod · 0.80
parseDBKeyFunction · 0.70
LockMethod · 0.65
UnlockMethod · 0.65
MatchesMethod · 0.65
FinishMethod · 0.45

Tested by

no test coverage detected