Skip to content

Commit

Permalink
Two changes:
Browse files Browse the repository at this point in the history
Fix a bug of ipv4_only connections

Port to DragonflyBSD
  • Loading branch information
cnbatch committed Apr 25, 2023
1 parent 5384a6f commit 34896d6
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)

set_property(GLOBAL PROPERTY USE_FOLDERS ON)

if(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
if(${CMAKE_SYSTEM_NAME} MATCHES "^DragonFly?" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD" OR ${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD")
include_directories("/usr/local/include")
include_directories("/usr/local/include/botan-2")
endif()
Expand Down
5 changes: 2 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ int main(int argc, char *argv[])
if (argc <= 1)
{
char app_name[] = "punchnat";
printf("%s version 20230423\n", app_name);
printf("%s version 20230426\n", app_name);
printf("Usage: %s config1.conf\n", app_name);
printf(" %s config1.conf config2.conf...\n", app_name);
return 0;
Expand Down Expand Up @@ -54,7 +54,7 @@ int main(int argc, char *argv[])
tcp_sessions.emplace_back(tcp_mode(ioc, settings));
}

std::cout << "error_found: " << (error_found ? "Yes" : "No") << "\n";
std::cout << "Error Found in Configuration File(s): " << (error_found ? "Yes" : "No") << "\n";
std::cout << "TCP: " << tcp_sessions.size() << "\n";
std::cout << "UDP: " << udp_sessions.size() << "\n";

Expand All @@ -74,6 +74,5 @@ int main(int argc, char *argv[])
network_io.run();
}

printf("bye\n");
return 0;
}
12 changes: 9 additions & 3 deletions src/networks/connections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,16 @@ int64_t udp_client::time_gap_of_send()

void udp_client::initialise()
{
asio::ip::v6_only v6_option(false);
connection_socket.open(udp::v6());
if (!ipv4_only)
if (ipv4_only)
{
connection_socket.open(udp::v4());
}
else
{
asio::ip::v6_only v6_option(false);
connection_socket.open(udp::v6());
connection_socket.set_option(v6_option);
}
}

void udp_client::start_receive()
Expand Down
1 change: 1 addition & 0 deletions src/shares/share_defines.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <climits>
#include <iomanip>
#include <limits>
#include <stdexcept>
#include <cstdlib>
Expand Down

0 comments on commit 34896d6

Please sign in to comment.