Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPv6 Not Supported #275

Closed
tcm0116 opened this issue Jul 11, 2019 · 3 comments
Closed

IPv6 Not Supported #275

tcm0116 opened this issue Jul 11, 2019 · 3 comments

Comments

@tcm0116
Copy link

tcm0116 commented Jul 11, 2019

IPv6 is not supported by libjson-rpc-cpp. However, it it supported by libmicrohttpd.

The simplest way to get IPv6 working is to pass MHD_USE_DUAL_STACK in the flags to MHD_start_daemon, but this will cause MHD_start_daemon to fail if IPv6 is not supported by the system.

@cinemast
Copy link
Owner

Thanks for pointing that out. The thing is that libmicrohttpd can be configured very differently, covering all ways through the constructor is probably not a good idea. Do you have a suggestion how to deal with this?

@tcm0116
Copy link
Author

tcm0116 commented Jul 11, 2019

The only place to enable IPv6 in libmicrohttpd is in the call to MHD_start_daemon. Below are some possible changes that could be incorporated to allow use of IPv6 if supported by the system.

CMakeLists.txt:

check_c_source_compiles("
	#include <sys/types.h>
	#include <sys/socket.h>
	#include <netinet/in.h>

	int main() {
		struct sockaddr_in6 s; struct in6_addr t=in6addr_any; int i=AF_INET6; s; t.s6_addr[0] = 0;
		return 0;
	}" HAVE_IPV6)

httpserver.cpp:

 bool HttpServer::StartListening() {
   if (!this->running) {
     const bool has_epoll =
         (MHD_is_feature_supported(MHD_FEATURE_EPOLL) == MHD_YES);
     const bool has_poll =
         (MHD_is_feature_supported(MHD_FEATURE_POLL) == MHD_YES);
-    unsigned int mhd_flags;
+    unsigned int mhd_flags = 0;

+#if defined(HAVE_IPV6)
+    mhd_flags |= MHD_USE_DUAL_STACK;
+#endif

     if (has_epoll)
 // In MHD version 0.9.44 the flag is renamed to
 // MHD_USE_EPOLL_INTERNALLY_LINUX_ONLY. In later versions both
 // are deprecated.
 #if defined(MHD_USE_EPOLL_INTERNALLY)
-      mhd_flags = MHD_USE_EPOLL_INTERNALLY;
+      mhd_flags |= MHD_USE_EPOLL_INTERNALLY;
 #else
-      mhd_flags = MHD_USE_EPOLL_INTERNALLY_LINUX_ONLY;
+      mhd_flags |= MHD_USE_EPOLL_INTERNALLY_LINUX_ONLY;
 #endif
     else if (has_poll)
-      mhd_flags = MHD_USE_POLL_INTERNALLY;
+      mhd_flags |= MHD_USE_POLL_INTERNALLY;

     if (this->bindlocalhost) {

@luke026
Copy link

luke026 commented Apr 2, 2021

Can u give me url of pinoy channel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants