From f5df416fd9b9d428aaf8c997e50b89c2710a010f Mon Sep 17 00:00:00 2001 From: Kiyoshi Aman Date: Tue, 9 Oct 2018 08:21:38 -0500 Subject: user/lua-socket: new package for lua-sec & prosody --- ...et-on-first-sendto-if-family-agnostic-udp.patch | 49 + user/lua-socket/APKBUILD | 41 + user/lua-socket/git.patch | 6609 ++++++++++++++++++++ user/lua-socket/lua-cflags.patch | 22 + 4 files changed, 6721 insertions(+) create mode 100644 user/lua-socket/0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch create mode 100644 user/lua-socket/APKBUILD create mode 100644 user/lua-socket/git.patch create mode 100644 user/lua-socket/lua-cflags.patch (limited to 'user/lua-socket') diff --git a/user/lua-socket/0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch b/user/lua-socket/0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch new file mode 100644 index 000000000..61bae6fbf --- /dev/null +++ b/user/lua-socket/0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch @@ -0,0 +1,49 @@ +From 3041a808c3797e3c87272d71666e7b2f7c7a9f46 Mon Sep 17 00:00:00 2001 +From: Natanael Copa +Date: Wed, 25 Jan 2017 12:43:29 +0100 +Subject: [PATCH] Create socket on first sendto if family agnostic udp() was + used + +Create socket and set family on first sendto() if udp() was created +without address family. + +Signed-off-by: Natanael Copa +--- + src/udp.c | 21 +++++++++++++++++++++ + 1 file changed, 21 insertions(+) + +diff --git a/src/udp.c b/src/udp.c +index ec97252..605c195 100644 +--- a/src/udp.c ++++ b/src/udp.c +@@ -189,6 +189,27 @@ static int meth_sendto(lua_State *L) { + lua_pushstring(L, gai_strerror(err)); + return 2; + } ++ ++ /* create socket if on first sendto if AF_UNSPEC was set */ ++ if (udp->family == AF_UNSPEC && udp->sock == SOCKET_INVALID) { ++ struct addrinfo *ap; ++ const char *errstr = NULL; ++ for (ap = ai; ap != NULL; ap = ap->ai_next) { ++ errstr = inet_trycreate(&udp->sock, ap->ai_family, SOCK_DGRAM, 0); ++ if (errstr == NULL) { ++ socket_setnonblocking(&udp->sock); ++ udp->family = ap->ai_family; ++ break; ++ } ++ } ++ if (errstr != NULL) { ++ lua_pushnil(L); ++ lua_pushstring(L, errstr); ++ freeaddrinfo(ai); ++ return 2; ++ } ++ } ++ + timeout_markstart(tm); + err = socket_sendto(&udp->sock, data, count, &sent, ai->ai_addr, + (socklen_t) ai->ai_addrlen, tm); +-- +2.11.0 + diff --git a/user/lua-socket/APKBUILD b/user/lua-socket/APKBUILD new file mode 100644 index 000000000..16bfbcf40 --- /dev/null +++ b/user/lua-socket/APKBUILD @@ -0,0 +1,41 @@ +# Contributor: Mika Havela +# Maintainer: Kiyoshi Aman +pkgname=lua-socket +_name=luasocket +pkgver=3.0_rc1_git20160306 +pkgrel=0 +_ver=${pkgver%_git*} +_ver=${_ver/_rc/-rc} +pkgdesc="Networking library for Lua" +url="http://luaforge.net/projects/luasocket/" +arch="all" +license="MIT" +depends="lua5.3" +makedepends="lua5.3-dev" +source="luasocket-$_ver.tar.gz::https://github.com/diegonehab/luasocket/archive/v$_ver.tar.gz + git.patch + lua-cflags.patch + 0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch" +builddir="$srcdir/$_name-$_ver" + +build() { + cd "$builddir" + make LUAV="" +} + +check() { + cd "$builddir" + mkdir -p src/socket && cp src/socket-$_ver.so src/socket/core.so + mkdir -p src/mime && cp src/mime-1.0.3.so src/mime/core.so + LUA_CPATH=./src/?.so LUA_PATH="./src/?.lua;;" lua test/hello.lua +} + +package() { + cd "$builddir" + make prefix=/usr DESTDIR="$pkgdir" LUAV="5.3" install-unix +} + +sha512sums="f6efce259aaacaa11472911471f8a13b118fe009b8953a82c6aa18b9ec829cd1293180904e56935cb130d36d267e3f27c91db2d78e03f7488f3e100571ed0540 luasocket-3.0-rc1.tar.gz +45c80e488fedc879f0217bc8a654d80da003039f5d1ff21b0dea0eb769151787dbe793e44a3dfd72cb07ff2697eceaf4fc7b55b4634cd170fa71281f19f025a5 git.patch +61c15238a2f116b7239fdbdb8f617c82dbbecd0117c6e8389b12015bf07f3978299a8e8995e93a45a23530c747662b08d161073cdb6a8e07c4f449e45856e8cb lua-cflags.patch +c45a12e17771a1b3b71154b5415421f524cd10b7969b4649a5f37b652cdc826721e117edb8fe64758d3520e59946e2f755b814f72cbb39ff42bf59bbcf9a64e9 0001-Create-socket-on-first-sendto-if-family-agnostic-udp.patch" diff --git a/user/lua-socket/git.patch b/user/lua-socket/git.patch new file mode 100644 index 000000000..d665fc232 --- /dev/null +++ b/user/lua-socket/git.patch @@ -0,0 +1,6609 @@ +diff --git a/doc/http.html b/doc/http.html +index cd41c0d..3b7a8b1 100644 +--- a/doc/http.html ++++ b/doc/http.html +@@ -112,12 +112,15 @@ the HTTP module: +

