Commit graph

76 commits

Author SHA1 Message Date
Thorben Günther
add22b771a
Remove default ntfy server setting
Setting this to "https://ntfy.sh" has security implications: If the user
forgets to set his server, but uses the new short form for topics, the
notification will be sent to "ntfy.sh" and could expose information.
2024-11-21 12:21:12 +01:00
Thorben Günther
182444df3a
Expose context to cache functions 2024-11-09 14:13:33 +01:00
Thorben Günther
ea58dec539
maxNTFYActions should be const 2024-11-07 20:02:22 +01:00
Thorben Günther
bd1abedac1
Allow setting topic through URL query parameters
Closes: https://codeberg.org/xenrox/ntfy-alertmanager/issues/2
2024-11-07 14:09:49 +01:00
Thorben Günther
84a45a909b
config: Allow to separate the ntfy topic from the server 2024-11-07 13:54:21 +01:00
Thorben Günther
9b9d71d648
Fix linter warnings 2024-11-06 15:09:49 +01:00
Thorben Günther
652c8b32cd
Limit number of ntfy actions
ntfy supports a maximum of three actions. If more a defined, the sending
of the message will fail. To prevent this, the surplus actions will be
removed.
2024-11-06 14:45:15 +01:00
Thorben Günther
e85b5e6ea5
Let a label specify its own ntfy topic
References: https://todo.xenrox.net/~xenrox/ntfy-alertmanager/9
2024-11-06 14:16:36 +01:00
Thorben Günther
f4483532f5
Add support for displaying the alert's GeneratorURL 2024-11-06 14:01:01 +01:00
Thorben Günther
f2cac349c6
Support logging to file 2024-09-11 22:45:56 +02:00
Thorben Günther
dc9741b798
config: ReadConfig -> Read
The function is already in the config package, the old naming is
redundant.
2024-09-11 22:02:50 +02:00
Jackson Chen
9b4b135a39
implement priority for resolved alerts 2023-09-28 13:05:28 +02:00
Thorben Günther
3baffc9bef
Send HTTP error code when failing to decode payload 2023-09-28 12:59:10 +02:00
Thorben Günther
d2eef546d5
Remove unnecessary Body.close() calls
The server will close those.
2023-09-22 22:35:16 +02:00
Thorben Günther
86afe915f3
publish: Move fingerprint conversion to config parsing
We only really need to do it once, not every time a new message gets
published.
2023-08-28 00:36:41 +02:00
Thorben Günther
1abacacab4
publish: Improve certificate fingerprint output 2023-08-27 16:53:19 +02:00
Thorben Günther
ad2bc1fd89
publish: Improve certificate verification
Remove colons and convert to lower case. hex.EncodeToString outputs a
lower case string.
2023-08-25 22:36:00 +02:00
Thorben Günther
25e65db8bd
Add support for self signed ntfy certificates
A fingerprint can be specified in the configuration file. If it matches
the one from the server certificate, it will be accepted.

