请问uTP的优化有什么进展吗?
之前测试版的帖子提到uTP打洞需要对PEX来源peer的端口进行替换操作
libtorrent中有实现
{
// don't write too big of a package
if (num_added >= max_peer_entries) break;
// only send proper bittorrent peers
if (peer->type() != connection_type::bittorrent)
continue;
auto const* const p = static_cast<bt_peer_connection const*>(peer);
// if the peer has told us which port its listening on,
// use that port. But only if we didn't connect to the peer.
// if we connected to it, use the port we know works
if (!p->is_outgoing())
{
torrent_peer const* const pi = peer->peer_info_struct();
if (pi != nullptr && pi->port > 0)
remote.port(pi->port);
}
// no supported flags to set yet
另外在阅读DHT协议时发现,2013年3月22日的修订中新增了可选参数"implied_port"
There is an optional argument called implied_port which value is either 0 or 1. If it is present and non-zero, the port argument should be ignored and the source port of the UDP packet should be used as the peer’s port instead. This is useful for peers behind a NAT that may not know their external port, and supporting uTP, they accept incoming connections on the same port as the DHT port.
libtorrent同样有相关的实现
o->m_in_constructor = false;
#endif
entry e;
e["y"] = "q";
e["q"] = "announce_peer";
entry& a = e["a"];
a["info_hash"] = ih;
a["port"] = listen_port;
a["token"] = p.second;
a["seed"] = (flags & announce::seed) ? 1 : 0;
if (flags & announce::implied_port) a["implied_port"] = 1;
node.stats_counters().inc_stats_counter(counters::dht_announce_peer_out);
node.m_rpc.invoke(e, p.first.ep(), o);
}
}
}
void node::add_router_node(udp::endpoint const& router)
{
#ifndef TORRENT_DISABLE_LOGGING
if (m_observer != nullptr && m_observer->should_log(dht_logger::node))
不知BC是否支持?