37 Commits

Author SHA1 Message Date
Justin Maggard
c21208508d upnphttp: Protect against DNS rebinding attacks
Validate HTTP requests to protect against DNS rebinding.
2022-02-10 23:51:28 -08:00
Gleb Smirnoff
f9a78d598e Support for pluggable event modules, stage 1. Take out select() loop and associated code into a separate module select.c. Detailed list of changes down below.
The idea is taken from the nginx web server, but much simplified and
almost no copypaste left. This will allow minidlna to use different
event dispatcher APIs, which would be defined at compile time.

My personal goal is to convert minidlna to kqueue(2) on FreeBSD. This
would later allow for kqueue based directory change notification, which
won't conflict with select(2) like the current patch does.
Other platforms will also benefit from the pluggability of the event
system, Linux can switch to epoll(2) or at least to poll(2).

Detailed list of changes:

* event.h [New]
  Our internal API to unify different event dispatch systems.
* select.c [New]
  Much simplified version of nginx's ngx_select_module.c.
* minidlna.c
  - Split out listen socket event processing into separate function
    ProcessListen(), which matches event_process_t type.
  - Create and initialize struct event for the monitor socket, SSDP
    socket, HTTP socket and beacon socket.
  - Simplify and make more precise timeout calculation using
    helper timeval functions from utils.c. Treat gettimeofday() error
    as a fatal event.
  - Rip out all stuff related to select(2). Just call event_module.process().
* upnpevents.c
  - Embed struct event into upnp_event_notify.
  - Merge upnp_event_create_notify() with upnp_event_notify_connect().
    Start connecting immediately after socket creation. Garbage collect
    now useless ECreated state.
  - Make upnp_event_process_notify() of event_process_t type, and use it
    as process callback for upnp_event_notify event.
  - Looks like we always create upnp_event_notify with existing subscriber,
    and never clear it later. Remove checks for obj->sub and assert that it
    is never NULL. Simplifies things.
  - When switching obj state, add/del it to event dispatcher accrodingly.
  - Garbage collect upnpevents_selectfds().
  - Garbage collect select(2) related stuff from upnpevents_processfds().
    Rename function to upnpevents_gc(), since the remaining functionality
    is garbage collecting, not file descriptor processing.
    Actually, this can be simplified even more. We can safely close sockets
    and free objects immediately, eliminating need for upnpevents_gc(). But
    this change would be beyond scope of this commit.
* upnphttp.c, upnphttp.h
  Embed struct event into struct upnphttp. Adjust Process_upnphttp() to match
  event_process_t type. Add/del to event dispatcher once creating/closing a
  socket.
* minissdp.c, minissdp.h
  Make ProcessSSDPRequest() of event_process_t type.
* getifaddr.c, getifaddr.h
  Make ProcessMonitorEvent() of event_process_t type.
