mirror of
https://github.com/lunarmodules/luasocket.git
synced 2025-07-13 14:14:30 +02:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
95b7efa9da | |||
80503077db | |||
5a7e3f0888 | |||
d1ad8160cb | |||
0c7df119c2 | |||
cff09ffb32 | |||
38c7b5161b | |||
1d61853ab8 |
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@ -8,11 +8,11 @@ on:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Test build on Linux
|
||||
name: Test build on ${{ matrix.platform }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
luaVersion: [ "5.4", "5.3", "5.2", "5.1", "luajit", "luajit-openresty"]
|
||||
luaVersion: [ "5.4", "5.3", "5.2", "5.1", "luajit", "luajit-openresty" ]
|
||||
platform: [ "ubuntu-20.04", "macos-11" ] # "windows-2022" not supported by gh-actions-lua
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
|
@ -1,5 +1,12 @@
|
||||
# Changelog
|
||||
|
||||
## [v3.1.0](https://github.com/lunarmodules/luasocket/releases/v3.1.0) — 2022-07-27
|
||||
|
||||
* Add support for TCP Defer Accept – @Zash
|
||||
* Add support for TCP Fast Open – @Zash
|
||||
* Fix Windows (mingw32) builds – @goldenstein64
|
||||
* Avoid build warnings on 64-bit Windows – @rpatters1
|
||||
|
||||
## [v3.0.0](https://github.com/lunarmodules/luasocket/releases/v3.0.0) — 2022-03-25
|
||||
|
||||
The last time LuaSocket had a stable release tag was 14 years ago when 2.0.2 was tagged.
|
||||
|
@ -87,7 +87,7 @@ Author: <a href="http://www.impa.br/~diego">Diego Nehab</a>
|
||||
<h2 id="download">Download</h2>
|
||||
|
||||
<p>
|
||||
LuaSocket version 3.0.0 is now available for download!
|
||||
LuaSocket version 3.1.0 is now available for download!
|
||||
It is compatible with Lua 5.1 through 5.4.
|
||||
Chances are it works well on most UNIX distributions and Windows flavors.
|
||||
</p>
|
||||
|
@ -89,7 +89,7 @@ it should be easy to use LuaSocket. Just fire the interpreter and use the
|
||||
Lua 5.2.2 Copyright (C) 1994-2013 Lua.org, PUC-Rio
|
||||
> socket = require("socket")
|
||||
> print(socket._VERSION)
|
||||
--> LuaSocket 3.0-rc1
|
||||
--> LuaSocket 3.0.0
|
||||
</pre>
|
||||
|
||||
<p> Each module loads their dependencies automatically, so you only need to
|
||||
|
@ -485,6 +485,12 @@ disables the Nagle's algorithm for the connection;</li>
|
||||
|
||||
<li> '<tt>tcp-keepintvl</tt>': value for <tt>TCP_KEEPINTVL</tt> Linux only!!</li>
|
||||
|
||||
<li> '<tt>tcp-defer-accept</tt>': value for <tt>TCP_DEFER_ACCEPT</tt> Linux only!!</li>
|
||||
|
||||
<li> '<tt>tcp-fastopen</tt>': value for <tt>TCP_FASTOPEN</tt> Linux only!!</li>
|
||||
|
||||
<li> '<tt>tcp-fastopen-connect</tt>': value for <tt>TCP_FASTOPEN_CONNECT</tt> Linux only!!</li>
|
||||
|
||||
<li> '<tt>ipv6-v6only</tt>':
|
||||
Setting this option to <tt>true</tt> restricts an <tt>inet6</tt> socket to
|
||||
sending and receiving only IPv6 packets.</li>
|
||||
|
@ -34,7 +34,7 @@ local function make_plat(plat)
|
||||
},
|
||||
mingw32 = {
|
||||
"LUASOCKET_DEBUG",
|
||||
"LUASOCKET_INET_PTON",
|
||||
-- "LUASOCKET_INET_PTON",
|
||||
"WINVER=0x0501"
|
||||
}
|
||||
}
|
||||
@ -113,6 +113,7 @@ local function make_plat(plat)
|
||||
then
|
||||
modules["socket.core"].sources[#modules["socket.core"].sources+1] = "src/wsocket.c"
|
||||
modules["socket.core"].libraries = { "ws2_32" }
|
||||
modules["socket.core"].libdirs = {}
|
||||
end
|
||||
return { modules = modules }
|
||||
end
|
||||
|
@ -1,7 +1,7 @@
|
||||
#--------------------------------------------------------------------------
|
||||
# Distribution makefile
|
||||
#--------------------------------------------------------------------------
|
||||
DIST = luasocket-3.0-rc1
|
||||
DIST = luasocket-3.0.0
|
||||
|
||||
TEST = \
|
||||
test/README \
|
||||
|
135
rockspecs/luasocket-3.1.0-1.rockspec
Normal file
135
rockspecs/luasocket-3.1.0-1.rockspec
Normal file
@ -0,0 +1,135 @@
|
||||
package = "LuaSocket"
|
||||
version = "3.1.0-1"
|
||||
source = {
|
||||
url = "git+https://github.com/lunarmodules/luasocket.git",
|
||||
tag = "v3.1.0"
|
||||
}
|
||||
description = {
|
||||
summary = "Network support for the Lua language",
|
||||
detailed = [[
|
||||
LuaSocket is a Lua extension library composed of two parts: a set of C
|
||||
modules that provide support for the TCP and UDP transport layers, and a
|
||||
set of Lua modules that provide functions commonly needed by applications
|
||||
that deal with the Internet.
|
||||
]],
|
||||
homepage = "https://github.com/lunarmodules/luasocket",
|
||||
license = "MIT"
|
||||
}
|
||||
dependencies = {
|
||||
"lua >= 5.1"
|
||||
}
|
||||
|
||||
local function make_plat(plat)
|
||||
local defines = {
|
||||
unix = {
|
||||
"LUASOCKET_DEBUG"
|
||||
},
|
||||
macosx = {
|
||||
"LUASOCKET_DEBUG",
|
||||
"UNIX_HAS_SUN_LEN"
|
||||
},
|
||||
win32 = {
|
||||
"LUASOCKET_DEBUG",
|
||||
"NDEBUG"
|
||||
},
|
||||
mingw32 = {
|
||||
"LUASOCKET_DEBUG",
|
||||
-- "LUASOCKET_INET_PTON",
|
||||
"WINVER=0x0501"
|
||||
}
|
||||
}
|
||||
local modules = {
|
||||
["socket.core"] = {
|
||||
sources = {
|
||||
"src/luasocket.c"
|
||||
, "src/timeout.c"
|
||||
, "src/buffer.c"
|
||||
, "src/io.c"
|
||||
, "src/auxiliar.c"
|
||||
, "src/options.c"
|
||||
, "src/inet.c"
|
||||
, "src/except.c"
|
||||
, "src/select.c"
|
||||
, "src/tcp.c"
|
||||
, "src/udp.c"
|
||||
, "src/compat.c" },
|
||||
defines = defines[plat],
|
||||
incdir = "/src"
|
||||
},
|
||||
["mime.core"] = {
|
||||
sources = { "src/mime.c", "src/compat.c" },
|
||||
defines = defines[plat],
|
||||
incdir = "/src"
|
||||
},
|
||||
["socket.http"] = "src/http.lua",
|
||||
["socket.url"] = "src/url.lua",
|
||||
["socket.tp"] = "src/tp.lua",
|
||||
["socket.ftp"] = "src/ftp.lua",
|
||||
["socket.headers"] = "src/headers.lua",
|
||||
["socket.smtp"] = "src/smtp.lua",
|
||||
ltn12 = "src/ltn12.lua",
|
||||
socket = "src/socket.lua",
|
||||
mime = "src/mime.lua"
|
||||
}
|
||||
if plat == "unix"
|
||||
or plat == "macosx"
|
||||
or plat == "haiku"
|
||||
then
|
||||
modules["socket.core"].sources[#modules["socket.core"].sources+1] = "src/usocket.c"
|
||||
if plat == "haiku" then
|
||||
modules["socket.core"].libraries = {"network"}
|
||||
end
|
||||
modules["socket.unix"] = {
|
||||
sources = {
|
||||
"src/buffer.c"
|
||||
, "src/compat.c"
|
||||
, "src/auxiliar.c"
|
||||
, "src/options.c"
|
||||
, "src/timeout.c"
|
||||
, "src/io.c"
|
||||
, "src/usocket.c"
|
||||
, "src/unix.c"
|
||||
, "src/unixdgram.c"
|
||||
, "src/unixstream.c" },
|
||||
defines = defines[plat],
|
||||
incdir = "/src"
|
||||
}
|
||||
modules["socket.serial"] = {
|
||||
sources = {
|
||||
"src/buffer.c"
|
||||
, "src/compat.c"
|
||||
, "src/auxiliar.c"
|
||||
, "src/options.c"
|
||||
, "src/timeout.c"
|
||||
, "src/io.c"
|
||||
, "src/usocket.c"
|
||||
, "src/serial.c" },
|
||||
defines = defines[plat],
|
||||
incdir = "/src"
|
||||
}
|
||||
end
|
||||
if plat == "win32"
|
||||
or plat == "mingw32"
|
||||
then
|
||||
modules["socket.core"].sources[#modules["socket.core"].sources+1] = "src/wsocket.c"
|
||||
modules["socket.core"].libraries = { "ws2_32" }
|
||||
modules["socket.core"].libdirs = {}
|
||||
end
|
||||
return { modules = modules }
|
||||
end
|
||||
|
||||
build = {
|
||||
type = "builtin",
|
||||
platforms = {
|
||||
unix = make_plat("unix"),
|
||||
macosx = make_plat("macosx"),
|
||||
haiku = make_plat("haiku"),
|
||||
win32 = make_plat("win32"),
|
||||
mingw32 = make_plat("mingw32")
|
||||
},
|
||||
copy_directories = {
|
||||
"docs"
|
||||
, "samples"
|
||||
, "etc"
|
||||
, "test" }
|
||||
}
|
4
src/inet.c
Normal file → Executable file
4
src/inet.c
Normal file → Executable file
@ -253,7 +253,7 @@ int inet_meth_getpeername(lua_State *L, p_socket ps, int family)
|
||||
port, sizeof(port), NI_NUMERICHOST | NI_NUMERICSERV);
|
||||
if (err) {
|
||||
lua_pushnil(L);
|
||||
lua_pushstring(L, gai_strerror(err));
|
||||
lua_pushstring(L, LUA_GAI_STRERROR(err));
|
||||
return 2;
|
||||
}
|
||||
lua_pushstring(L, name);
|
||||
@ -286,7 +286,7 @@ int inet_meth_getsockname(lua_State *L, p_socket ps, int family)
|
||||
name, INET6_ADDRSTRLEN, port, 6, NI_NUMERICHOST | NI_NUMERICSERV);
|
||||
if (err) {
|
||||
lua_pushnil(L);
|
||||
lua_pushstring(L, gai_strerror(err));
|
||||
lua_pushstring(L, LUA_GAI_STRERROR(err));
|
||||
return 2;
|
||||
}
|
||||
lua_pushstring(L, name);
|
||||
|
@ -10,7 +10,7 @@
|
||||
/*-------------------------------------------------------------------------* \
|
||||
* Current socket library version
|
||||
\*-------------------------------------------------------------------------*/
|
||||
#define LUASOCKET_VERSION "LuaSocket 3.0-rc1"
|
||||
#define LUASOCKET_VERSION "LuaSocket 3.0.0"
|
||||
#define LUASOCKET_COPYRIGHT "Copyright (C) 1999-2013 Diego Nehab"
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
|
@ -272,7 +272,7 @@ SOCKET_win64=wsocket.obj
|
||||
#
|
||||
SO=$(SO_$(PLAT))
|
||||
O=$(O_$(PLAT))
|
||||
SOCKET_V=3.0-rc1
|
||||
SOCKET_V=3.0.0
|
||||
MIME_V=1.0.3
|
||||
SOCKET_SO=socket-$(SOCKET_V).$(SO)
|
||||
MIME_SO=mime-$(MIME_V).$(SO)
|
||||
|
@ -190,6 +190,31 @@ int opt_set_send_buf_size(lua_State *L, p_socket ps)
|
||||
return opt_setint(L, ps, SOL_SOCKET, SO_SNDBUF);
|
||||
}
|
||||
|
||||
// /*------------------------------------------------------*/
|
||||
|
||||
#ifdef TCP_FASTOPEN
|
||||
int opt_set_tcp_fastopen(lua_State *L, p_socket ps)
|
||||
{
|
||||
return opt_setint(L, ps, IPPROTO_TCP, TCP_FASTOPEN);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TCP_FASTOPEN_CONNECT
|
||||
int opt_set_tcp_fastopen_connect(lua_State *L, p_socket ps)
|
||||
{
|
||||
return opt_setint(L, ps, IPPROTO_TCP, TCP_FASTOPEN_CONNECT);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------*/
|
||||
|
||||
#ifdef TCP_DEFER_ACCEPT
|
||||
int opt_set_tcp_defer_accept(lua_State *L, p_socket ps)
|
||||
{
|
||||
return opt_setint(L, ps, IPPROTO_TCP, TCP_DEFER_ACCEPT);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*------------------------------------------------------*/
|
||||
int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps)
|
||||
{
|
||||
|
@ -49,6 +49,10 @@ int opt_set_tcp_keepintvl(lua_State *L, p_socket ps);
|
||||
int opt_get_tcp_keepintvl(lua_State *L, p_socket ps);
|
||||
#endif
|
||||
|
||||
#ifdef TCP_DEFER_ACCEPT
|
||||
int opt_set_tcp_defer_accept(lua_State *L, p_socket ps);
|
||||
#endif
|
||||
|
||||
int opt_set_keepalive(lua_State *L, p_socket ps);
|
||||
int opt_get_keepalive(lua_State *L, p_socket ps);
|
||||
|
||||
@ -64,6 +68,13 @@ int opt_get_recv_buf_size(lua_State *L, p_socket ps);
|
||||
int opt_set_send_buf_size(lua_State *L, p_socket ps);
|
||||
int opt_get_send_buf_size(lua_State *L, p_socket ps);
|
||||
|
||||
#ifdef TCP_FASTOPEN
|
||||
int opt_set_tcp_fastopen(lua_State *L, p_socket ps);
|
||||
#endif
|
||||
#ifdef TCP_FASTOPEN_CONNECT
|
||||
int opt_set_tcp_fastopen_connect(lua_State *L, p_socket ps);
|
||||
#endif
|
||||
|
||||
int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps);
|
||||
int opt_get_ip6_unicast_hops(lua_State *L, p_socket ps);
|
||||
|
||||
|
2
src/socket.h
Normal file → Executable file
2
src/socket.h
Normal file → Executable file
@ -16,8 +16,10 @@
|
||||
\*=========================================================================*/
|
||||
#ifdef _WIN32
|
||||
#include "wsocket.h"
|
||||
#define LUA_GAI_STRERROR gai_strerrorA
|
||||
#else
|
||||
#include "usocket.h"
|
||||
#define LUA_GAI_STRERROR gai_strerror
|
||||
#endif
|
||||
|
||||
/*=========================================================================*\
|
||||
|
@ -109,6 +109,15 @@ static t_opt optset[] = {
|
||||
{"linger", opt_set_linger},
|
||||
{"recv-buffer-size", opt_set_recv_buf_size},
|
||||
{"send-buffer-size", opt_set_send_buf_size},
|
||||
#ifdef TCP_DEFER_ACCEPT
|
||||
{"tcp-defer-accept", opt_set_tcp_defer_accept},
|
||||
#endif
|
||||
#ifdef TCP_FASTOPEN
|
||||
{"tcp-fastopen", opt_set_tcp_fastopen},
|
||||
#endif
|
||||
#ifdef TCP_FASTOPEN_CONNECT
|
||||
{"tcp-fastopen-connect", opt_set_tcp_fastopen_connect},
|
||||
#endif
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
4
src/udp.c
Normal file → Executable file
4
src/udp.c
Normal file → Executable file
@ -191,7 +191,7 @@ static int meth_sendto(lua_State *L) {
|
||||
err = getaddrinfo(ip, port, &aihint, &ai);
|
||||
if (err) {
|
||||
lua_pushnil(L);
|
||||
lua_pushstring(L, gai_strerror(err));
|
||||
lua_pushstring(L, LUA_GAI_STRERROR(err));
|
||||
return 2;
|
||||
}
|
||||
|
||||
@ -290,7 +290,7 @@ static int meth_receivefrom(lua_State *L) {
|
||||
INET6_ADDRSTRLEN, portstr, 6, NI_NUMERICHOST | NI_NUMERICSERV);
|
||||
if (err) {
|
||||
lua_pushnil(L);
|
||||
lua_pushstring(L, gai_strerror(err));
|
||||
lua_pushstring(L, LUA_GAI_STRERROR(err));
|
||||
if (wanted > sizeof(buf)) free(dgram);
|
||||
return 2;
|
||||
}
|
||||
|
@ -449,6 +449,6 @@ const char *socket_gaistrerror(int err) {
|
||||
case EAI_SERVICE: return PIE_SERVICE;
|
||||
case EAI_SOCKTYPE: return PIE_SOCKTYPE;
|
||||
case EAI_SYSTEM: return strerror(errno);
|
||||
default: return gai_strerror(err);
|
||||
default: return LUA_GAI_STRERROR(err);
|
||||
}
|
||||
}
|
||||
|
@ -429,6 +429,6 @@ const char *socket_gaistrerror(int err) {
|
||||
#ifdef EAI_SYSTEM
|
||||
case EAI_SYSTEM: return strerror(errno);
|
||||
#endif
|
||||
default: return gai_strerror(err);
|
||||
default: return LUA_GAI_STRERROR(err);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user