* Fix parsing hexadecimal integers in conditions
Remove the assumption that JSON contains only decimal integers and
instead identify the base from the prefix of the data.
`strconv.ParseInt` can identify the base of the integer based on its
"prefix":
- 0x -> hexadecimal
- 0o -> octal
- 0b -> binary
- decimal otherwise.
* core: add more tests for condiction.evaluate
* fix isEqual parsing integers as strings
* tests: extend conditions
* Test if we can compare equality of hex in JSON
* Test if we can have hex/oct/bin in conditions
---------
Co-authored-by: TwiN <twin@linux.com>
* feat(SSH): Add support for SSH endpoint
This commit adds support for SSH endpoint monitoring. Users can now configure an endpoint to be monitored using an SSH command by prefixing the endpoint's URL with ssh:\\. The configuration options for an SSH endpoint include the username, password, and command to be executed on the remote server. In addition, two placeholders are supported for SSH endpoints: [CONNECTED] and [STATUS].
This commit also updates the README to include instructions on how to configure SSH endpoints and the placeholders that can be used in their conditions. The README has been updated to include the new SSH-related options in the endpoints[] configuration object.
Here's a summary of the changes made in this commit:
Added support for SSH endpoint monitoring
Updated the documentation to include instructions on how to configure SSH endpoints and the placeholders that can be used in their conditions
* feat: support monitoring WebSocket endpoints
WebSocket endpoints are automatically identified by the URL protocol
specification: `wss://` or `ws://`. The request body is used as the
"message" written to the server, and the answer is stored in the
`[BODY]`.
Optionally, the user can set the `jsonrpc` flag to automatically wrap
the request body in a JSON RPC 2.0 method call.
* core:websocket: close connection after using it
* test: add tests related to WebSocket support
- test we can identify the endpoint type for WebSockets based on the URL
supplied: `wss://` (with SSL/TLS) and `ws://` (plain text).
- test we can generate a JsonRPC 2.0 message via the new endpoint flag
`JsonRPC`.
* core:endpoint: fix name of jsonrpc parameter
See https://en.wikipedia.org/wiki/JSON-RPC#Version_2.0
* core:websocket: fix dangling open connection on error
Move the `defer ws.Close()` to after opening the connection, so the
socket is closed also in case of errors.
* remove jsonrpc flag
* core:websocket: fix nil pointer dereference
The connection should only be closed if successfully opened.
* Move websocket function to client
* update go.mod
* Fix build errors
* Fix errors
* Update client/client.go
---------
Co-authored-by: TwiN <twin@linux.com>
* fix(watchdog): Add functions to avoid dangling file descriptors
* Change function name and add comment under core/endpoint.go
- change the function name of CloseHTTPConnection() to Close()
- add some comments above Close() function
* Update core/endpoint.go
* Update core/endpoint.go
---------
Co-authored-by: Richard Cheng <richard_cheng@trendmicro.com>
Co-authored-by: TwiN <twin@linux.com>
* docs: Don't include Pushover in alerting provider examples
* fix(condition): Partially support numbers with floating point
Fixes#433
Does not add support for decimal numbers, but it converts float64 to int64.
The reason why I'm not just using float64 instead of int64 is because float64 does not support all the numbers that int64 supports, which means this would be a breaking change. Instead, this change at least supports the non-decimal part of floating point numbers.
This is an improvement over the current implementation, as right now, numbers with decimals are just converted to 0 when compared using a non-equal operator
* feat: Add [DOMAIN_EXPIRATION] placeholder for monitoring domain expiration using WHOIS
* test: Fix issue caused by possibility of millisecond elapsed during previous tests
* test: Fix test with different behavior based on architecture
* docs: Revert accidental change to starttls example
* docs: Fix mistake in comment for Condition.hasIPPlaceholder()
* recreated all changes for setting thresholds on Uptime Badges
* Suggestion accepted: Update core/ui/ui.go
Co-authored-by: TwiN <twin@linux.com>
* Suggestion accepted: Update core/ui/ui.go
Co-authored-by: TwiN <twin@linux.com>
* implemented final suggestions by Twin
* Update controller/handler/badge.go
* Update README.md
* test: added the suggestons to set the UiConfig at another line
Co-authored-by: TwiN <twin@linux.com>
* Add support for HideURL UI config parameter
* Redact whole URL when hide-url parameter is set to true
* Add integration test for hide-url functionality
* Document the hide-url config parameter in README
* Apply suggestions from code review
Co-authored-by: TwiN <twin@linux.com>
* Update test to have client config with 1ms timeout
* Re-align README tables
* Update core/endpoint_test.go
* Update core/endpoint_test.go
Co-authored-by: TwiN <twin@linux.com>