Merge 495634795203bf4b1b4c7b6ffbc09c071cfbd7a2 into 58c76080a0c654de906de9f554e2de45b1784929

This commit is contained in:
Wires77 2025-02-28 19:28:41 -03:00 committed by GitHub
commit 6a646f62a6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 37 additions and 0 deletions

View File

@ -93,6 +93,26 @@ int opt_get_reuseaddr(lua_State *L, p_socket ps)
return opt_getboolean(L, ps, SOL_SOCKET, SO_REUSEADDR); return opt_getboolean(L, ps, SOL_SOCKET, SO_REUSEADDR);
} }
/*------------------------------------------------------*/
/* enables reuse of local address */
int opt_set_exclusiveaddruse(lua_State* L, p_socket ps)
{
#ifndef SO_EXCLUSIVEADDRUSE
return luaL_error(L, "SO_EXCLUSIVEADDRUSE is not supported on this operating system");
#else
return opt_setboolean(L, ps, SOL_SOCKET, SO_EXCLUSIVEADDRUSE);
#endif
}
int opt_get_exclusiveaddruse(lua_State* L, p_socket ps)
{
#ifndef SO_EXCLUSIVEADDRUSE
return luaL_error(L, "SO_EXCLUSIVEADDRUSE is not supported on this operating system");
#else
return opt_getboolean(L, ps, SOL_SOCKET, SO_EXCLUSIVEADDRUSE);
#endif
}
/*------------------------------------------------------*/ /*------------------------------------------------------*/
/* enables reuse of local port */ /* enables reuse of local port */
int opt_set_reuseport(lua_State *L, p_socket ps) int opt_set_reuseport(lua_State *L, p_socket ps)

View File

@ -28,6 +28,11 @@ int opt_meth_getoption(lua_State *L, p_opt opt, p_socket ps);
int opt_set_reuseaddr(lua_State *L, p_socket ps); int opt_set_reuseaddr(lua_State *L, p_socket ps);
int opt_get_reuseaddr(lua_State *L, p_socket ps); int opt_get_reuseaddr(lua_State *L, p_socket ps);
#ifdef SO_EXCLUSIVEADDRUSE
int opt_set_exclusiveaddruse(lua_State* L, p_socket ps);
int opt_get_exclusiveaddruse(lua_State* L, p_socket ps);
#endif
int opt_set_reuseport(lua_State *L, p_socket ps); int opt_set_reuseport(lua_State *L, p_socket ps);
int opt_get_reuseport(lua_State *L, p_socket ps); int opt_get_reuseport(lua_State *L, p_socket ps);

View File

@ -74,6 +74,9 @@ static t_opt optget[] = {
{"bindtodevice", opt_get_bindtodevice}, {"bindtodevice", opt_get_bindtodevice},
{"keepalive", opt_get_keepalive}, {"keepalive", opt_get_keepalive},
{"reuseaddr", opt_get_reuseaddr}, {"reuseaddr", opt_get_reuseaddr},
#ifdef SO_EXCLUSIVEADDRUSE
{"exclusiveaddruse", opt_get_exclusiveaddruse},
#endif
{"reuseport", opt_get_reuseport}, {"reuseport", opt_get_reuseport},
{"tcp-nodelay", opt_get_tcp_nodelay}, {"tcp-nodelay", opt_get_tcp_nodelay},
#ifdef TCP_KEEPIDLE #ifdef TCP_KEEPIDLE
@ -96,6 +99,9 @@ static t_opt optset[] = {
{"bindtodevice", opt_set_bindtodevice}, {"bindtodevice", opt_set_bindtodevice},
{"keepalive", opt_set_keepalive}, {"keepalive", opt_set_keepalive},
{"reuseaddr", opt_set_reuseaddr}, {"reuseaddr", opt_set_reuseaddr},
#ifdef SO_EXCLUSIVEADDRUSE
{"exclusiveaddruse", opt_set_exclusiveaddruse},
#endif
{"reuseport", opt_set_reuseport}, {"reuseport", opt_set_reuseport},
{"tcp-nodelay", opt_set_tcp_nodelay}, {"tcp-nodelay", opt_set_tcp_nodelay},
#ifdef TCP_KEEPIDLE #ifdef TCP_KEEPIDLE

View File

@ -74,6 +74,9 @@ static t_opt optset[] = {
{"dontroute", opt_set_dontroute}, {"dontroute", opt_set_dontroute},
{"broadcast", opt_set_broadcast}, {"broadcast", opt_set_broadcast},
{"reuseaddr", opt_set_reuseaddr}, {"reuseaddr", opt_set_reuseaddr},
#ifdef SO_EXCLUSIVEADDRUSE
{"exclusiveaddruse", opt_set_exclusiveaddruse},
#endif
{"reuseport", opt_set_reuseport}, {"reuseport", opt_set_reuseport},
{"ip-multicast-if", opt_set_ip_multicast_if}, {"ip-multicast-if", opt_set_ip_multicast_if},
{"ip-multicast-ttl", opt_set_ip_multicast_ttl}, {"ip-multicast-ttl", opt_set_ip_multicast_ttl},
@ -96,6 +99,9 @@ static t_opt optget[] = {
{"dontroute", opt_get_dontroute}, {"dontroute", opt_get_dontroute},
{"broadcast", opt_get_broadcast}, {"broadcast", opt_get_broadcast},
{"reuseaddr", opt_get_reuseaddr}, {"reuseaddr", opt_get_reuseaddr},
#ifdef SO_EXCLUSIVEADDRUSE
{"exclusiveaddruse", opt_get_exclusiveaddruse},
#endif
{"reuseport", opt_get_reuseport}, {"reuseport", opt_get_reuseport},
{"ip-multicast-if", opt_get_ip_multicast_if}, {"ip-multicast-if", opt_get_ip_multicast_if},
{"ip-multicast-loop", opt_get_ip_multicast_loop}, {"ip-multicast-loop", opt_get_ip_multicast_loop},