diff options
| author | Wires77 <Wires77@users.noreply.github.com> | 2025-02-27 15:40:35 -0600 |
|---|---|---|
| committer | Caleb Maclennan <caleb@alerque.com> | 2026-08-31 10:52:00 +0300 |
| commit | b56a0c1b16f10ba6290b4decedbc424433972f46 (patch) | |
| tree | 00218f594f1d7036ae6c73bb03f952632d08f0ad | |
| parent | e13de2013749961edaa126697f3290d3dca91823 (diff) | |
| download | luasocket-b56a0c1b16f10ba6290b4decedbc424433972f46.tar.gz luasocket-b56a0c1b16f10ba6290b4decedbc424433972f46.tar.bz2 luasocket-b56a0c1b16f10ba6290b4decedbc424433972f46.zip | |
feat(core): Add option for Windows SO_EXCLUSIVEADDRUSE
| -rw-r--r-- | src/options.c | 20 | ||||
| -rw-r--r-- | src/options.h | 5 | ||||
| -rw-r--r-- | src/tcp.c | 6 | ||||
| -rw-r--r-- | src/udp.c | 6 |
4 files changed, 37 insertions, 0 deletions
diff --git a/src/options.c b/src/options.c index 9dea6bd..1c3eb1c 100644 --- a/src/options.c +++ b/src/options.c | |||
| @@ -94,6 +94,26 @@ int opt_get_reuseaddr(lua_State *L, p_socket ps) | |||
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | /*------------------------------------------------------*/ | 96 | /*------------------------------------------------------*/ |
| 97 | /* enables reuse of local address */ | ||
| 98 | int opt_set_exclusiveaddruse(lua_State* L, p_socket ps) | ||
| 99 | { | ||
| 100 | #ifndef SO_EXCLUSIVEADDRUSE | ||
| 101 | return luaL_error(L, "SO_EXCLUSIVEADDRUSE is not supported on this operating system"); | ||
| 102 | #else | ||
| 103 | return opt_setboolean(L, ps, SOL_SOCKET, SO_EXCLUSIVEADDRUSE); | ||
| 104 | #endif | ||
| 105 | } | ||
| 106 | |||
| 107 | int opt_get_exclusiveaddruse(lua_State* L, p_socket ps) | ||
| 108 | { | ||
| 109 | #ifndef SO_EXCLUSIVEADDRUSE | ||
| 110 | return luaL_error(L, "SO_EXCLUSIVEADDRUSE is not supported on this operating system"); | ||
| 111 | #else | ||
| 112 | return opt_getboolean(L, ps, SOL_SOCKET, SO_EXCLUSIVEADDRUSE); | ||
| 113 | #endif | ||
| 114 | } | ||
| 115 | |||
| 116 | /*------------------------------------------------------*/ | ||
| 97 | /* enables reuse of local port */ | 117 | /* enables reuse of local port */ |
| 98 | int opt_set_reuseport(lua_State *L, p_socket ps) | 118 | int opt_set_reuseport(lua_State *L, p_socket ps) |
| 99 | { | 119 | { |
diff --git a/src/options.h b/src/options.h index 26d6f02..6d6d7e0 100644 --- a/src/options.h +++ b/src/options.h | |||
| @@ -28,6 +28,11 @@ int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps); | |||
| 28 | int opt_set_reuseaddr(lua_State *L, p_socket ps); | 28 | int opt_set_reuseaddr(lua_State *L, p_socket ps); |
| 29 | int opt_get_reuseaddr(lua_State *L, p_socket ps); | 29 | int opt_get_reuseaddr(lua_State *L, p_socket ps); |
| 30 | 30 | ||
| 31 | #ifdef SO_EXCLUSIVEADDRUSE | ||
| 32 | int opt_set_exclusiveaddruse(lua_State* L, p_socket ps); | ||
| 33 | int opt_get_exclusiveaddruse(lua_State* L, p_socket ps); | ||
| 34 | #endif | ||
| 35 | |||
| 31 | int opt_set_reuseport(lua_State *L, p_socket ps); | 36 | int opt_set_reuseport(lua_State *L, p_socket ps); |
| 32 | int opt_get_reuseport(lua_State *L, p_socket ps); | 37 | int opt_get_reuseport(lua_State *L, p_socket ps); |
| 33 | 38 | ||
| @@ -74,6 +74,9 @@ static t_opt optget[] = { | |||
| 74 | {"bindtodevice", opt_get_bindtodevice}, | 74 | {"bindtodevice", opt_get_bindtodevice}, |
| 75 | {"keepalive", opt_get_keepalive}, | 75 | {"keepalive", opt_get_keepalive}, |
| 76 | {"reuseaddr", opt_get_reuseaddr}, | 76 | {"reuseaddr", opt_get_reuseaddr}, |
| 77 | #ifdef SO_EXCLUSIVEADDRUSE | ||
| 78 | {"exclusiveaddruse", opt_get_exclusiveaddruse}, | ||
| 79 | #endif | ||
| 77 | {"reuseport", opt_get_reuseport}, | 80 | {"reuseport", opt_get_reuseport}, |
| 78 | {"tcp-nodelay", opt_get_tcp_nodelay}, | 81 | {"tcp-nodelay", opt_get_tcp_nodelay}, |
| 79 | #ifdef TCP_KEEPIDLE | 82 | #ifdef TCP_KEEPIDLE |
| @@ -96,6 +99,9 @@ static t_opt optset[] = { | |||
| 96 | {"bindtodevice", opt_set_bindtodevice}, | 99 | {"bindtodevice", opt_set_bindtodevice}, |
| 97 | {"keepalive", opt_set_keepalive}, | 100 | {"keepalive", opt_set_keepalive}, |
| 98 | {"reuseaddr", opt_set_reuseaddr}, | 101 | {"reuseaddr", opt_set_reuseaddr}, |
| 102 | #ifdef SO_EXCLUSIVEADDRUSE | ||
| 103 | {"exclusiveaddruse", opt_set_exclusiveaddruse}, | ||
| 104 | #endif | ||
| 99 | {"reuseport", opt_set_reuseport}, | 105 | {"reuseport", opt_set_reuseport}, |
| 100 | {"tcp-nodelay", opt_set_tcp_nodelay}, | 106 | {"tcp-nodelay", opt_set_tcp_nodelay}, |
| 101 | #ifdef TCP_KEEPIDLE | 107 | #ifdef TCP_KEEPIDLE |
| @@ -74,6 +74,9 @@ static t_opt optset[] = { | |||
| 74 | {"dontroute", opt_set_dontroute}, | 74 | {"dontroute", opt_set_dontroute}, |
| 75 | {"broadcast", opt_set_broadcast}, | 75 | {"broadcast", opt_set_broadcast}, |
| 76 | {"reuseaddr", opt_set_reuseaddr}, | 76 | {"reuseaddr", opt_set_reuseaddr}, |
| 77 | #ifdef SO_EXCLUSIVEADDRUSE | ||
| 78 | {"exclusiveaddruse", opt_set_exclusiveaddruse}, | ||
| 79 | #endif | ||
| 77 | {"reuseport", opt_set_reuseport}, | 80 | {"reuseport", opt_set_reuseport}, |
| 78 | {"ip-multicast-if", opt_set_ip_multicast_if}, | 81 | {"ip-multicast-if", opt_set_ip_multicast_if}, |
| 79 | {"ip-multicast-ttl", opt_set_ip_multicast_ttl}, | 82 | {"ip-multicast-ttl", opt_set_ip_multicast_ttl}, |
| @@ -96,6 +99,9 @@ static t_opt optget[] = { | |||
| 96 | {"dontroute", opt_get_dontroute}, | 99 | {"dontroute", opt_get_dontroute}, |
| 97 | {"broadcast", opt_get_broadcast}, | 100 | {"broadcast", opt_get_broadcast}, |
| 98 | {"reuseaddr", opt_get_reuseaddr}, | 101 | {"reuseaddr", opt_get_reuseaddr}, |
| 102 | #ifdef SO_EXCLUSIVEADDRUSE | ||
| 103 | {"exclusiveaddruse", opt_get_exclusiveaddruse}, | ||
| 104 | #endif | ||
| 99 | {"reuseport", opt_get_reuseport}, | 105 | {"reuseport", opt_get_reuseport}, |
| 100 | {"ip-multicast-if", opt_get_ip_multicast_if}, | 106 | {"ip-multicast-if", opt_get_ip_multicast_if}, |
| 101 | {"ip-multicast-loop", opt_get_ip_multicast_loop}, | 107 | {"ip-multicast-loop", opt_get_ip_multicast_loop}, |
