Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/channels/channel_peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ bool channel_peer::is_handshaked() const NOEXCEPT
return !is_null(peer_version_);
}

// peer_version_->user_agent is not sanitized here.
version::cptr channel_peer::peer_version() const NOEXCEPT
{
// peer_version_ defaults to nullptr, which implies not handshaked.
Expand Down
2 changes: 1 addition & 1 deletion src/net/proxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ void proxy::do_write(const asio::const_buffer& payload,
}

const auto started = !queue_.empty();
queue_.push_back(std::make_pair(payload, std::move(handler)));
queue_.push_back(std::make_pair(payload, handler));
total_ = ceilinged_add(total_.load(), payload.size());
backlog_ = ceilinged_add(backlog_.load(), payload.size());

Expand Down
23 changes: 18 additions & 5 deletions src/protocols/protocol_version_106.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,17 @@ minutes protocol_version_106::to_deviation(uint64_t timestamp) NOEXCEPT
return std::chrono::duration_cast<minutes>(time - now);
}

static std::string escape_user_agent(const std::string& in) NOEXCEPT
{
std::string out(in.size(), '*');
std::transform(in.begin(), in.end(), out.begin(), [](char c) NOEXCEPT
{
return is_ascii_character(c) && !is_ascii_whitespace(c) ? c : '*';
});

return out;
}

bool protocol_version_106::handle_receive_version(const code& ec,
const version::cptr& message) NOEXCEPT
{
Expand All @@ -300,12 +311,14 @@ bool protocol_version_106::handle_receive_version(const code& ec,
return false;
}

const auto user_agent = escape_user_agent(message->user_agent);

// Filter out user agent spam.
auto user_agent = system::replace_copy(message->user_agent,
"(not-your-file-server)/Knots:", "/Sybil:");
system::replace(user_agent, "(FutureBit-Apollo-Node)", "/FutureBit");
system::replace(user_agent, "/Satoshi-BTF(BitcoinFinance)-Main-vSeventeen:",
"/BitcoinFinance:");
////user_agent = system::replace_copy(user_agent,
//// "(not-your-file-server)/Knots:", "/Sybil:");
////system::replace(user_agent, "(FutureBit-Apollo-Node)", "/FutureBit");
////system::replace(user_agent, "/Satoshi-BTF(BitcoinFinance)-Main-vSeventeen:",
//// "/BitcoinFinance:");

LOG_ONLY(const auto prefix = (inbound_ ? "Inbound" : "Outbound");)
LOGN(prefix << " [" << opposite() << "] version (" << message->value
Expand Down
Loading