+ +
    +-
  • PORT: default port used for connections; +-
  • PROXY: default proxy used for connections; ++
  • PROXY: default proxy used for connections; +
  • TIMEOUT: sets the timeout for all I/O operations; +
  • USERAGENT: default user agent reported to server. +
+ ++

++Note: These constants are global. Changing them will also ++change the behavior other code that might be using LuaSocket. ++

+ + + +diff --git a/doc/mime.html b/doc/mime.html +index ae136fd..8cb3507 100644 +--- a/doc/mime.html ++++ b/doc/mime.html +@@ -72,34 +72,6 @@ local mime = require("mime") + +

High-level filters

+ +- +- +-

+-mime.normalize([marker]) +-

+- +-

+-Converts most common end-of-line markers to a specific given marker. +-

+- +-

+-Marker is the new marker. It defaults to CRLF, the canonic +-end-of-line marker defined by the MIME standard. +-

+- +-

+-The function returns a filter that performs the conversion. +-

+- +-

+-Note: There is no perfect solution to this problem. Different end-of-line +-markers are an evil that will probably plague developers forever. +-This function, however, will work perfectly for text created with any of +-the most common end-of-line markers, i.e. the Mac OS (CR), the Unix (LF), +-or the DOS (CRLF) conventions. Even if the data has mixed end-of-line +-markers, the function will still work well, although it doesn't +-guarantee that the number of empty lines will be correct. +-

+ + + +@@ -159,6 +131,35 @@ base64 = ltn12.filter.chain( + ) + + ++ ++ ++

++mime.normalize([marker]) ++

++ ++

++Converts most common end-of-line markers to a specific given marker. ++

++ ++

++Marker is the new marker. It defaults to CRLF, the canonic ++end-of-line marker defined by the MIME standard. ++

++ ++

++The function returns a filter that performs the conversion. ++

++ ++

++Note: There is no perfect solution to this problem. Different end-of-line ++markers are an evil that will probably plague developers forever. ++This function, however, will work perfectly for text created with any of ++the most common end-of-line markers, i.e. the Mac OS (CR), the Unix (LF), ++or the DOS (CRLF) conventions. Even if the data has mixed end-of-line ++markers, the function will still work well, although it doesn't ++guarantee that the number of empty lines will be correct. ++

++ + + +

+@@ -466,7 +467,7 @@ marker. +

+ + Last modified by Diego Nehab on
+-Thu Apr 20 00:25:44 EDT 2006 ++Fri Mar 4 15:19:17 BRT 2016 +
+

