@@ -50,10 +50,17 @@ var getTaToleranceDict = function getTaToleranceDict(tolerance) {
50
50
var MonitorROAS = exports [ "default" ] = /*#__PURE__*/ function ( _Monitor ) {
51
51
_inherits ( MonitorROAS , _Monitor ) ;
52
52
function MonitorROAS ( name , channel , params , env , input ) {
53
- var _params$enableAdvance , _params$diffEverySeco ;
53
+ var _params$enableDiffAle , _params$enableExpirat , _params$enableExpirat2 , _params$enableDeleted , _params$enableAdvance ;
54
54
var _this ;
55
55
_classCallCheck ( this , MonitorROAS ) ;
56
56
_this = _callSuper ( this , MonitorROAS , [ name , channel , params , env , input ] ) ;
57
+ _defineProperty ( _assertThisInitialized ( _this ) , "_enablePeriodicCheck" , function ( condition , checkFunction , seconds ) {
58
+ if ( condition ) {
59
+ setInterval ( function ( ) {
60
+ _this . _skipIfStaleVrps ( checkFunction ) ;
61
+ } , global . EXTERNAL_ROA_EXPIRATION_TEST || seconds * 1000 ) ;
62
+ }
63
+ } ) ;
57
64
_defineProperty ( _assertThisInitialized ( _this ) , "_skipIfStaleVrps" , function ( callback ) {
58
65
if ( ! _this . rpki . getStatus ( ) . stale ) {
59
66
callback ( ) ;
@@ -80,9 +87,14 @@ var MonitorROAS = exports["default"] = /*#__PURE__*/function (_Monitor) {
80
87
}
81
88
return times ;
82
89
} ) ;
83
- _defineProperty ( _assertThisInitialized ( _this ) , "_checkDeletedRoasTAs" , function ( vrps ) {
90
+ _defineProperty ( _assertThisInitialized ( _this ) , "_checkDeletedRoasTAs" , function ( ) {
91
+ var vrps = _this . rpki . getVRPs ( ) ; // Get all the vrps as retrieved from the rpki validator
84
92
var sizes = _this . _calculateSizes ( vrps ) ;
85
93
var metadata = _this . rpki . getMetadata ( ) ;
94
+ _this . logger . log ( {
95
+ level : 'info' ,
96
+ message : "Performing TA deletion check"
97
+ } ) ;
86
98
for ( var ta in sizes ) {
87
99
if ( _this . timesDeletedTAs [ ta ] ) {
88
100
var oldSize = _this . timesDeletedTAs [ ta ] ;
@@ -110,9 +122,18 @@ var MonitorROAS = exports["default"] = /*#__PURE__*/function (_Monitor) {
110
122
}
111
123
_this . timesDeletedTAs = sizes ;
112
124
} ) ;
113
- _defineProperty ( _assertThisInitialized ( _this ) , "_checkExpirationTAs" , function ( vrps , expiringVrps ) {
125
+ _defineProperty ( _assertThisInitialized ( _this ) , "_checkExpirationTAs" , function ( ) {
126
+ var roaExpirationAlertHours = _this . roaExpirationAlertHours ;
127
+ var vrps = _this . rpki . getVRPs ( ) ;
128
+ var expiringVrps = vrps . filter ( function ( i ) {
129
+ return ! ! i . expires && i . expires - _moment [ "default" ] . utc ( ) . unix ( ) < roaExpirationAlertHours * 3600 ;
130
+ } ) ;
114
131
var sizes = _this . _calculateSizes ( vrps ) ;
115
132
var expiringSizes = _this . _calculateSizes ( expiringVrps ) ;
133
+ _this . logger . log ( {
134
+ level : 'info' ,
135
+ message : "Performing TA expiration check"
136
+ } ) ;
116
137
var _loop = function _loop ( ta ) {
117
138
var min = expiringSizes [ ta ] ;
118
139
var max = sizes [ ta ] ;
@@ -146,16 +167,18 @@ var MonitorROAS = exports["default"] = /*#__PURE__*/function (_Monitor) {
146
167
_loop ( ta ) ;
147
168
}
148
169
} ) ;
149
- _defineProperty ( _assertThisInitialized ( _this ) , "_verifyExpiration" , function ( roaExpirationAlertHours ) {
170
+ _defineProperty ( _assertThisInitialized ( _this ) , "_verifyExpiration" , function ( ) {
171
+ var roaExpirationAlertHours = _this . roaExpirationAlertHours ;
150
172
var roas = _this . rpki . getVRPs ( ) ;
151
173
var metadata = _this . rpki . getMetadata ( ) ;
152
174
var expiringRoas = roas . filter ( function ( i ) {
153
175
return ! ! i . expires && i . expires - _moment [ "default" ] . utc ( ) . unix ( ) < roaExpirationAlertHours * 3600 ;
154
176
} ) ;
155
- if ( _this . enableExpirationCheckTA ) {
156
- _this . _checkExpirationTAs ( roas , expiringRoas ) ; // Check for TA malfunctions
157
- }
158
177
if ( _this . enableExpirationAlerts ) {
178
+ _this . logger . log ( {
179
+ level : 'info' ,
180
+ message : "Performing expiration check on VRPs"
181
+ } ) ;
159
182
var prefixesIn = _this . monitored . prefixes . map ( function ( i ) {
160
183
return i . prefix ;
161
184
} ) ;
@@ -318,12 +341,14 @@ var MonitorROAS = exports["default"] = /*#__PURE__*/function (_Monitor) {
318
341
_defineProperty ( _assertThisInitialized ( _this ) , "_diffVrps" , function ( ) {
319
342
var newVrps = _this . rpki . getVRPs ( ) ; // Get all the vrps as retrieved from the rpki validator
320
343
321
- if ( _this . enableDeletedCheckTA ) {
322
- _this . _checkDeletedRoasTAs ( newVrps ) ; // Check for TA malfunctions for too many deleted roas
323
- }
324
344
if ( _this . enableDiffAlerts ) {
325
345
if ( _this . _oldVrps ) {
326
346
// No diff if there were no vrps before
347
+
348
+ _this . logger . log ( {
349
+ level : 'info' ,
350
+ message : "Performing diff on VRPs"
351
+ } ) ;
327
352
var prefixesIn = _this . monitored . prefixes . map ( function ( i ) {
328
353
return i . prefix ;
329
354
} ) ;
@@ -478,12 +503,14 @@ var MonitorROAS = exports["default"] = /*#__PURE__*/function (_Monitor) {
478
503
_this . rpki = env . rpki ;
479
504
480
505
// Enabled checks
481
- _this . enableDiffAlerts = params . enableDiffAlerts != null ? params . enableDiffAlerts : true ;
482
- _this . enableExpirationAlerts = params . enableExpirationAlerts != null ? params . enableExpirationAlerts : true ;
483
- _this . enableExpirationCheckTA = params . enableExpirationCheckTA != null ? params . enableExpirationCheckTA : true ;
484
- _this . enableDeletedCheckTA = params . enableDeletedCheckTA != null ? params . enableDeletedCheckTA : true ;
506
+ _this . enableDiffAlerts = ( _params$enableDiffAle = params . enableDiffAlerts ) !== null && _params$enableDiffAle !== void 0 ? _params$enableDiffAle : true ;
507
+ _this . enableExpirationAlerts = ( _params$enableExpirat = params . enableExpirationAlerts ) !== null && _params$enableExpirat !== void 0 ? _params$enableExpirat : true ;
508
+ _this . enableExpirationCheckTA = ( _params$enableExpirat2 = params . enableExpirationCheckTA ) !== null && _params$enableExpirat2 !== void 0 ? _params$enableExpirat2 : true ;
509
+ _this . enableDeletedCheckTA = ( _params$enableDeleted = params . enableDeletedCheckTA ) !== null && _params$enableDeleted !== void 0 ? _params$enableDeleted : true ;
510
+ _this . diffEverySeconds = Math . max ( params . diffEverySeconds || 600 , 300 ) ;
511
+ _this . checkExpirationVrpsEverySeconds = Math . max ( _this . diffEverySeconds , 600 ) ;
512
+ _this . checkTaEverySeconds = Math . max ( params . checkTaEverySeconds || 0 , _this . diffEverySeconds , 15 * 60 ) ;
485
513
_this . enableAdvancedRpkiStats = ( _params$enableAdvance = params . enableAdvancedRpkiStats ) !== null && _params$enableAdvance !== void 0 ? _params$enableAdvance : true ;
486
- _this . diffEverySeconds = ( _params$diffEverySeco = params . diffEverySeconds ) !== null && _params$diffEverySeco !== void 0 ? _params$diffEverySeco : 30 ;
487
514
488
515
// Default parameters
489
516
_this . roaExpirationAlertHours = params . roaExpirationAlertHours || 2 ;
@@ -496,18 +523,10 @@ var MonitorROAS = exports["default"] = /*#__PURE__*/function (_Monitor) {
496
523
asns : [ ] ,
497
524
prefixes : [ ]
498
525
} ;
499
- if ( _this . enableDiffAlerts || _this . enableDeletedCheckTA ) {
500
- setInterval ( function ( ) {
501
- _this . _skipIfStaleVrps ( _this . _diffVrps ) ;
502
- } , _this . diffEverySeconds * 1000 ) ;
503
- }
504
- if ( _this . enableExpirationAlerts || _this . enableExpirationCheckTA ) {
505
- setInterval ( function ( ) {
506
- _this . _skipIfStaleVrps ( function ( ) {
507
- return _this . _verifyExpiration ( _this . roaExpirationAlertHours ) ;
508
- } ) ;
509
- } , global . EXTERNAL_ROA_EXPIRATION_TEST || 600000 ) ;
510
- }
526
+ _this . _enablePeriodicCheck ( _this . enableDiffAlerts , _this . _diffVrps , _this . diffEverySeconds ) ;
527
+ _this . _enablePeriodicCheck ( _this . enableExpirationAlerts , _this . _verifyExpiration , _this . checkExpirationVrpsEverySeconds ) ;
528
+ _this . _enablePeriodicCheck ( _this . enableDeletedCheckTA , _this . _checkDeletedRoasTAs , _this . checkTaEverySeconds ) ; // Check for TA malfunctions for too many deleted roas
529
+ _this . _enablePeriodicCheck ( _this . enableExpirationCheckTA , _this . _checkExpirationTAs , _this . checkTaEverySeconds ) ; // Check for TA malfunctions for too many expiring roas
511
530
return _this ;
512
531
}
513
532
return _createClass ( MonitorROAS ) ;
0 commit comments