mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-07 16:01:30 +00:00
Address https://github.com/cesanta/mongoose/discussions/2305 - bind to v6 only / v6 and v4
This commit is contained in:
1 parent
33ab44430c
commit
00d475bc7e
4 files changed
+12
-2
No files matched your search
+2
-1
@@ -6062,7 +6062,8 @@ bool mg_open_listener(struct mg_connection *c, const char *url) {
|
|||||||
// won't work! (setsockopt will return EINVAL)
|
// won't work! (setsockopt will return EINVAL)
|
||||||
MG_ERROR(("setsockopt(SO_REUSEADDR): %d", MG_SOCK_ERR(rc)));
|
MG_ERROR(("setsockopt(SO_REUSEADDR): %d", MG_SOCK_ERR(rc)));
|
||||||
#endif
|
#endif
|
||||||
#if defined(IPV6_V6ONLY)
|
#if MG_IPV6_V6ONLY
|
||||||
|
// Bind only to the V6 address, not V4 address on this port
|
||||||
} else if (c->loc.is_ip6 &&
|
} else if (c->loc.is_ip6 &&
|
||||||
(rc = setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &on,
|
(rc = setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &on,
|
||||||
sizeof(on))) != 0) {
|
sizeof(on))) != 0) {
|
||||||
|
|||||||
@@ -709,6 +709,10 @@ struct timeval {
|
|||||||
#define MG_ENABLE_IPV6 0
|
#define MG_ENABLE_IPV6 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MG_IPV6_V6ONLY
|
||||||
|
#define MG_IPV6_V6ONLY 0 // IPv6 socket binds only to V6, not V4 address
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MG_ENABLE_MD5
|
#ifndef MG_ENABLE_MD5
|
||||||
#define MG_ENABLE_MD5 1
|
#define MG_ENABLE_MD5 1
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -44,6 +44,10 @@
|
|||||||
#define MG_ENABLE_IPV6 0
|
#define MG_ENABLE_IPV6 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef MG_IPV6_V6ONLY
|
||||||
|
#define MG_IPV6_V6ONLY 0 // IPv6 socket binds only to V6, not V4 address
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef MG_ENABLE_MD5
|
#ifndef MG_ENABLE_MD5
|
||||||
#define MG_ENABLE_MD5 1
|
#define MG_ENABLE_MD5 1
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+2
-1
@@ -212,7 +212,8 @@ bool mg_open_listener(struct mg_connection *c, const char *url) {
|
|||||||
// won't work! (setsockopt will return EINVAL)
|
// won't work! (setsockopt will return EINVAL)
|
||||||
MG_ERROR(("setsockopt(SO_REUSEADDR): %d", MG_SOCK_ERR(rc)));
|
MG_ERROR(("setsockopt(SO_REUSEADDR): %d", MG_SOCK_ERR(rc)));
|
||||||
#endif
|
#endif
|
||||||
#if defined(IPV6_V6ONLY)
|
#if MG_IPV6_V6ONLY
|
||||||
|
// Bind only to the V6 address, not V4 address on this port
|
||||||
} else if (c->loc.is_ip6 &&
|
} else if (c->loc.is_ip6 &&
|
||||||
(rc = setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &on,
|
(rc = setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &on,
|
||||||
sizeof(on))) != 0) {
|
sizeof(on))) != 0) {
|
||||||
|
|||||||
Reference in new issue
Block a user