- Make function synchronous and remove database dependency
- Accept lastNonPendingStatus as parameter instead of monitorID
- Simplify function logic for better testability
- Update call sites to fetch lastNonPendingStatus only when needed
- Add comprehensive test suite with 17 test cases covering all status transitions
Addresses code review feedback about function complexity and testability
Fixes#6025
When a monitor transitions DOWN → PENDING → UP, the UP webhook notification
was not being sent because PENDING → UP transitions were marked as 'not important'
for notifications.
This fix:
- Adds getLastNonPendingStatus() helper to check if monitor was DOWN before PENDING
- Modifies isImportantForNotification() to check history when PENDING → UP transition occurs
- If monitor was DOWN before PENDING, PENDING → UP is now treated as important for notifications
- Maintains backward compatibility: UP → PENDING → UP still doesn't trigger notifications
Tested with Docker container monitor and HTTP monitor scenarios.
Previously, errors in cloudflared socket handlers were silently swallowed
by empty catch blocks, making debugging difficult. This commit adds
proper error logging to all empty catch blocks in the cloudflared
socket handler to improve observability and debugging.
- Added error logging to join handler
- Added error logging to leave handler
- Added error logging to start handler
- Added error logging to removeToken handler
- Replace client.badssl.com tests with unit tests for parseTlsAlertNumber and getTlsAlertName
- Export helper functions for testing
- Keep one integration test for connection success scenario
Error messages could be translated, but TLS alert names (e.g., certificate_required)
are from RFC 8446 spec and should remain in English for consistency.
- Use i18n-t for description with code tag and RFC 8446 spec link
- Add comment that TLS alert names are from spec (not translatable)
- Refactor TCP monitor into smaller functions:
- checkTcp() for standard TCP connectivity check
- performStartTls() for STARTTLS handshake
- checkTlsCertificate() for TLS certificate validation
- attemptTlsConnection() for TLS connection with alert capture
- Improve error messages with more context
Per CommanderStorm's feedback, instead of creating a separate TLS monitor
type, add the TLS alert checking functionality directly to the existing
TCP monitor.
Changes:
- Add TLS_ALERT_CODES, parseTlsAlertNumber(), getTlsAlertName() to tcp.js
- Add checkTlsAlert() method to TCPMonitorType for mTLS verification
- Add 'Expected TLS Alert' dropdown to TCP monitor UI
- Remove separate TLS monitor type (tls.js)
This allows users to verify mTLS endpoints reject connections without
client certificates by expecting specific TLS alerts like
'certificate_required'.
Closes#5837
Add a new TLS monitor type that allows monitoring mTLS endpoints to verify
they properly reject connections without client certificates.
Features:
- New TLS monitor type with hostname and port configuration
- Expected TLS Alert dropdown to specify which TLS alert to expect
- Support for certificate_required (116) alert for mTLS verification
- Optional certificate expiry monitoring when connection succeeds
- Ignore TLS errors option
Closes#5837