2018-01-16 16:53:08 -08:00
Justin Maggard
5b3c6a3645 upnphttp: declare a couple functions static 2014-07-18 12:26:30 -07:00
Justin Maggard
e9a653d6e8 clients: restructure client cache 2014-06-09 18:02:03 -07:00
Justin Maggard
1c748c1d5a * Consolidate client detection code.
* Add forced sorting support for Panasonic devices.
2013-03-18 05:37:46 +00:00
Justin Maggard
ba162fc082 * Add flag to force downscaled thumbnails rather than using embedded ones.
* Add DirecTV client detection.
2012-05-31 18:37:22 +00:00
Justin Maggard
6b5e121f13 * Add DLNA.ORG_FLAGS support, and clean up transferMode support. 2012-02-14 18:43:35 +00:00
Justin Maggard
08172a4ed2 * Enhance error checking in some additional places as required by the latest UPnP CTT. 2012-01-21 01:00:26 +00:00
Justin Maggard
773e1f6566 * Add support for other operating systems (kFreeBSD, FreeBSD, and OSX for now).
* Switch to autoconf from genconfig.sh.
2011-09-16 23:39:58 +00:00
Justin Maggard
1e23a1e8e9 * Send a custom root description to enable the subtitle menu on some Samsung TV's. 2011-08-31 18:21:30 +00:00
Justin Maggard
546175743a * Add WAV MIME workaround for Marantz Receivers and Roku SoundBridge.
* Fix bitrate displayed on Microsoft PFS devices.
2011-08-18 23:24:17 +00:00
Justin Maggard
108fda1e84 * Add the ability to change the root media container. (Thanks to Ivan Mironov) 2011-06-25 00:39:45 +00:00
Justin Maggard
0cf2e5731a * Make a distiction between Samsung A series and later models. We need to trick A series only into playing AVI files. 2011-05-28 00:01:21 +00:00
Justin Maggard
9806103335 * Add support for multiple network interfaces. 2011-05-24 17:20:16 +00:00
Justin Maggard
7068d2fda4 * Improve TiVo error handling. 2011-04-28 21:04:24 +00:00
Justin Maggard
e72c9d0a08 * Send known audio-only devices straight to the Music section on root requests. 2011-04-12 20:58:01 +00:00
Justin Maggard
07c5fd5dd6 * Add the ability to parse the root description of clients after they send an SSDP NOTIFY.
* Using this new capability, detect Roku SoundBridge clients.
2011-04-09 01:37:11 +00:00
Justin Maggard
8e0fcd56f9 * Complete/clarify license information. 2010-11-11 23:48:14 +00:00
Justin Maggard
c97d359fe2 * Make Xbox360 support more generic for use with other PlaysForSure clients. 2010-08-05 23:09:11 +00:00
Justin Maggard
c4170af521 * Add a no-resize flag, which tells us to to advertise downscaled images. Useful for clients like Samsung TVs, which can use large images well, but will use downscaled small images when given a choice. 2009-11-10 00:00:09 +00:00
Justin Maggard
f7e525019a * Add SRT subtitle support using Samsung's method. 2009-10-15 00:40:27 +00:00
Justin Maggard
f259479ecf * Don't call WAV files LPCM, because they're disqualified due to endianness. 2009-08-10 21:16:53 +00:00
Justin Maggard
780ae7ad8b * Add Popcorn Hour support for using the wrong MIME type for FLAC.
* Fix a couple crash bugs with invalid UPnP-A/V SOAP requests.
* Fix WAV file extension support.
2009-07-28 23:17:31 +00:00
Justin Maggard
0d069effd9 * Fix some minor 64-bit compilation issues. 2009-07-17 22:54:31 +00:00
Justin Maggard
a6d01a85e3 * Add MIME workarounds for WAV files on Denon receivers. 2009-06-04 19:13:18 +00:00
Justin Maggard
8dc1a82d7e * Use PS3-style MIME tweaks for Samsung TVs. 2009-06-03 22:01:31 +00:00
Justin Maggard
81f9fa80a5 * Send DLNA version with our User-Agent header. 2009-05-12 01:54:28 +00:00
Justin Maggard
bdf2c86075 * Sort out Server description in HTTP headers. This actually makes Windows Media Player recognize a MiniDLNA server also. 2009-05-10 03:24:29 +00:00
Justin Maggard
401da95831 * Add generic DLNA client type detection and caching, and don't use DLNA-specific MIME types if the client doesn't support DLNA. 2009-05-01 19:36:43 +00:00
Justin Maggard
76ab570ed1 * Add client type caching code, so we can behave in a customized manner if necessary for certain clients. 2009-05-01 00:01:03 +00:00
Justin Maggard
c4ca6527f0 * Invalidate the scanner cache when an inotify deletion takes place. 2009-04-21 02:50:45 +00:00
Justin Maggard
2e3a4f1dde * Implement the QueryItem command.
* Add error handling/reporting for unknown commands.
2009-03-30 07:43:10 +00:00
Justin Maggard
2664fe0d91 * Add device icon support. 2009-03-02 19:59:07 +00:00
Justin Maggard
2da2f6d4a1 * Add some preliminary code for the eventual possibility of TiVo support. 2009-02-23 23:10:27 +00:00
Justin Maggard
0d3505656d * Fix accidental double-scan from last checkin.
* Add XBox360 compatibility.
2009-02-10 07:41:50 +00:00
Justin Maggard
8cab1a2800 * Add some conditional statements to work with more ffmpeg library versions.
* Fix a crash bug when generating a friendly name if the hostname does not contain a dot.
* Implement folder browsing by media type.
* Add initial DLNA-compliant music album art support. (Using a <=160x160 cover.jpg, or folder.jpg, etc)
2009-01-30 08:50:09 +00:00
Justin Maggard
f557f8ea77 Initial checkin 2008-10-23 17:30:45 +00:00