This commit addresses most of the issues identified in #432:
* Support UPnP IGDs with both WANIPConnection and WANPPPConnection services
IGDs that offer both WANIPConnection and WANPPPConnection services should
now have port forwarding correctly configured for all services.
* Support multiple UPnP WANDevice and WANConnection descriptions
Per Figure 1 of the InternetGatewayDevice specification
(http://upnp.org/specs/gw/UPnP-gw-InternetGatewayDevice-v1-Device.pdf),
an IGD may have multiple WAN devices, each with multiple WANConnection
services
* Support for discovery of UPnP InternetGatewayDevice version 2 devices
* Support for discovery of multiple UPnP IGDs
Consumers that cannot yet properly process multiple IGDs can simply use
the first IGD listed in the discovery results
* Logging refinements such as friendly UPnP IGD identifiers in log messages.
This commit introduces the following, cosmetic changes:
- All callers of 'ldbGenericReplace' specify a non-nil 'deleteFn' argument.
Thus, remove the checks for 'deleteFn' being nil.
- Before this change, 'ldbInsert' took a 'FileInfo' argument and a
separate argument for the file name, but all callers passed in the
value of FileInfo.Name as the file name. Simplify this, by not not
passing in the file name as a separate argument. This makes the
function signature of 'ldbInsert' more similar to 'ldbUpdate'.
- doc fixes
When extracting a folder name from the byte slices used as database
keys, bytes.IndexByte() is used to find and remove trailing 0 bytes.
In case the folder name is 64 bytes long, bytes.IndexByte() returns
-1. Before this change, syncthing crashed in this case with an
out-of-bounds slice access.
The commit fixes the problem and also introduces a test case which
checks for the presence of the bug.
- Bug fix - use .Errorf() instead of .Error():
Before this change, an error message for failed tests in files/set_test.go
wrongly tried to use format strings in a call to .Error()
- Change event constants to be of type EventType rather than untyped integers.
- Slightly relax the locking for registry cache lookups:
For read access to Discover.registry we only need to take a read lock.
- Some cosmetic fixes.