@@ -40,6 +40,9 @@ function updateAppConfig(app, newConfig) {
4040const blockedIPAddresses = [ ] ;
4141const blockedUserAgents = [ ] ;
4242const allowedIPAddresses = [ ] ;
43+ const monitoredUserAgents = [ ] ;
44+ const monitoredIPAddresses = [ ] ;
45+ const userAgentDetails = [ ] ;
4346
4447function updateBlockedIPAddresses ( app , ips ) {
4548 let entry = blockedIPAddresses . find ( ( ip ) => ip . serviceId === app . serviceId ) ;
@@ -110,7 +113,79 @@ function getBlockedUserAgents(app) {
110113 return entry . userAgents ;
111114 }
112115
113- return { serviceId : app . serviceId , userAgents : [ ] } ;
116+ return "" ;
117+ }
118+
119+ function updateMonitoredUserAgents ( app , uas ) {
120+ let entry = monitoredUserAgents . find ( ( e ) => e . serviceId === app . serviceId ) ;
121+
122+ if ( entry ) {
123+ entry . userAgents = uas ;
124+ } else {
125+ entry = { serviceId : app . serviceId , userAgents : uas } ;
126+ monitoredUserAgents . push ( entry ) ;
127+ }
128+
129+ // Bump lastUpdatedAt
130+ updateAppConfig ( app , { } ) ;
131+ }
132+
133+ function getMonitoredUserAgents ( app ) {
134+ const entry = monitoredUserAgents . find ( ( e ) => e . serviceId === app . serviceId ) ;
135+
136+ if ( entry ) {
137+ return entry . userAgents ;
138+ }
139+
140+ return "" ;
141+ }
142+
143+ function updateMonitoredIPAddresses ( app , ips ) {
144+ let entry = monitoredIPAddresses . find ( ( e ) => e . serviceId === app . serviceId ) ;
145+
146+ if ( entry ) {
147+ entry . ipAddresses = ips ;
148+ } else {
149+ entry = { serviceId : app . serviceId , ipAddresses : ips } ;
150+ monitoredIPAddresses . push ( entry ) ;
151+ }
152+
153+ // Bump lastUpdatedAt
154+ updateAppConfig ( app , { } ) ;
155+ }
156+
157+ function getMonitoredIPAddresses ( app ) {
158+ const entry = monitoredIPAddresses . find ( ( e ) => e . serviceId === app . serviceId ) ;
159+
160+ if ( entry ) {
161+ return entry . ipAddresses ;
162+ }
163+
164+ return [ ] ;
165+ }
166+
167+ function updateUserAgentDetails ( app , uas ) {
168+ let entry = userAgentDetails . find ( ( e ) => e . serviceId === app . serviceId ) ;
169+
170+ if ( entry ) {
171+ entry . userAgents = uas ;
172+ } else {
173+ entry = { serviceId : app . serviceId , userAgents : uas } ;
174+ userAgentDetails . push ( entry ) ;
175+ }
176+
177+ // Bump lastUpdatedAt
178+ updateAppConfig ( app , { } ) ;
179+ }
180+
181+ function getUserAgentDetails ( app ) {
182+ const entry = userAgentDetails . find ( ( e ) => e . serviceId === app . serviceId ) ;
183+
184+ if ( entry ) {
185+ return entry . userAgents ;
186+ }
187+
188+ return [ ] ;
114189}
115190
116191module . exports = {
@@ -122,4 +197,10 @@ module.exports = {
122197 getBlockedUserAgents,
123198 getAllowedIPAddresses,
124199 updateAllowedIPAddresses,
200+ updateMonitoredUserAgents,
201+ getMonitoredUserAgents,
202+ updateMonitoredIPAddresses,
203+ getMonitoredIPAddresses,
204+ updateUserAgentDetails,
205+ getUserAgentDetails,
125206} ;
0 commit comments