From 7cfe909644b1d56150c836047d95934c5ced2285 Mon Sep 17 00:00:00 2001 From: Philipp Heckel Date: Mon, 27 Dec 2021 22:27:01 +0100 Subject: [PATCH] CLI arguments --- cmd/serve.go | 22 +++++++++++----------- server/server.yml | 25 ++++++++++++++----------- 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/cmd/serve.go b/cmd/serve.go index 83a5b838..3da824fd 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -22,13 +22,13 @@ var flagsServe = []cli.Flag{ altsrc.NewDurationFlag(&cli.DurationFlag{Name: "cache-duration", Aliases: []string{"b"}, EnvVars: []string{"NTFY_CACHE_DURATION"}, Value: server.DefaultCacheDuration, Usage: "buffer messages for this time to allow `since` requests"}), altsrc.NewDurationFlag(&cli.DurationFlag{Name: "keepalive-interval", Aliases: []string{"k"}, EnvVars: []string{"NTFY_KEEPALIVE_INTERVAL"}, Value: server.DefaultKeepaliveInterval, Usage: "interval of keepalive messages"}), altsrc.NewDurationFlag(&cli.DurationFlag{Name: "manager-interval", Aliases: []string{"m"}, EnvVars: []string{"NTFY_MANAGER_INTERVAL"}, Value: server.DefaultManagerInterval, Usage: "interval of for message pruning and stats printing"}), - altsrc.NewStringFlag(&cli.StringFlag{Name: "smtp-addr", EnvVars: []string{"NTFY_SMTP_ADDR"}, Usage: "SMTP server address (host:port) to allow email sending"}), - altsrc.NewStringFlag(&cli.StringFlag{Name: "smtp-user", EnvVars: []string{"NTFY_SMTP_USER"}, Usage: "SMTP user (if e-mail sending is enabled)"}), - altsrc.NewStringFlag(&cli.StringFlag{Name: "smtp-pass", EnvVars: []string{"NTFY_SMTP_PASS"}, Usage: "SMTP password (if e-mail sending is enabled)"}), - altsrc.NewStringFlag(&cli.StringFlag{Name: "smtp-from", EnvVars: []string{"NTFY_SMTP_FROM"}, Usage: "SMTP sender address (if e-mail sending is enabled)"}), - altsrc.NewStringFlag(&cli.StringFlag{Name: "smtp-server-listen", EnvVars: []string{"NTFY_SMTP_SERVER_LISTEN"}, Usage: "xxxxxxxxxx"}), - altsrc.NewStringFlag(&cli.StringFlag{Name: "smtp-server-domain", EnvVars: []string{"NTFY_SMTP_SERVER_DOMAIN"}, Usage: "xxxxxxxxxxx"}), - altsrc.NewStringFlag(&cli.StringFlag{Name: "smtp-server-addr-prefix", EnvVars: []string{"NTFY_SMTP_SERVER_ADDR_PREFIX"}, Usage: "xxxxxxxxxxx"}), + altsrc.NewStringFlag(&cli.StringFlag{Name: "smtp-sender-addr", Aliases: []string{"smtp-addr"}, EnvVars: []string{"NTFY_SMTP_SENDER_ADDR"}, Usage: "SMTP server address (host:port) for outgoing emails"}), + altsrc.NewStringFlag(&cli.StringFlag{Name: "smtp-sender-user", Aliases: []string{"smtp-user"}, EnvVars: []string{"NTFY_SMTP_SENDER_USER"}, Usage: "SMTP user (if e-mail sending is enabled)"}), + altsrc.NewStringFlag(&cli.StringFlag{Name: "smtp-sender-pass", Aliases: []string{"smtp-pass"}, EnvVars: []string{"NTFY_SMTP_SENDER_PASS"}, Usage: "SMTP password (if e-mail sending is enabled)"}), + altsrc.NewStringFlag(&cli.StringFlag{Name: "smtp-sender-from", Aliases: []string{"smtp-from"}, EnvVars: []string{"NTFY_SMTP_SENDER_FROM"}, Usage: "SMTP sender address (if e-mail sending is enabled)"}), + altsrc.NewStringFlag(&cli.StringFlag{Name: "smtp-server-listen", EnvVars: []string{"NTFY_SMTP_SERVER_LISTEN"}, Usage: "SMTP server address (ip:port) for incoming emails, e.g. :25"}), + altsrc.NewStringFlag(&cli.StringFlag{Name: "smtp-server-domain", EnvVars: []string{"NTFY_SMTP_SERVER_DOMAIN"}, Usage: "SMTP domain for incoming e-mail, e.g. ntfy.sh"}), + altsrc.NewStringFlag(&cli.StringFlag{Name: "smtp-server-addr-prefix", EnvVars: []string{"NTFY_SMTP_SERVER_ADDR_PREFIX"}, Usage: "SMTP email address prefix for topics to prevent spam (e.g. 'ntfy-')"}), altsrc.NewIntFlag(&cli.IntFlag{Name: "global-topic-limit", Aliases: []string{"T"}, EnvVars: []string{"NTFY_GLOBAL_TOPIC_LIMIT"}, Value: server.DefaultGlobalTopicLimit, Usage: "total number of topics allowed"}), altsrc.NewIntFlag(&cli.IntFlag{Name: "visitor-subscription-limit", EnvVars: []string{"NTFY_VISITOR_SUBSCRIPTION_LIMIT"}, Value: server.DefaultVisitorSubscriptionLimit, Usage: "number of subscriptions per visitor"}), altsrc.NewIntFlag(&cli.IntFlag{Name: "visitor-request-limit-burst", EnvVars: []string{"NTFY_VISITOR_REQUEST_LIMIT_BURST"}, Value: server.DefaultVisitorRequestLimitBurst, Usage: "initial limit of requests per visitor"}), @@ -71,10 +71,10 @@ func execServe(c *cli.Context) error { cacheDuration := c.Duration("cache-duration") keepaliveInterval := c.Duration("keepalive-interval") managerInterval := c.Duration("manager-interval") - smtpSenderAddr := c.String("smtp-addr") - smtpSenderUser := c.String("smtp-user") - smtpSenderPass := c.String("smtp-pass") - smtpSenderFrom := c.String("smtp-from") + smtpSenderAddr := c.String("smtp-sender-addr") + smtpSenderUser := c.String("smtp-sender-user") + smtpSenderPass := c.String("smtp-sender-pass") + smtpSenderFrom := c.String("smtp-sender-from") smtpServerListen := c.String("smtp-server-listen") smtpServerDomain := c.String("smtp-server-domain") smtpServerAddrPrefix := c.String("smtp-server-addr-prefix") diff --git a/server/server.yml b/server/server.yml index e6afefc4..bc1bd573 100644 --- a/server/server.yml +++ b/server/server.yml @@ -1,7 +1,7 @@ # ntfy server config file # Public facing base URL of the service (e.g. https://ntfy.sh or https://ntfy.example.com) -# This setting is currently only used by the e-mail feature. +# This setting is currently only used by the e-mail sending feature (outgoing mail only). # # base-url: @@ -46,21 +46,24 @@ # # behind-proxy: false -# If enabled, allow e-mail notifications via the 'X-Email' header. As of today, only SMTP servers -# with plain text auth and STARTLS are supported. Please also refer to the rate limiting settings +# If enabled, allow outgoing e-mail notifications via the 'X-Email' header. If this header is set, +# messages will additionally be sent out as e-mail using an external SMTP server. As of today, only +# SMTP servers with plain text auth and STARTLS are supported. Please also refer to the rate limiting settings # below (visitor-email-limit-burst & visitor-email-limit-burst). # -# - smtp-addr is the hostname:port of the SMTP server -# - smtp-user/smtp-pass are the username and password of the SMTP user -# - smtp-from is the e-mail address of the sender +# - smtp-sender-addr is the hostname:port of the SMTP server +# - smtp-sender-user/smtp-sender-pass are the username and password of the SMTP user +# - smtp-sender-from is the e-mail address of the sender # -# smtp-addr: -# smtp-user: -# smtp-pass: -# smtp-from: +# smtp-sender-addr: +# smtp-sender-user: +# smtp-sender-pass: +# smtp-sender-from: +# XXXXXXXXXXXXXXXXXXXXxx # smtp-server-listen: -# smtp-server-addr: +# smtp-server-domain: +# smtp-server-addr-prefix: # Interval in which keepalive messages are sent to the client. This is to prevent # intermediaries closing the connection for inactivity.