You've already forked lidgren-network-gen3
mirror of
https://github.com/lidgren/lidgren-network-gen3.git
synced 2026-05-17 23:56:30 +09:00
Don't try to parse packets identified as UPnP responses even when UPnP response parsing fails
This commit is contained in:
@@ -458,21 +458,27 @@ namespace Lidgren.Network
|
|||||||
|
|
||||||
IPEndPoint ipsender = (IPEndPoint)m_senderRemote;
|
IPEndPoint ipsender = (IPEndPoint)m_senderRemote;
|
||||||
|
|
||||||
if (m_upnp != null && now < m_upnp.m_discoveryResponseDeadline)
|
if (m_upnp != null && now < m_upnp.m_discoveryResponseDeadline && bytesReceived > 32)
|
||||||
{
|
{
|
||||||
// is this an UPnP response?
|
// is this an UPnP response?
|
||||||
try
|
string resp = System.Text.Encoding.ASCII.GetString(m_receiveBuffer, 0, bytesReceived);
|
||||||
|
if (resp.Contains("upnp:rootdevice") || resp.Contains("UPnP/1.0"))
|
||||||
{
|
{
|
||||||
string resp = System.Text.Encoding.ASCII.GetString(m_receiveBuffer, 0, bytesReceived);
|
try
|
||||||
if (resp.Contains("upnp:rootdevice") || resp.Contains("UPnP/1.0"))
|
|
||||||
{
|
{
|
||||||
resp = resp.Substring(resp.ToLower().IndexOf("location:") + 9);
|
resp = resp.Substring(resp.ToLower().IndexOf("location:") + 9);
|
||||||
resp = resp.Substring(0, resp.IndexOf("\r")).Trim();
|
resp = resp.Substring(0, resp.IndexOf("\r")).Trim();
|
||||||
m_upnp.ExtractServiceUrl(resp);
|
m_upnp.ExtractServiceUrl(resp);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogDebug("Failed to parse UPnP response: " + ex.ToString());
|
||||||
|
|
||||||
|
// don't try to parse this packet further
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch { }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NetConnection sender = null;
|
NetConnection sender = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user