+ +diff --git a/doc/reference.css b/doc/reference.css +index b1dd25d..04e38cf 100644 +--- a/doc/reference.css ++++ b/doc/reference.css +@@ -2,6 +2,7 @@ body { + margin-left: 1em; + margin-right: 1em; + font-family: "Verdana", sans-serif; ++ background: #ffffff; + } + + tt { +diff --git a/doc/reference.html b/doc/reference.html +index e9bb5eb..287dc19 100644 +--- a/doc/reference.html ++++ b/doc/reference.html +@@ -147,6 +147,7 @@ Support, Manual"> + connect, + connect4, + connect6, ++_DATAGRAMSIZE, + _DEBUG, + dns, + gettime, +@@ -158,11 +159,14 @@ Support, Manual"> + skip, + sleep, + _SETSIZE, ++_SOCKETINVALID, + source, + tcp, ++tcp4, + tcp6, + try, + udp, ++udp4, + udp6, + _VERSION. + +@@ -183,6 +187,7 @@ Support, Manual"> + getpeername, + getsockname, + getstats, ++gettimeout, + listen, + receive, + send, +@@ -203,6 +208,7 @@ Support, Manual"> + getoption, + getpeername, + getsockname, ++gettimeout, + receive, + receivefrom, + send, +diff --git a/doc/smtp.html b/doc/smtp.html +index bbbff80..600ec37 100644 +--- a/doc/smtp.html ++++ b/doc/smtp.html +@@ -114,6 +114,124 @@ the SMTP module: +
  • ZONE: default time zone. + + ++ ++ ++

    ++smtp.message(mesgt) ++

    ++ ++

    ++Returns a simple ++LTN12 source that sends an SMTP message body, possibly multipart (arbitrarily deep). ++

    ++ ++

    ++The only parameter of the function is a table describing the message. ++Mesgt has the following form (notice the recursive structure): ++

    ++ ++
    ++ ++ ++
    ++mesgt = {
    ++  headers = header-table,
    ++  body = LTN12 source or string or ++multipart-mesgt
    ++}
    ++ 
    ++multipart-mesgt = {
    ++  [preamble = string,]
    ++  [1] = mesgt,
    ++  [2] = mesgt,
    ++  ...
    ++  [n] = mesgt,
    ++  [epilogue = string,]
    ++}
    ++
    ++
    ++ ++

    ++For a simple message, all that is needed is a set of headers ++and the body. The message body can be given as a string ++or as a simple ++LTN12 ++source. For multipart messages, the body is a table that ++recursively defines each part as an independent message, plus an optional ++preamble and epilogue. ++

    ++ ++

    ++The function returns a simple ++LTN12 ++source that produces the ++message contents as defined by mesgt, chunk by chunk. ++Hopefully, the following ++example will make things clear. When in doubt, refer to the appropriate RFC ++as listed in the introduction.

    ++ ++
    ++-- load the smtp support and its friends
    ++local smtp = require("socket.smtp")
    ++local mime = require("mime")
    ++local ltn12 = require("ltn12")
    ++
    ++-- creates a source to send a message with two parts. The first part is 
    ++-- plain text, the second part is a PNG image, encoded as base64.
    ++source = smtp.message{
    ++  headers = {
    ++     -- Remember that headers are *ignored* by smtp.send. 
    ++     from = "Sicrano de Oliveira <sicrano@example.com>",
    ++     to = "Fulano da Silva <fulano@example.com>",
    ++     subject = "Here is a message with attachments"
    ++  },
    ++  body = {
    ++    preamble = "If your client doesn't understand attachments, \r\n" ..
    ++               "it will still display the preamble and the epilogue.\r\n" ..
    ++               "Preamble will probably appear even in a MIME enabled client.",
    ++    -- first part: no headers means plain text, us-ascii.
    ++    -- The mime.eol low-level filter normalizes end-of-line markers.
    ++    [1] = { 
    ++      body = mime.eol(0, [[
    ++        Lines in a message body should always end with CRLF. 
    ++        The smtp module will *NOT* perform translation. However, the 
    ++        send function *DOES* perform SMTP stuffing, whereas the message
    ++        function does *NOT*.
    ++      ]])
    ++    },
    ++    -- second part: headers describe content to be a png image, 
    ++    -- sent under the base64 transfer content encoding.
    ++    -- notice that nothing happens until the message is actually sent. 
    ++    -- small chunks are loaded into memory right before transmission and 
    ++    -- translation happens on the fly.
    ++    [2] = { 
    ++      headers = {
    ++        ["content-type"] = 'image/png; name="image.png"',
    ++        ["content-disposition"] = 'attachment; filename="image.png"',
    ++        ["content-description"] = 'a beautiful image',
    ++        ["content-transfer-encoding"] = "BASE64"
    ++      },
    ++      body = ltn12.source.chain(
    ++        ltn12.source.file(io.open("image.png", "rb")),
    ++        ltn12.filter.chain(
    ++          mime.encode("base64"),
    ++          mime.wrap()
    ++        )
    ++      )
    ++    },
    ++    epilogue = "This might also show up, but after the attachments"
    ++  }
    ++}
    ++
    ++-- finally send it
    ++r, e = smtp.send{
    ++    from = "<sicrano@example.com>",
    ++    rcpt = "<fulano@example.com>",
    ++    source = source,
    ++}
    ++
    ++ ++ + + +

    +@@ -275,123 +393,6 @@ r, e = smtp.send{ + } + + +- +- +-

    +-smtp.message(mesgt) +-

    +- +-

    +-Returns a simple +-LTN12 source that sends an SMTP message body, possibly multipart (arbitrarily deep). +-

    +- +-

    +-The only parameter of the function is a table describing the message. +-Mesgt has the following form (notice the recursive structure): +-

    +- +-
    +- +- +-
    +-mesgt = {
    +-  headers = header-table,
    +-  body = LTN12 source or string or +-multipart-mesgt
    +-}
    +- 
    +-multipart-mesgt = {
    +-  [preamble = string,]
    +-  [1] = mesgt,
    +-  [2] = mesgt,
    +-  ...
    +-  [n] = mesgt,
    +-  [epilogue = string,]
    +-}
    +-
    +-
    +- +-

    +-For a simple message, all that is needed is a set of headers +-and the body. The message body can be given as a string +-or as a simple +-LTN12 +-source. For multipart messages, the body is a table that +-recursively defines each part as an independent message, plus an optional +-preamble and epilogue. +-

    +- +-

    +-The function returns a simple +-LTN12 +-source that produces the +-message contents as defined by mesgt, chunk by chunk. +-Hopefully, the following +-example will make things clear. When in doubt, refer to the appropriate RFC +-as listed in the introduction.

    +- +-
    +--- load the smtp support and its friends
    +-local smtp = require("socket.smtp")
    +-local mime = require("mime")
    +-local ltn12 = require("ltn12")
    +-
    +--- creates a source to send a message with two parts. The first part is 
    +--- plain text, the second part is a PNG image, encoded as base64.
    +-source = smtp.message{
    +-  headers = {
    +-     -- Remember that headers are *ignored* by smtp.send. 
    +-     from = "Sicrano de Oliveira <sicrano@example.com>",
    +-     to = "Fulano da Silva <fulano@example.com>",
    +-     subject = "Here is a message with attachments"
    +-  },
    +-  body = {
    +-    preamble = "If your client doesn't understand attachments, \r\n" ..
    +-               "it will still display the preamble and the epilogue.\r\n" ..
    +-               "Preamble will probably appear even in a MIME enabled client.",
    +-    -- first part: no headers means plain text, us-ascii.
    +-    -- The mime.eol low-level filter normalizes end-of-line markers.
    +-    [1] = { 
    +-      body = mime.eol(0, [[
    +-        Lines in a message body should always end with CRLF. 
    +-        The smtp module will *NOT* perform translation. However, the 
    +-        send function *DOES* perform SMTP stuffing, whereas the message
    +-        function does *NOT*.
    +-      ]])
    +-    },
    +-    -- second part: headers describe content to be a png image, 
    +-    -- sent under the base64 transfer content encoding.
    +-    -- notice that nothing happens until the message is actually sent. 
    +-    -- small chunks are loaded into memory right before transmission and 
    +-    -- translation happens on the fly.
    +-    [2] = { 
    +-      headers = {
    +-        ["content-type"] = 'image/png; name="image.png"',
    +-        ["content-disposition"] = 'attachment; filename="image.png"',
    +-        ["content-description"] = 'a beautiful image',
    +-        ["content-transfer-encoding"] = "BASE64"
    +-      },
    +-      body = ltn12.source.chain(
    +-        ltn12.source.file(io.open("image.png", "rb")),
    +-        ltn12.filter.chain(
    +-          mime.encode("base64"),
    +-          mime.wrap()
    +-        )
    +-      )
    +-    },
    +-    epilogue = "This might also show up, but after the attachments"
    +-  }
    +-}
    +-
    +--- finally send it
    +-r, e = smtp.send{
    +-    from = "<sicrano@example.com>",
    +-    rcpt = "<fulano@example.com>",
    +-    source = source,
    +-}
    +-
    +- + + +