Skip to content

Commit 8aebc31

Browse files
committedFeb 15, 2015
Fix unit test if there isn't a localhost address (for example FreeBSD jails), second part
1 parent a3e2b3e commit 8aebc31

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed
 

‎src/test.cpp

+21-2
Original file line numberDiff line numberDiff line change
@@ -1865,9 +1865,24 @@ struct TestConnection: public TestBase
18651865
Handler hand_server("server");
18661866
Handler hand_client("client");
18671867

1868+
Address address(0, 0, 0, 0, 30001);
1869+
Address bind_addr(0, 0, 0, 0, 30001);
1870+
/*
1871+
* Try to use the bind_address for servers with no localhost address
1872+
* For example: FreeBSD jails
1873+
*/
1874+
std::string bind_str = g_settings->get("bind_address");
1875+
try {
1876+
bind_addr.Resolve(bind_str.c_str());
1877+
1878+
if (!bind_addr.isIPv6()) {
1879+
address = bind_addr;
1880+
}
1881+
} catch (ResolveError &e) {
1882+
}
1883+
18681884
infostream<<"** Creating server Connection"<<std::endl;
18691885
con::Connection server(proto_id, 512, 5.0, false, &hand_server);
1870-
Address address(0,0,0,0, 30001);
18711886
server.Serve(address);
18721887

18731888
infostream<<"** Creating client Connection"<<std::endl;
@@ -1878,7 +1893,11 @@ struct TestConnection: public TestBase
18781893

18791894
sleep_ms(50);
18801895

1881-
Address server_address(127,0,0,1, 30001);
1896+
Address server_address(127, 0, 0, 1, 30001);
1897+
if (address != Address(0, 0, 0, 0, 30001)) {
1898+
server_address = bind_addr;
1899+
}
1900+
18821901
infostream<<"** running client.Connect()"<<std::endl;
18831902
client.Connect(server_address);
18841903

0 commit comments

Comments
 (0)
Please sign in to comment.