Settings > Sources: turn syslog reception on/off, choose UDP/TCP

- SyslogServer opens and closes the UDP/TCP listeners at runtime from the
  configuration saved in /data/syslog.json; a busy port no longer stops
  Logstream, the error is shown in Settings instead.
- Sources tab: syslog section with an on/off switch, UDP and TCP labels,
  the live listening state and the published port (SYSLOG_PORT, passed as
  SYSLOG_PUBLIC_PORT for display; the mapping stays in docker-compose).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cedricandClaude Opus 5.5 committed 2026-09-28 17:37:08 +02:00
1 parent 7beb791e44
commit 32593b9515
9 files changed
+278 -28

No files matched your search

+23
View File
@@ -20,6 +20,7 @@ type API struct {
allowPurge bool
exportMax int
docker *DockerManager // nil when DOCKER_LOGS is off
syslog *SyslogServer
}
func (a *API) Routes(mux *http.ServeMux) {
@@ -37,10 +38,32 @@ func (a *API) Routes(mux *http.ServeMux) {
mux.HandleFunc("GET /api/purge", a.purgeStatus)
mux.HandleFunc("POST /api/purge", a.purge)
mux.HandleFunc("GET /api/export.csv", a.exportCSV)
mux.HandleFunc("GET /api/syslog", a.syslogStatus)
mux.HandleFunc("PUT /api/syslog", a.syslogConfigure)
mux.HandleFunc("GET /api/docker", a.dockerStatus)
mux.HandleFunc("PUT /api/docker", a.dockerConfigure)
}
// GET /api/syslog: syslog reception state (Settings > Sources).
func (a *API) syslogStatus(w http.ResponseWriter, r *http.Request) {
writeJSON(w, http.StatusOK, a.syslog.Status())
}
// PUT /api/syslog {"enabled": bool, "udp": bool, "tcp": bool}
func (a *API) syslogConfigure(w http.ResponseWriter, r *http.Request) {
var cfg syslogConfig
if err := json.NewDecoder(http.MaxBytesReader(w, r.Body, 4096)).Decode(&cfg); err != nil {
writeErr(w, http.StatusBadRequest, err)
return
}
if err := a.syslog.Configure(cfg); err != nil {
writeErr(w, http.StatusInternalServerError, err)
return
}
log.Printf("syslog reception changed from %s: %+v", r.RemoteAddr, cfg)
writeJSON(w, http.StatusOK, a.syslog.Status())
}
// GET /api/docker: Docker source state and containers (Settings > Sources).
func (a *API) dockerStatus(w http.ResponseWriter, r *http.Request) {
if a.docker == nil {