Skip to content

Commit

Permalink
Support IPv6 in snapserver
Browse files Browse the repository at this point in the history
  • Loading branch information
miek authored and badaix committed Sep 26, 2017
1 parent b58ecfd commit 5f06f70
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion server/controlServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,14 @@ void ControlServer::handleAccept(socket_ptr socket)

void ControlServer::start()
{
acceptor_ = make_shared<tcp::acceptor>(*io_service_, tcp::endpoint(tcp::v4(), port_));
asio::ip::address address = asio::ip::address::from_string("::");
tcp::endpoint endpoint(address, port_);
acceptor_ = make_shared<tcp::acceptor>(*io_service_, endpoint);
if (endpoint.protocol() == tcp::v6())
{
error_code ec;
acceptor_->set_option(asio::ip::v6_only(false), ec);
}
startAccept();
}

Expand Down
9 changes: 8 additions & 1 deletion server/streamServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,14 @@ void StreamServer::start()
}
streamManager_->start();

acceptor_ = make_shared<tcp::acceptor>(*io_service_, tcp::endpoint(tcp::v4(), settings_.port));
asio::ip::address address = asio::ip::address::from_string("::");
tcp::endpoint endpoint(address, settings_.port);
acceptor_ = make_shared<tcp::acceptor>(*io_service_, endpoint);
if (endpoint.protocol() == tcp::v6())
{
error_code ec;
acceptor_->set_option(asio::ip::v6_only(false), ec);
}
startAccept();
}
catch (const std::exception& e)
Expand Down

0 comments on commit 5f06f70

Please sign in to comment.