* UPnP:
- Fix up port handling, add some logging on bind fails - Force IPv4 only for binds
This commit is contained in:
@ -48,6 +48,9 @@ public class UPnPManager {
|
|||||||
_context = context;
|
_context = context;
|
||||||
_manager = manager;
|
_manager = manager;
|
||||||
_log = _context.logManager().getLog(UPnPManager.class);
|
_log = _context.logManager().getLog(UPnPManager.class);
|
||||||
|
// UPnP wants to bind to IPv6 link local interfaces by default, but what UPnP router
|
||||||
|
// is going to want to talk IPv6 anyway? Just make it easy and force IPv4 only
|
||||||
|
org.cybergarage.upnp.UPnP.setEnable(org.cybergarage.upnp.UPnP.USE_ONLY_IPV4_ADDR);
|
||||||
_upnp = new UPnP(context);
|
_upnp = new UPnP(context);
|
||||||
_upnp.setHTTPPort(_context.getProperty(PROP_HTTP_PORT, DEFAULT_HTTP_PORT));
|
_upnp.setHTTPPort(_context.getProperty(PROP_HTTP_PORT, DEFAULT_HTTP_PORT));
|
||||||
_upnp.setSSDPPort(_context.getProperty(PROP_SSDP_PORT, DEFAULT_SSDP_PORT));
|
_upnp.setSSDPPort(_context.getProperty(PROP_SSDP_PORT, DEFAULT_SSDP_PORT));
|
||||||
@ -150,7 +153,7 @@ public class UPnPManager {
|
|||||||
|
|
||||||
public String renderStatusHTML() {
|
public String renderStatusHTML() {
|
||||||
if (!_isRunning)
|
if (!_isRunning)
|
||||||
return "<a name=\"upnp\"><<b>UPnP is not enabled</b>\n";
|
return "<a name=\"upnp\"><b>UPnP is not enabled</b>\n";
|
||||||
return _upnp.renderStatusHTML();
|
return _upnp.renderStatusHTML();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,7 @@ public class HTTPServer implements Runnable
|
|||||||
serverSock.setSoTimeout(10*1000);
|
serverSock.setSoTimeout(10*1000);
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
|
Debug.warning("HTTP server open failed " + addr + " " + port, e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -786,9 +786,13 @@ public class ControlPoint implements HTTPRequestListener
|
|||||||
HTTPServerList httpServerList = getHTTPServerList();
|
HTTPServerList httpServerList = getHTTPServerList();
|
||||||
while (httpServerList.open(bindPort) == false) {
|
while (httpServerList.open(bindPort) == false) {
|
||||||
retryCnt++;
|
retryCnt++;
|
||||||
if (UPnP.SERVER_RETRY_COUNT < retryCnt)
|
if (UPnP.SERVER_RETRY_COUNT < retryCnt) {
|
||||||
|
Debug.warning("Failed to open HTTP event listener port " + bindPort);
|
||||||
|
// I2P do we really need this, or can we just break ?
|
||||||
return false;
|
return false;
|
||||||
setHTTPPort(bindPort + 1);
|
}
|
||||||
|
// I2P go down not up so we don't run into other I2P things
|
||||||
|
setHTTPPort(bindPort - 1);
|
||||||
bindPort = getHTTPPort();
|
bindPort = getHTTPPort();
|
||||||
}
|
}
|
||||||
httpServerList.addRequestListener(this);
|
httpServerList.addRequestListener(this);
|
||||||
@ -799,8 +803,10 @@ public class ControlPoint implements HTTPRequestListener
|
|||||||
////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
|
|
||||||
SSDPNotifySocketList ssdpNotifySocketList = getSSDPNotifySocketList();
|
SSDPNotifySocketList ssdpNotifySocketList = getSSDPNotifySocketList();
|
||||||
if (ssdpNotifySocketList.open() == false)
|
if (ssdpNotifySocketList.open() == false) {
|
||||||
|
Debug.warning("Failed to open SSDP notify port 1900");
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
ssdpNotifySocketList.setControlPoint(this);
|
ssdpNotifySocketList.setControlPoint(this);
|
||||||
ssdpNotifySocketList.start();
|
ssdpNotifySocketList.start();
|
||||||
|
|
||||||
@ -813,9 +819,12 @@ public class ControlPoint implements HTTPRequestListener
|
|||||||
SSDPSearchResponseSocketList ssdpSearchResponseSocketList = getSSDPSearchResponseSocketList();
|
SSDPSearchResponseSocketList ssdpSearchResponseSocketList = getSSDPSearchResponseSocketList();
|
||||||
while (ssdpSearchResponseSocketList.open(ssdpPort) == false) {
|
while (ssdpSearchResponseSocketList.open(ssdpPort) == false) {
|
||||||
retryCnt++;
|
retryCnt++;
|
||||||
if (UPnP.SERVER_RETRY_COUNT < retryCnt)
|
if (UPnP.SERVER_RETRY_COUNT < retryCnt) {
|
||||||
|
Debug.warning("Failed to open SSDP search response port " + ssdpPort);
|
||||||
return false;
|
return false;
|
||||||
setSSDPPort(ssdpPort + 1);
|
}
|
||||||
|
// I2P go down not up so we don't run into other I2P things
|
||||||
|
setSSDPPort(ssdpPort - 1);
|
||||||
ssdpPort = getSSDPPort();
|
ssdpPort = getSSDPPort();
|
||||||
}
|
}
|
||||||
ssdpSearchResponseSocketList.setControlPoint(this);
|
ssdpSearchResponseSocketList.setControlPoint(this);
|
||||||
|
@ -37,7 +37,8 @@ public class UPnP
|
|||||||
public final static String NAME = "CyberLink";
|
public final static String NAME = "CyberLink";
|
||||||
public final static String VERSION = "1.7";
|
public final static String VERSION = "1.7";
|
||||||
|
|
||||||
public final static int SERVER_RETRY_COUNT = 100;
|
// I2P was 100
|
||||||
|
public final static int SERVER_RETRY_COUNT = 4;
|
||||||
public final static int DEFAULT_EXPIRED_DEVICE_EXTRA_TIME = 60;
|
public final static int DEFAULT_EXPIRED_DEVICE_EXTRA_TIME = 60;
|
||||||
|
|
||||||
public final static String getServerName()
|
public final static String getServerName()
|
||||||
|
Reference in New Issue
Block a user