Rename adminSocketListener to adminUnixListener

This commit is contained in:
binwiederhier committed 2026-10-30 23:51:28 +00:00
1 parent 89cd122952
commit 6cb87c31b4
2 files changed
+42 -42

No files matched your search

+41 -41
View File
@@ -51,42 +51,42 @@ import (
// Server is the main server, providing the UI and API for ntfy
type Server struct {
config *Config
db *db.DB // Shared PostgreSQL connection pool (with optional replicas), nil when using SQLite
cluster cluster.Cluster // Fans messages out to peer cluster nodes (nop when not clustered)
httpServers []*http.Server
httpsServer *http.Server
httpMetricsServer *http.Server
httpProfileServer *http.Server
httpClusterServer *http.Server // Dedicated private listener for node-to-node fan-out (experimental-cluster-listen)
unixListener net.Listener
adminSocketListener net.Listener // Serves the admin API on the local admin socket, see handleAdminSocket
smtpServer *smtp.Server
smtpServerBackend *smtpBackend
mailer mail.Sender
topics map[string]*topic
limiter *limit.Service // Decides on and counts the visitors' usage, keyed by visitor key
visitors *visitorEnv // Shared by all visitors, which are built per request
ban *ban.Service // Abuse ban-feed; nil when the feature is disabled (no ban file)
firebaseClient *firebaseClient
twilio *twilio.Client
messages int64 // Total number of messages (persisted if messageCache enabled)
messagesHistory []int64 // Last n values of the messages counter, used to determine rate
messagesFlushed int64 // Value of the messages counter at the last stats flush; the difference is written as a delta
userManager *user.Manager // Might be nil!
messageCache *message.Cache // Database that stores the messages
webPush *webpush.Store // Database that stores web push subscriptions
attachment *attachment.Store // Attachment store (file system or S3)
stripe stripeAPI // Stripe API, can be replaced with a mock
priceCache *util.LookupCache[map[string]int64] // Stripe price ID -> price as cents (USD implied!)
metricsHandler http.Handler // Handles /metrics if enable-metrics set, and listen-metrics-http not set
closeChan chan bool
tail *message.Tail // Reads what was written, see runTail; nil without a message cache
stopOnce sync.Once
stopped atomic.Bool // Set by Stop; read by Run, which must not start listeners afterwards
streams *streamRegistry // Open subscriber connections, for Drain
readOnly atomic.Bool // Second phase of a drain: new subscriptions and publishes get 503 (see Drain)
mu sync.RWMutex
config *Config
db *db.DB // Shared PostgreSQL connection pool (with optional replicas), nil when using SQLite
cluster cluster.Cluster // Fans messages out to peer cluster nodes (nop when not clustered)
httpServers []*http.Server
httpsServer *http.Server
httpMetricsServer *http.Server
httpProfileServer *http.Server
httpClusterServer *http.Server // Dedicated private listener for node-to-node fan-out (experimental-cluster-listen)
unixListener net.Listener
adminUnixListener net.Listener // Serves the admin API on the local admin socket, see handleAdminSocket
smtpServer *smtp.Server
smtpServerBackend *smtpBackend
mailer mail.Sender
topics map[string]*topic
limiter *limit.Service // Decides on and counts the visitors' usage, keyed by visitor key
visitors *visitorEnv // Shared by all visitors, which are built per request
ban *ban.Service // Abuse ban-feed; nil when the feature is disabled (no ban file)
firebaseClient *firebaseClient
twilio *twilio.Client
messages int64 // Total number of messages (persisted if messageCache enabled)
messagesHistory []int64 // Last n values of the messages counter, used to determine rate
messagesFlushed int64 // Value of the messages counter at the last stats flush; the difference is written as a delta
userManager *user.Manager // Might be nil!
messageCache *message.Cache // Database that stores the messages
webPush *webpush.Store // Database that stores web push subscriptions
attachment *attachment.Store // Attachment store (file system or S3)
stripe stripeAPI // Stripe API, can be replaced with a mock
priceCache *util.LookupCache[map[string]int64] // Stripe price ID -> price as cents (USD implied!)
metricsHandler http.Handler // Handles /metrics if enable-metrics set, and listen-metrics-http not set
closeChan chan bool
tail *message.Tail // Reads what was written, see runTail; nil without a message cache
stopOnce sync.Once
stopped atomic.Bool // Set by Stop; read by Run, which must not start listeners afterwards
streams *streamRegistry // Open subscriber connections, for Drain
readOnly atomic.Bool // Second phase of a drain: new subscriptions and publishes get 503 (see Drain)
mu sync.RWMutex
}
// handleFunc extends the normal http.HandlerFunc to be able to easily return errors
@@ -512,17 +512,17 @@ func (s *Server) Run() error {
s.mu.Unlock()
return // Nobody would close this listener anymore
}
s.adminSocketListener, err = s.listenAdminSocket()
s.adminUnixListener, err = s.listenAdminSocket()
if err != nil {
s.mu.Unlock()
// Not fatal, unlike the other listeners: the CLI falls back to writing to the database (deprecated)
log.Tag(tagStartup).Err(err).Warn("Admin socket %s not available, 'ntfy user/access/token/tier' will write to the database directly, which is deprecated and stops working after 2026-12-30, see https://ntfy.sh/docs/deprecations/", s.config.ListenAdminUnix)
return
}
defer s.adminSocketListener.Close()
defer s.adminUnixListener.Close()
s.mu.Unlock()
httpServer := &http.Server{Handler: http.HandlerFunc(s.handleAdminSocket)}
errChan <- httpServer.Serve(s.adminSocketListener)
errChan <- httpServer.Serve(s.adminUnixListener)
}()
}
if s.config.MetricsListenHTTP != "" {
@@ -601,8 +601,8 @@ func (s *Server) stop() {
if s.unixListener != nil {
s.unixListener.Close()
}
if s.adminSocketListener != nil {
s.adminSocketListener.Close()
if s.adminUnixListener != nil {
s.adminUnixListener.Close()
}
if s.smtpServer != nil {
s.smtpServer.Close()