From ff0be454ff99737f44968da0b99cbb72b93edfb6 Mon Sep 17 00:00:00 2001 From: Rob Emery Date: Thu, 2 Jan 2025 17:58:14 +0000 Subject: [PATCH] handler hooked in --- dlna/dlnaserver.go | 76 +++++++++++++++++++++++++++++++++++----------- 1 file changed, 58 insertions(+), 18 deletions(-) diff --git a/dlna/dlnaserver.go b/dlna/dlnaserver.go index 48a7f2b87..11406fde6 100644 --- a/dlna/dlnaserver.go +++ b/dlna/dlnaserver.go @@ -59,18 +59,18 @@ type SSDPServer struct { func New(ds model.DataStore, broker events.Broker) *DLNAServer { s := &DLNAServer{ - ds: ds, - broker: broker, + ds: ds, + broker: broker, ssdp: SSDPServer{ AnnounceInterval: time.Duration(30) * time.Second, - Interfaces: listInterfaces(), - FriendlyName: "Navidrome", - RootDeviceUUID: makeDeviceUUID("Navidrome"), - waitChan: make(chan struct{}), + Interfaces: listInterfaces(), + FriendlyName: "Navidrome", + RootDeviceUUID: makeDeviceUUID("Navidrome"), + waitChan: make(chan struct{}), }, } - s.ssdp.services = map[string]UPnPService { + s.ssdp.services = map[string]UPnPService{ "ContentDirectory": &contentDirectoryService{ DLNAServer: s, }, @@ -85,15 +85,15 @@ func New(ds model.DataStore, broker events.Broker) *DLNAServer { //setup dedicated HTTP server for UPNP r := http.NewServeMux() r.Handle(resPath, http.StripPrefix(resPath, http.HandlerFunc(s.ssdp.resourceHandler))) - + r.HandleFunc(rootDescPath, s.ssdp.rootDescHandler) r.HandleFunc(serviceControlURL, s.ssdp.serviceControlHandler) r.Handle("/static/", http.StripPrefix("/static/", withHeader("Cache-Control", "public, max-age=86400", - http.FileServer(http.Dir("/tmp"))))) //TODO - - //s.handler = logging(withHeader("Server", serverField, r)) + http.FileServer(http.Dir("/tmp"))))) //TODO + + s.ssdp.handler = logging(withHeader("Server", serverField, r)) return s } @@ -258,8 +258,8 @@ func isAppropriatelyConfigured(intf net.Interface) bool { func (s *SSDPServer) resourceHandler(w http.ResponseWriter, r *http.Request) { //remotePath := r.URL.Path - - w.Header().Set("Content-Length", strconv.FormatInt(1024, 10)) //TODO + + w.Header().Set("Content-Length", strconv.FormatInt(1024, 10)) //TODO // add some DLNA specific headers if r.Header.Get("getContentFeatures.dlna.org") != "" { @@ -272,8 +272,6 @@ func (s *SSDPServer) resourceHandler(w http.ResponseWriter, r *http.Request) { //http.ServeContent(w, r, remotePath, time.Now(), in) } - - func (s *SSDPServer) rootDescHandler(w http.ResponseWriter, r *http.Request) { buffer := new(bytes.Buffer) @@ -326,7 +324,6 @@ func (s *SSDPServer) soapActionResponse(sa upnp.SoapAction, actionRequestXML []b return service.Handle(sa.Action, actionRequestXML, r) } - func didlLite(chardata string) string { return `