@@ -26,6 +26,19 @@ func storeAttackStats(req *protos.AttackDetected) {
2626 }
2727}
2828
29+ func storeMonitoredListsMatches (m * map [string ]int , lists []string ) {
30+ if * m == nil {
31+ * m = make (map [string ]int )
32+ }
33+
34+ for _ , list := range lists {
35+ if _ , exists := (* m )[list ]; ! exists {
36+ (* m )[list ] = 0
37+ }
38+ (* m )[list ] += 1
39+ }
40+ }
41+
2942func storeSinkStats (protoSinkStats * protos.MonitoredSinkStats ) {
3043 globals .StatsData .StatsMutex .Lock ()
3144 defer globals .StatsData .StatsMutex .Unlock ()
@@ -176,6 +189,14 @@ func getRateLimitingStatus(method string, route string, user string, ip string)
176189 return & protos.RateLimitingStatus {Block : false }
177190}
178191
192+ func getIpsList (ipsList map [string ]IpBlocklist ) map [string ]* protos.IpBlockList {
193+ m := make (map [string ]* protos.IpBlockList )
194+ for ipBlocklistSource , ipBlocklist := range ipsList {
195+ m [ipBlocklistSource ] = & protos.IpBlockList {Description : ipBlocklist .Description , Ips : ipBlocklist .Ips }
196+ }
197+ return m
198+ }
199+
179200func getCloudConfig (configUpdatedAt int64 ) * protos.CloudConfig {
180201 isBlockingEnabled := utils .IsBlockingEnabled ()
181202
@@ -187,19 +208,15 @@ func getCloudConfig(configUpdatedAt int64) *protos.CloudConfig {
187208 }
188209
189210 cloudConfig := & protos.CloudConfig {
190- ConfigUpdatedAt : globals .CloudConfig .ConfigUpdatedAt ,
191- BlockedUserIds : globals .CloudConfig .BlockedUserIds ,
192- BypassedIps : globals .CloudConfig .BypassedIps ,
193- BlockedIps : map [string ]* protos.IpBlockList {},
194- BlockedUserAgents : globals .CloudConfig .BlockedUserAgents ,
195- Block : isBlockingEnabled ,
196- }
197-
198- for ipBlocklistSource , ipBlocklist := range globals .CloudConfig .BlockedIpsList {
199- cloudConfig .BlockedIps [ipBlocklistSource ] = & protos.IpBlockList {
200- Description : ipBlocklist .Description ,
201- Ips : ipBlocklist .Ips ,
202- }
211+ ConfigUpdatedAt : globals .CloudConfig .ConfigUpdatedAt ,
212+ BlockedUserIds : globals .CloudConfig .BlockedUserIds ,
213+ BypassedIps : globals .CloudConfig .BypassedIps ,
214+ BlockedIps : getIpsList (globals .CloudConfig .BlockedIpsList ),
215+ BlockedUserAgents : globals .CloudConfig .BlockedUserAgents ,
216+ MonitoredIps : getIpsList (globals .CloudConfig .MonitoredIpsList ),
217+ MonitoredUserAgents : globals .CloudConfig .MonitoredUserAgents ,
218+ UserAgentDetails : globals .CloudConfig .UserAgentDetails ,
219+ Block : isBlockingEnabled ,
203220 }
204221
205222 for _ , endpoint := range globals .CloudConfig .Endpoints {
0 commit comments