Skip to content

Commit

Permalink
make it possible to listen on a domain name
Browse files Browse the repository at this point in the history
  • Loading branch information
GreaterFire committed Apr 11, 2019
1 parent b047d15 commit 32b48d0
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@ Service::Service(Config &config, bool test) :
auth(nullptr),
udp_socket(io_service) {
if (!test) {
auto listen_endpoint = tcp::endpoint(address::from_string(config.local_addr), config.local_port);
tcp::resolver resolver(io_service);
tcp::endpoint listen_endpoint = *resolver.resolve(tcp::resolver::query(config.local_addr, to_string(config.local_port)));
socket_acceptor.open(listen_endpoint.protocol());
socket_acceptor.set_option(tcp::acceptor::reuse_address(true));
socket_acceptor.bind(listen_endpoint);
socket_acceptor.listen();
if (config.run_type == Config::FORWARD) {
auto udp_bind_endpoint = udp::endpoint(address::from_string(config.local_addr), config.local_port);
auto udp_bind_endpoint = udp::endpoint(listen_endpoint.address(), listen_endpoint.port());
udp_socket.open(udp_bind_endpoint.protocol());
udp_socket.bind(udp_bind_endpoint);
}
Expand Down

0 comments on commit 32b48d0

Please sign in to comment.