Skip to content

Commit

Permalink
Stop trying to store remote endpoint for Channels.
Browse files Browse the repository at this point in the history
  • Loading branch information
saurik committed Jul 21, 2024
1 parent 0cc23f1 commit cebc2be
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 7 deletions.
5 changes: 1 addition & 4 deletions lib-protocol/source/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,12 @@ Channel::Channel(BufferDrain &drain, const S<Peer> &peer, int id, const std::str
{
}

task<Socket> Channel::Wire(BufferSunk &sunk, S<Base> base, Configuration configuration, const std::function<task<std::string> (std::string)> &respond) {
task<void> Channel::Wire(BufferSunk &sunk, S<Base> base, Configuration configuration, const std::function<task<std::string> (std::string)> &respond) {
const auto client(co_await Post([&]() { return Make<Actor>(std::move(base), std::move(configuration)); }));
auto &channel(*co_await Post([&]() { return &sunk.Wire<Channel>(client); }));
const auto answer(co_await respond(Strip(co_await client->Offer())));
co_await client->Negotiate(answer);
co_await channel.Open();
const auto candidate(co_await client->Candidate());
const auto &socket(candidate.address());
co_return Socket(socket.ipaddr().ipv4_address(), socket.port());
}

void Channel::OnStateChange() noexcept {
Expand Down
2 changes: 1 addition & 1 deletion lib-protocol/source/channel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Channel :
Channel(BufferDrain &drain, const S<Peer> &peer, rtc::scoped_refptr<webrtc::DataChannelInterface> channel);
Channel(BufferDrain &drain, const S<Peer> &peer, int id = -1, const std::string &label = std::string(), const std::string &protocol = std::string());

static task<Socket> Wire(BufferSunk &sunk, S<Base> base, Configuration configuration, const std::function<task<std::string> (std::string)> &respond);
static task<void> Wire(BufferSunk &sunk, S<Base> base, Configuration configuration, const std::function<task<std::string> (std::string)> &respond);

void OnStateChange() noexcept override;
void OnBufferedAmountChange(uint64_t previous) noexcept override;
Expand Down
2 changes: 1 addition & 1 deletion vpn-shared/source/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ task<void> Client::Open(const Provider &provider, const S<Base> &base) {
auto &bonding(Bond());
auto &defragment(bonding.Wire<BufferSink<Defragment>>());

socket_ = co_await Channel::Wire(defragment, base, [&]() {
co_await Channel::Wire(defragment, base, [&]() {
Configuration configuration;
configuration.tls_ = local_;
return configuration;
Expand Down
1 change: 0 additions & 1 deletion vpn-shared/source/client.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class Client :
}; Locked<Locked_> locked_;

Nest nest_;
Socket socket_;

void Transfer(size_t size, bool send);

Expand Down

0 comments on commit cebc2be

Please sign in to comment.