Closes: https://todo.xenrox.net/~xenrox/ntfy-alertmanager/22
2023-08-25 14:57:54 +02:00
Thorben Günther
2dcfb7270e
Add CORS middleware
Fixes: https://todo.xenrox.net/~xenrox/ntfy-alertmanager/21
2023-08-16 01:18:51 +02:00
Thorben Günther
ddd41a6341
Add option for setting the logging format 2023-08-13 16:02:02 +02:00
Thorben Günther
6d64c21549
Use Logger.With to create child loggers for the handlers
With that it will be easier to check on which endpoint a failure
happened.
2023-08-13 15:16:26 +02:00
Thorben Günther
dab77f6393
Use "log/slog" for logging 2023-08-13 14:48:27 +02:00
Thorben Günther
164e30b37d
Use slices.Contains from the standard library 2023-08-11 13:39:19 +02:00
Thorben Günther
c5575c3dc1
Simplify HTTP Basic Authentication middleware 2023-07-19 16:00:20 +02:00
Thorben Günther
913a076c52
Implement graceful shutdown 2023-07-17 16:39:16 +02:00
Thorben Günther
e0e1281ec3
http: Use own server 2023-07-14 12:47:22 +02:00
Thorben Günther
fab51ab54b
http: Use own multiplexer 2023-07-14 12:38:43 +02:00
Thorben Günther
b2a1ab61c9
cache: Move creation logic into cache package 2023-07-12 19:00:25 +02:00
Thorben Günther
c70b82e9ab
config: Move to own package 2023-07-12 14:56:48 +02:00
Thorben Günther
dc9078c3f5
publish: Try to decode ntfy error string 2023-07-07 23:20:03 +02:00
Thorben Günther
7efc6cdbc2
Add phone call support
Implements: https://todo.xenrox.net/~xenrox/ntfy-alertmanager/18
2023-07-07 21:37:11 +02:00
Thorben Günther
025ad78a60
Add ntfy email support
Implements: https://todo.xenrox.net/~xenrox/ntfy-alertmanager/15
2023-03-09 17:02:05 +01:00
Thorben Günther
53bd3b4e58
config: Add redis-url 2023-03-08 22:19:27 +01:00
Thorben Günther
054c163ffb
cache: Support redis
Closes: https://todo.xenrox.net/~xenrox/ntfy-alertmanager/11
2023-03-08 22:18:30 +01:00
Thorben Günther
d35b77fbc9
cache: Move to own interface package
With this interface it will be easy to support multiple cache types.
2023-03-08 16:16:21 +01:00
Thorben Günther
5a8a85f0f9
Sort labels alphabetically
Closes: https://todo.xenrox.net/~xenrox/ntfy-alertmanager/13
2023-02-21 14:37:26 +01:00
Thorben Günther
82a22c8959
Simplify outgoing Basic Authentication 2023-02-21 14:12:21 +01:00
Thorben Günther
d7fdd85b72
multi mode: Simplify code
Just like it's done in the single mode.
2023-02-21 14:02:19 +01:00
Thorben Günther
cd848543b3
Slightly improve logging 2023-02-21 14:00:21 +01:00
Thorben Günther
af7469d97b
Rename receiver to bridge 2023-02-21 13:57:21 +01:00
Thorben Günther
41fb0f7766
ntfy: Support authentication via access-tokens
Implements: https://todo.xenrox.net/~xenrox/ntfy-alertmanager/14
2023-02-21 11:50:50 +01:00
Thorben Günther
b58ce4acb3
Set default header for User-Agent 2023-02-20 13:27:41 +01:00
Thorben Günther
f1dfde6891
Add icon support
Implements: https://todo.xenrox.net/~xenrox/ntfy-alertmanager/12
2023-02-20 13:08:59 +01:00
Thorben Günther
1daa751cb2
Move http.Client to receiver struct 2023-02-17 01:45:14 +01:00
Thorben Günther
84c4c45d5b
version: Use linker flag
Embedding the version file is slightly annoying for packaging, because
the release tarball is not a git repository and so "go generate" would
fail. Instead a packager would have to manually create the version.txt
file.
With using a linker flag, the version string has a graceful fallback.
2023-02-16 13:06:21 +01:00
Thorben Günther
8a387ff834
Add tags for resolved alerts
Implements: https://todo.xenrox.net/~xenrox/ntfy-alertmanager/8
2023-02-12 17:09:23 +01:00
Thorben Günther
df02ee5303
cache: Only cache the alert if it was published successfully 2023-02-12 16:50:18 +01:00
Thorben Günther
a329d4dc52
silence: Fix broken ntfy action
A silence action was added even when "base-url" was not set. This action
would of course fail, since there was no valid URL scheme given.
The action button is now removed in that case.
2023-02-12 16:32:34 +01:00
Thorben Günther
7bb448b5eb
Refactor structs to use map[string]string 2023-02-12 14:40:32 +01:00
Thorben Günther
1b986078f0
silence: Don't add silence action to resolved alerts 2023-02-12 14:32:05 +01:00