Skip to content
Browse files

UUID: don't use MAC address seed as it breaks the use of multiple (co…

…ncurrent) profiles - thanks whickwire
  • Loading branch information...
1 parent 42359a9 commit f3da164a9e3d40ba2864b4383d7655ce1c61f6d9 @chocolateboy chocolateboy committed
Showing with 16 additions and 49 deletions.
  1. +3 −0 CHANGELOG.txt
  2. +13 −49 src/main/java/net/pms/PMS.java
View
3 CHANGELOG.txt
@@ -15,6 +15,9 @@ Changelog:
- custom FFmpeg options are now read before each transcode rather than only at startup (parity with custom MEncoder options)
- rescale videos larger than the renderer's max height/width
FFmpeg Audio: support all TranscodeAudio profiles
+ Misc:
+ - fix bug that prevents PMS running multiple profiles concurrently
+ - fix NPE for DLNA subtitle requests
1.72.0 - 2012-11-18
View
62 src/main/java/net/pms/PMS.java
@@ -37,7 +37,6 @@
import net.pms.io.*;
import net.pms.logging.LoggingConfigFileLoader;
import net.pms.network.HTTPServer;
-import net.pms.network.NetworkConfiguration;
import net.pms.network.ProxyServer;
import net.pms.network.UPNPHelper;
import net.pms.newgui.LooksFrame;
@@ -61,9 +60,6 @@
import java.io.IOException;
import java.io.PrintStream;
import java.net.BindException;
-import java.net.NetworkInterface;
-import java.net.SocketException;
-import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.Map.Entry;
@@ -90,6 +86,11 @@
// TODO(tcox): This shouldn't be static
private static PmsConfiguration configuration;
+ /**
+ * Universally Unique Identifier used in the UPnP server.
+ */
+ private String uuid;
+
/**Returns a pointer to the main PMS GUI.
* @return {@link net.pms.gui.IFrame} Main PMS window.
*/
@@ -706,59 +707,22 @@ public static void error(String msg, Throwable t) {
}
/**
- * Universally Unique Identifier used in the UPnP server.
- */
- private String uuid;
-
- /**
- * Creates a new {@link #uuid} for the UPnP server to use. Tries to follow the RFCs for creating the UUID based on the link MAC address.
- * Defaults to a random one if that method is not available.
+ * Creates a new random {@link #uuid}. These are used to uniquely identify the server to renderers (i.e.
+ * renderers treat multiple servers with the same UUID as the same server).
* @return {@link String} with an Universally Unique Identifier.
*/
+ // XXX don't use the MAC address to seed the UUID as it breaks multiple profiles:
+ // http://www.ps3mediaserver.org/forum/viewtopic.php?f=6&p=75542#p75542
public synchronized String usn() {
if (uuid == null) {
// retrieve UUID from configuration
uuid = getConfiguration().getUuid();
if (uuid == null) {
- // create a new UUID based on the MAC address of the used network adapter
- NetworkInterface ni = null;
-
- try {
- // this retrieves the network interface via:
- //
- // 1) NetworkConfiguration.getAddressForNetworkInterfaceName(pmsConfInterfaceName)
- // 2) NetworkConfiguration.getDefaultNetworkInterfaceAddress()
-
- ni = get().getServer().getNetworkInterface();
-
- // failing that, default to:
- //
- // 3) NetworkConfiguration.getNetworkInterfaceByServerName()
- if (ni == null) {
- ni = NetworkConfiguration.getInstance().getNetworkInterfaceByServerName();
- }
-
- if (ni != null) {
- byte[] addr = getRegistry().getHardwareAddress(ni); // return null when java.net.preferIPv4Stack=true
- if (addr != null) {
- uuid = UUID.nameUUIDFromBytes(addr).toString();
- LOGGER.info(String.format("Generated new UUID based on the MAC address of the network adapter '%s'", ni.getDisplayName()));
- }
- }
- } catch (SocketException e) {
- LOGGER.debug("Caught exception", e);
- } catch (UnknownHostException e) {
- LOGGER.debug("Caught exception", e);
- }
-
- // create random UUID if the generation by MAC address failed
- if (uuid == null) {
- uuid = UUID.randomUUID().toString();
- LOGGER.info("Generated new random UUID");
- }
+ uuid = UUID.randomUUID().toString();
+ LOGGER.info("Generated new random UUID: {}", uuid);
- // save the newly generated UUID
+ // save the newly-generated UUID
getConfiguration().setUuid(uuid);
try {
@@ -768,7 +732,7 @@ public synchronized String usn() {
}
}
- LOGGER.info("Using the following UUID configured in PMS.conf: " + uuid);
+ LOGGER.info("Using the following UUID configured in PMS.conf: {}", uuid);
}
return "uuid:" + uuid;

0 comments on commit f3da164

Please sign in to comment.
Something went wrong with that request. Please try again.