Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix for vector sender; path methods #130

Merged
merged 1 commit into from
May 27, 2024
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
15 changes: 14 additions & 1 deletion include/oxen/quic/address.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ namespace oxen::quic
return r <=> 0;
return oxenc::big_to_host(a.sin_port) <=> oxenc::big_to_host(b.sin_port);
}

if (is_ipv6() && other.is_ipv6())
{
auto& a = in6();
Expand All @@ -258,7 +259,6 @@ namespace oxen::quic
}

bool operator==(const Address& other) const { return (*this <=> other) == 0; }
bool operator!=(const Address& other) const { return !(*this == other); }

// Returns the size of the sockaddr
socklen_t socklen() const { return _addr.addrlen; }
Expand Down Expand Up @@ -340,6 +340,8 @@ namespace oxen::quic
return *this;
}

bool operator==(const Path& other) const { return std::tie(local, remote) == std::tie(other.local, other.remote); }
dr7ana marked this conversation as resolved.
Show resolved Hide resolved

// template code to pass Path as ngtcp2_path into ngtcp2 functions
template <typename T>
requires std::same_as<T, ngtcp2_path>
Expand Down Expand Up @@ -390,4 +392,15 @@ namespace std
return h;
}
};

template <>
struct hash<oxen::quic::Path>
{
size_t operator()(const oxen::quic::Path& addr) const
{
auto h = hash<oxen::quic::Address>{}(addr.local);
h ^= hash<oxen::quic::Address>{}(addr.remote) + inverse_golden_ratio + (h << 6) + (h >> 2);
return h;
}
};
} // namespace std
6 changes: 3 additions & 3 deletions include/oxen/quic/connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ namespace oxen::quic
template <oxenc::basic_char Char>
void send_datagram(std::vector<Char>&& buf)
{
send_datagram(
std::basic_string_view<Char>{buf.data(), buf.size()},
std::make_shared<std::vector<Char>>(std::move(buf)));
auto keep_alive = std::make_shared<std::vector<Char>>(std::move(buf));
std::basic_string_view<Char> view{keep_alive->data(), keep_alive->size()};
send_datagram(view, std::move(keep_alive));
dr7ana marked this conversation as resolved.
Show resolved Hide resolved
}

template <oxenc::basic_char CharType>
Expand Down