forked from premiere/premiere-libtorrent
fixed bug in UPnP and added functionality to grab router model
This commit is contained in:
parent
e38c0c9cdc
commit
1724ce5974
|
@ -77,6 +77,8 @@ public:
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
|
std::string router_model() { return m_model; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static address_v4 upnp_multicast_address;
|
static address_v4 upnp_multicast_address;
|
||||||
|
@ -233,6 +235,8 @@ private:
|
||||||
|
|
||||||
connection_queue& m_cc;
|
connection_queue& m_cc;
|
||||||
|
|
||||||
|
std::string m_model;
|
||||||
|
|
||||||
#ifdef TORRENT_UPNP_LOGGING
|
#ifdef TORRENT_UPNP_LOGGING
|
||||||
std::ofstream m_log;
|
std::ofstream m_log;
|
||||||
#endif
|
#endif
|
||||||
|
|
17
src/upnp.cpp
17
src/upnp.cpp
|
@ -578,6 +578,7 @@ namespace
|
||||||
std::string top_tag;
|
std::string top_tag;
|
||||||
std::string control_url;
|
std::string control_url;
|
||||||
char const* service_type;
|
char const* service_type;
|
||||||
|
std::string model;
|
||||||
};
|
};
|
||||||
|
|
||||||
void find_control_url(int type, char const* string, parse_state& state)
|
void find_control_url(int type, char const* string, parse_state& state)
|
||||||
|
@ -591,6 +592,10 @@ namespace
|
||||||
{
|
{
|
||||||
state.top_tag = string;
|
state.top_tag = string;
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(string, "modelName"))
|
||||||
|
{
|
||||||
|
state.top_tag = string;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (type == xml_end_tag)
|
else if (type == xml_end_tag)
|
||||||
{
|
{
|
||||||
|
@ -614,6 +619,10 @@ namespace
|
||||||
state.control_url = string;
|
state.control_url = string;
|
||||||
if (state.found_service) state.exit = true;
|
if (state.found_service) state.exit = true;
|
||||||
}
|
}
|
||||||
|
else if (state.top_tag == "modelName")
|
||||||
|
{
|
||||||
|
state.model = string;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -663,10 +672,11 @@ void upnp::on_upnp_xml(asio::error_code const& e
|
||||||
parse_state s;
|
parse_state s;
|
||||||
s.reset("urn:schemas-upnp-org:service:WANIPConnection:1");
|
s.reset("urn:schemas-upnp-org:service:WANIPConnection:1");
|
||||||
xml_parse((char*)p.get_body().begin, (char*)p.get_body().end
|
xml_parse((char*)p.get_body().begin, (char*)p.get_body().end
|
||||||
, m_strand.wrap(bind(&find_control_url, _1, _2, boost::ref(s))));
|
, bind(&find_control_url, _1, _2, boost::ref(s)));
|
||||||
if (s.found_service)
|
if (s.found_service)
|
||||||
{
|
{
|
||||||
d.service_namespace = s.service_type;
|
d.service_namespace = s.service_type;
|
||||||
|
if (!s.model.empty()) m_model = s.model;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -674,10 +684,11 @@ void upnp::on_upnp_xml(asio::error_code const& e
|
||||||
// a PPP connection
|
// a PPP connection
|
||||||
s.reset("urn:schemas-upnp-org:service:WANPPPConnection:1");
|
s.reset("urn:schemas-upnp-org:service:WANPPPConnection:1");
|
||||||
xml_parse((char*)p.get_body().begin, (char*)p.get_body().end
|
xml_parse((char*)p.get_body().begin, (char*)p.get_body().end
|
||||||
, m_strand.wrap(bind(&find_control_url, _1, _2, boost::ref(s))));
|
, bind(&find_control_url, _1, _2, boost::ref(s)));
|
||||||
if (s.found_service)
|
if (s.found_service)
|
||||||
{
|
{
|
||||||
d.service_namespace = s.service_type;
|
d.service_namespace = s.service_type;
|
||||||
|
if (!s.model.empty()) m_model = s.model;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -821,7 +832,7 @@ void upnp::on_upnp_map_response(asio::error_code const& e
|
||||||
|
|
||||||
error_code_parse_state s;
|
error_code_parse_state s;
|
||||||
xml_parse((char*)p.get_body().begin, (char*)p.get_body().end
|
xml_parse((char*)p.get_body().begin, (char*)p.get_body().end
|
||||||
, m_strand.wrap(bind(&find_error_code, _1, _2, boost::ref(s))));
|
, bind(&find_error_code, _1, _2, boost::ref(s)));
|
||||||
|
|
||||||
#ifdef TORRENT_UPNP_LOGGING
|
#ifdef TORRENT_UPNP_LOGGING
|
||||||
if (s.error_code != -1)
|
if (s.error_code != -1)
|
||||||
|
|
Loading…
Reference in New Issue