mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-11-08 14:28:21 +01:00
Making progress toward a release
Documented headers.lua Update copyright date everywhere Remove RCSID from files Move version back to 2.1 rather than 2.1.1 Fixed url package to support ipv6 hosts Changed "domain" to "family" in tcp and udp structures Implemented getfamily methods
This commit is contained in:
parent
f37e026026
commit
f960b3872a
4
LICENSE
4
LICENSE
@ -1,5 +1,5 @@
|
|||||||
LuaSocket 2.0.2 license
|
LuaSocket 2.1 license
|
||||||
Copyright © 2004-2007 Diego Nehab
|
Copyright © 2004-2012 Diego Nehab
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
copy of this software and associated documentation files (the "Software"),
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
2
README
2
README
@ -1,4 +1,4 @@
|
|||||||
This is the LuaSocket 2.1.1. It has been tested on --[[WinXP--]], Mac OS X,
|
This is the LuaSocket 2.1. It has been tested on --[[WinXP--]], Mac OS X,
|
||||||
and --[[Linux--]]. Please use the Lua mailing list to report any bugs
|
and --[[Linux--]]. Please use the Lua mailing list to report any bugs
|
||||||
(or "features") you encounter.
|
(or "features") you encounter.
|
||||||
|
|
||||||
|
25
TODO
25
TODO
@ -1,39 +1,40 @@
|
|||||||
- merge luaL_typeerror into auxiliar to avoid using luaL prefix?
|
|
||||||
- getsockname should also support IPv6, no?
|
- getsockname should also support IPv6, no?
|
||||||
- remove RCSID from files?
|
|
||||||
- shouldn't we instead make the code compatible to Lua 5.2
|
- shouldn't we instead make the code compatible to Lua 5.2
|
||||||
without any compat stuff, and use a compatibility layer to
|
without any compat stuff, and use a compatibility layer to
|
||||||
make it work on 5.1?
|
make it work on 5.1?
|
||||||
- why 2.1.1 rather than 2.1?
|
|
||||||
- add what's new to manual
|
- add what's new to manual
|
||||||
- should there be an equivalent to tohostname for IPv6?
|
- should there be an equivalent to tohostname for IPv6?
|
||||||
- should we add service name resolution as well to
|
- should we add service name resolution as well to getaddrinfo?
|
||||||
getaddrinfo?
|
|
||||||
- document bind and connect behavior based on address?
|
- document bind and connect behavior based on address?
|
||||||
|
|
||||||
- add functionality to query if object is ipv4 or 6?
|
|
||||||
- update copyright date everywhere?
|
|
||||||
- what to do about author?
|
|
||||||
- add http POST sample to manual
|
- add http POST sample to manual
|
||||||
people keep asking stupid questions
|
people keep asking stupid questions
|
||||||
- documentation of dirty/getfd/setfd is problematic because of portability
|
- documentation of dirty/getfd/setfd is problematic because of portability
|
||||||
same for unix and serial.
|
same for unix and serial.
|
||||||
what to do about this? add a stronger disclaimer?
|
what to do about this? add a stronger disclaimer?
|
||||||
- remove references to Lua 5.0 from documentation, add 5.2?
|
|
||||||
- update lua and luasocket version in samples in documentation
|
|
||||||
- document headers.lua?
|
|
||||||
- fix makefile with decent defaults?
|
- fix makefile with decent defaults?
|
||||||
|
|
||||||
Done:
|
Done:
|
||||||
|
|
||||||
|
- document headers.lua?
|
||||||
|
- update copyright date everywhere?
|
||||||
|
- remove RCSID from files?
|
||||||
|
- move version to 2.1 rather than 2.1.1?
|
||||||
|
- fixed url package to support ipv6 hosts
|
||||||
|
- changed domain to family
|
||||||
|
- implement getfamily methods.
|
||||||
|
|
||||||
|
- remove references to Lua 5.0 from documentation, add 5.2?
|
||||||
|
- update lua and luasocket version in samples in documentation
|
||||||
- document ipv5_v6only default option being set?
|
- document ipv5_v6only default option being set?
|
||||||
- document tcp6 and udp6
|
- document tcp6 and udp6
|
||||||
- document dns.getaddrinfo
|
- document dns.getaddrinfo
|
||||||
- document zero-sized send on udp vs. tcp?
|
- documented zero-sized datagram change?
|
||||||
no.
|
no.
|
||||||
- document unix socket and serial socket? add raw support?
|
- document unix socket and serial socket? add raw support?
|
||||||
no.
|
no.
|
||||||
- document getoption
|
- document getoption
|
||||||
|
- merge luaL_typeerror into auxiliar to avoid using luaL prefix?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -95,8 +95,9 @@ headers = {<br>
|
|||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Field names are case insensitive (as specified by the standard) and all
|
Field names are case insensitive (as specified by the standard) and all
|
||||||
functions work with lowercase field names.
|
functions work with lowercase field names (but see
|
||||||
|
<a href=socket.html#headers.canonic><tt>socket.headers.canonic</tt></a>).
|
||||||
Field values are left unmodified.
|
Field values are left unmodified.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@ -117,6 +118,7 @@ the HTTP module:
|
|||||||
<li> <tt>USERAGENT</tt>: default user agent reported to server.
|
<li> <tt>USERAGENT</tt>: default user agent reported to server.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
<!-- http.request ++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
<!-- http.request ++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||||
|
|
||||||
<p class=name id="request">
|
<p class=name id="request">
|
||||||
|
@ -87,7 +87,7 @@ Author: <A href="http://www.impa.br/~diego">Diego Nehab</a>
|
|||||||
<h2 id=download>Download</h2>
|
<h2 id=download>Download</h2>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
LuaSocket version 2.1.1-rc1 is now available for download!
|
LuaSocket version 2.1-rc1 is now available for download!
|
||||||
It is compatible with Lua 5.1 and 5.2, and has
|
It is compatible with Lua 5.1 and 5.2, and has
|
||||||
been tested on Windows XP, Linux, and Mac OS X. Chances
|
been tested on Windows XP, Linux, and Mac OS X. Chances
|
||||||
are it works well on most UNIX distributions and Windows flavors.
|
are it works well on most UNIX distributions and Windows flavors.
|
||||||
@ -125,7 +125,7 @@ has helped bring this library back to life.
|
|||||||
<h2 id=new>What's New</h2>
|
<h2 id=new>What's New</h2>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Main changes for LuaSocket 2.1.1-rc1 are IPv6 support
|
Main changes for LuaSocket 2.1-rc1 are IPv6 support
|
||||||
and Lua 5.2 compatibility.
|
and Lua 5.2 compatibility.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
@ -135,6 +135,7 @@ and Lua 5.2 compatibility.
|
|||||||
<ul>
|
<ul>
|
||||||
<li> <tt>Socket.connect</tt> and <tt>socket.bind</tt> support IPv6 addresses;
|
<li> <tt>Socket.connect</tt> and <tt>socket.bind</tt> support IPv6 addresses;
|
||||||
<li> <tt>Getpeername</tt> and <tt>getsockname</tt> support IPv6 addresses;
|
<li> <tt>Getpeername</tt> and <tt>getsockname</tt> support IPv6 addresses;
|
||||||
|
<li> URL module updated to support IPv6 host names;
|
||||||
<li> New <tt>socket.tcp6</tt> and <tt>socket.udp6</tt> functions;
|
<li> New <tt>socket.tcp6</tt> and <tt>socket.udp6</tt> functions;
|
||||||
<li> New <tt>socket.dns.getaddrinfo</tt> function;
|
<li> New <tt>socket.dns.getaddrinfo</tt> function;
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -39,7 +39,7 @@ Installation">
|
|||||||
|
|
||||||
<h2>Installation</h2>
|
<h2>Installation</h2>
|
||||||
|
|
||||||
<p> LuaSocket 2.1.1-rc still uses Lua 5.1's package
|
<p> LuaSocket 2.1-rc still uses Lua 5.1's package
|
||||||
system. Users that have already made the switch to
|
system. Users that have already made the switch to
|
||||||
Lua 5.2 should leave the default
|
Lua 5.2 should leave the default
|
||||||
<tt>LUA_COMPAT_MODULE</tt> defined when compiling their Lua
|
<tt>LUA_COMPAT_MODULE</tt> defined when compiling their Lua
|
||||||
@ -95,7 +95,7 @@ it should be easy to use LuaSocket. Just fire the interpreter and use the
|
|||||||
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
|
Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio
|
||||||
> socket = require("socket")
|
> socket = require("socket")
|
||||||
> print(socket._VERSION)
|
> print(socket._VERSION)
|
||||||
--> LuaSocket 2.1.1-rc1
|
--> LuaSocket 2.1-rc1
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<p> Each module loads their dependencies automatically, so you only need to
|
<p> Each module loads their dependencies automatically, so you only need to
|
||||||
|
@ -148,6 +148,7 @@ Support, Manual">
|
|||||||
<a href="socket.html#debug">_DEBUG</a>,
|
<a href="socket.html#debug">_DEBUG</a>,
|
||||||
<a href="dns.html#dns">dns</a>,
|
<a href="dns.html#dns">dns</a>,
|
||||||
<a href="socket.html#gettime">gettime</a>,
|
<a href="socket.html#gettime">gettime</a>,
|
||||||
|
<a href="socket.html#headers.canonic">headers.canonic</a>,
|
||||||
<a href="socket.html#newtry">newtry</a>,
|
<a href="socket.html#newtry">newtry</a>,
|
||||||
<a href="socket.html#protect">protect</a>,
|
<a href="socket.html#protect">protect</a>,
|
||||||
<a href="socket.html#select">select</a>,
|
<a href="socket.html#select">select</a>,
|
||||||
|
@ -90,8 +90,9 @@ headers = {<br>
|
|||||||
</blockquote>
|
</blockquote>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Field names are case insensitive (as specified by the standard) and all
|
Field names are case insensitive (as specified by the standard) and all
|
||||||
functions work with lowercase field names.
|
functions work with lowercase field names (but see
|
||||||
|
<a href=socket.html#headers.canonic><tt>socket.headers.canonic</tt></a>).
|
||||||
Field values are left unmodified.
|
Field values are left unmodified.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
@ -112,6 +112,29 @@ t = socket.gettime()
|
|||||||
print(socket.gettime() - t .. " seconds elapsed")
|
print(socket.gettime() - t .. " seconds elapsed")
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
<!-- socket.headers ++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||||
|
|
||||||
|
<p class=name id="headers.canonic">
|
||||||
|
socket.headers.<b>canonic</b></p>
|
||||||
|
|
||||||
|
<p> The <tt>socket.headers.canonic</tt> table
|
||||||
|
is used by the HTTP and SMTP modules to translate from
|
||||||
|
lowercase field names back into their canonic
|
||||||
|
capitalization. When a lowercase field name exists as a key
|
||||||
|
in this table, the associated value is substituted in
|
||||||
|
whenever the field name is sent out.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
You can obtain the <tt>headers</tt> namespace if case run-time
|
||||||
|
modifications are required by running:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<pre class=example>
|
||||||
|
-- loads the headers module
|
||||||
|
local headers = require("headers")
|
||||||
|
</pre>
|
||||||
|
|
||||||
<!-- newtry +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
<!-- newtry +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -->
|
||||||
|
|
||||||
<p class=name id=newtry>
|
<p class=name id=newtry>
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
-- Little program to convert to and from Base64
|
-- Little program to convert to and from Base64
|
||||||
-- LuaSocket sample files
|
-- LuaSocket sample files
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id: b64.lua,v 1.8 2004/06/16 04:28:21 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
local ltn12 = require("ltn12")
|
local ltn12 = require("ltn12")
|
||||||
local mime = require("mime")
|
local mime = require("mime")
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
-- non-blocking I/O via the dispatcher module.
|
-- non-blocking I/O via the dispatcher module.
|
||||||
-- LuaSocket sample files
|
-- LuaSocket sample files
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $$
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
local url = require("socket.url")
|
local url = require("socket.url")
|
||||||
local dispatch = require("dispatch")
|
local dispatch = require("dispatch")
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
-- Little program to download DICT word definitions
|
-- Little program to download DICT word definitions
|
||||||
-- LuaSocket sample files
|
-- LuaSocket sample files
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id: dict.lua,v 1.22 2005/11/22 08:33:29 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
-- A hacked dispatcher module
|
-- A hacked dispatcher module
|
||||||
-- LuaSocket sample files
|
-- LuaSocket sample files
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $$
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
local base = _G
|
local base = _G
|
||||||
local table = require("table")
|
local table = require("table")
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
-- Little program to adjust end of line markers.
|
-- Little program to adjust end of line markers.
|
||||||
-- LuaSocket sample files
|
-- LuaSocket sample files
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id: eol.lua,v 1.8 2005/11/22 08:33:29 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
local mime = require("mime")
|
local mime = require("mime")
|
||||||
local ltn12 = require("ltn12")
|
local ltn12 = require("ltn12")
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
-- Little program to download files from URLs
|
-- Little program to download files from URLs
|
||||||
-- LuaSocket sample files
|
-- LuaSocket sample files
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id: get.lua,v 1.25 2007/03/12 04:08:40 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
local socket = require("socket")
|
local socket = require("socket")
|
||||||
local http = require("socket.http")
|
local http = require("socket.http")
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
-- LuaSocket toolkit.
|
-- LuaSocket toolkit.
|
||||||
-- Author: David Burgess
|
-- Author: David Burgess
|
||||||
-- Modified by Diego Nehab, but David is in charge
|
-- Modified by Diego Nehab, but David is in charge
|
||||||
-- RCS ID: $Id: lp.lua,v 1.14 2005/11/21 07:04:44 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
--[[
|
--[[
|
||||||
if you have any questions: RFC 1179
|
if you have any questions: RFC 1179
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
-- Little program to convert to and from Quoted-Printable
|
-- Little program to convert to and from Quoted-Printable
|
||||||
-- LuaSocket sample files
|
-- LuaSocket sample files
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id: qp.lua,v 1.5 2004/06/17 21:46:22 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
local ltn12 = require("ltn12")
|
local ltn12 = require("ltn12")
|
||||||
local mime = require("mime")
|
local mime = require("mime")
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
-- TFTP support for the Lua language
|
-- TFTP support for the Lua language
|
||||||
-- LuaSocket toolkit.
|
-- LuaSocket toolkit.
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id: tftp.lua,v 1.16 2005/11/22 08:33:29 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#--------------------------------------------------------------------------
|
#--------------------------------------------------------------------------
|
||||||
# Distribution makefile
|
# Distribution makefile
|
||||||
#--------------------------------------------------------------------------
|
#--------------------------------------------------------------------------
|
||||||
DIST = luasocket-2.1.1-rc1
|
DIST = luasocket-2.1-rc1
|
||||||
|
|
||||||
TEST = \
|
TEST = \
|
||||||
test/README \
|
test/README \
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
-- UDP sample: daytime protocol client
|
-- UDP sample: daytime protocol client
|
||||||
-- LuaSocket sample files
|
-- LuaSocket sample files
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id: daytimeclnt.lua,v 1.11 2004/06/21 06:07:57 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
local socket = require"socket"
|
local socket = require"socket"
|
||||||
host = host or "127.0.0.1"
|
host = host or "127.0.0.1"
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
-- UDP sample: echo protocol client
|
-- UDP sample: echo protocol client
|
||||||
-- LuaSocket sample files
|
-- LuaSocket sample files
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id: echoclnt.lua,v 1.10 2005/01/02 22:44:00 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
local socket = require("socket")
|
local socket = require("socket")
|
||||||
host = host or "localhost"
|
host = host or "localhost"
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
-- UDP sample: echo protocol server
|
-- UDP sample: echo protocol server
|
||||||
-- LuaSocket sample files
|
-- LuaSocket sample files
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id: echosrvr.lua,v 1.12 2005/11/22 08:33:29 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
local socket = require("socket")
|
local socket = require("socket")
|
||||||
host = host or "127.0.0.1"
|
host = host or "127.0.0.1"
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
-- TCP sample: Little program to dump lines received at a given port
|
-- TCP sample: Little program to dump lines received at a given port
|
||||||
-- LuaSocket sample files
|
-- LuaSocket sample files
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id: listener.lua,v 1.11 2005/01/02 22:44:00 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
local socket = require("socket")
|
local socket = require("socket")
|
||||||
host = host or "*"
|
host = host or "*"
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
-- TCP sample: Little program to send text lines to a given host/port
|
-- TCP sample: Little program to send text lines to a given host/port
|
||||||
-- LuaSocket sample files
|
-- LuaSocket sample files
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id: talker.lua,v 1.9 2005/01/02 22:44:00 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
local socket = require("socket")
|
local socket = require("socket")
|
||||||
host = host or "localhost"
|
host = host or "localhost"
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
-- Select sample: simple text line server
|
-- Select sample: simple text line server
|
||||||
-- LuaSocket sample files.
|
-- LuaSocket sample files.
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id: tinyirc.lua,v 1.14 2005/11/22 08:33:29 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
local socket = require("socket")
|
local socket = require("socket")
|
||||||
host = host or "*"
|
host = host or "*"
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Auxiliar routines for class hierarchy manipulation
|
* Auxiliar routines for class hierarchy manipulation
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
*
|
|
||||||
* RCS ID: $Id: auxiliar.c,v 1.14 2005/10/07 04:40:59 diego Exp $
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Input/Output interface for Lua programs
|
* Input/Output interface for Lua programs
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
*
|
|
||||||
* RCS ID: $Id: buffer.c,v 1.29 2009/05/27 09:31:35 diego Exp $
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "lua.h"
|
#include "lua.h"
|
||||||
#include "lauxlib.h"
|
#include "lauxlib.h"
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Simple exception support
|
* Simple exception support
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
*
|
|
||||||
* RCS ID: $Id: except.c,v 1.8 2005/09/29 06:11:41 diego Exp $
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
-- FTP support for the Lua language
|
-- FTP support for the Lua language
|
||||||
-- LuaSocket toolkit.
|
-- LuaSocket toolkit.
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id: ftp.lua,v 1.45 2007/07/11 19:25:47 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
-- Canonic header field capitalization
|
-- Canonic header field capitalization
|
||||||
-- LuaSocket toolkit.
|
-- LuaSocket toolkit.
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id$
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
module("socket.headers")
|
module("socket.headers")
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
-- HTTP/1.1 client support for the Lua language.
|
-- HTTP/1.1 client support for the Lua language.
|
||||||
-- LuaSocket toolkit.
|
-- LuaSocket toolkit.
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id: http.lua,v 1.72 2009/05/27 09:31:35 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Internet domain functions
|
* Internet domain functions
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
*
|
|
||||||
* RCS ID: $Id: inet.c,v 1.28 2005/10/07 04:40:59 diego Exp $
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -270,8 +268,8 @@ static void inet_pushresolved(lua_State *L, struct hostent *hp)
|
|||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Tries to create a new inet socket
|
* Tries to create a new inet socket
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
const char *inet_trycreate(p_socket ps, int domain, int type) {
|
const char *inet_trycreate(p_socket ps, int family, int type) {
|
||||||
return socket_strerror(socket_create(ps, domain, type, 0));
|
return socket_strerror(socket_create(ps, family, type, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
|
2
src/io.c
2
src/io.c
@ -1,8 +1,6 @@
|
|||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Input/Output abstraction
|
* Input/Output abstraction
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
*
|
|
||||||
* RCS ID: $Id: io.c,v 1.6 2005/09/29 06:11:41 diego Exp $
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include "io.h"
|
#include "io.h"
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
-- LTN12 - Filters, sources, sinks and pumps.
|
-- LTN12 - Filters, sources, sinks and pumps.
|
||||||
-- LuaSocket toolkit.
|
-- LuaSocket toolkit.
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id: ltn12.lua,v 1.31 2006/04/03 04:45:42 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Current socket library version
|
* Current socket library version
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
#define LUASOCKET_VERSION "LuaSocket 2.1.1-rc1"
|
#define LUASOCKET_VERSION "LuaSocket 2.1-rc1"
|
||||||
#define LUASOCKET_COPYRIGHT "Copyright (C) 1999-2012 Diego Nehab"
|
#define LUASOCKET_COPYRIGHT "Copyright (C) 1999-2012 Diego Nehab"
|
||||||
#define LUASOCKET_AUTHORS "Diego Nehab"
|
#define LUASOCKET_AUTHORS "Diego Nehab"
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ SOCKET_win32=wsocket.obj
|
|||||||
#
|
#
|
||||||
SO=$(SO_$(PLAT))
|
SO=$(SO_$(PLAT))
|
||||||
O=$(O_$(PLAT))
|
O=$(O_$(PLAT))
|
||||||
SOCKET_V=2.1.1
|
SOCKET_V=2.1
|
||||||
MIME_V=1.0.3
|
MIME_V=1.0.3
|
||||||
SOCKET_SO=socket.$(SO).$(SOCKET_V)
|
SOCKET_SO=socket.$(SO).$(SOCKET_V)
|
||||||
MIME_SO=mime.$(SO).$(MIME_V)
|
MIME_SO=mime.$(SO).$(MIME_V)
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* MIME support functions
|
* MIME support functions
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
*
|
|
||||||
* RCS ID: $Id: mime.c,v 1.29 2009/05/27 09:31:35 diego Exp $
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
-- MIME support for the Lua language.
|
-- MIME support for the Lua language.
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- Conforming to RFCs 2045-2049
|
-- Conforming to RFCs 2045-2049
|
||||||
-- RCS ID: $Id: mime.lua,v 1.29 2007/06/11 23:44:54 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Common option interface
|
* Common option interface
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
*
|
|
||||||
* RCS ID: $Id: options.c,v 1.7 2009/05/27 09:31:35 diego Exp $
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Select implementation
|
* Select implementation
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
*
|
|
||||||
* RCS ID: $Id: select.c,v 1.23 2009/05/27 09:31:35 diego Exp $
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
-- SMTP client support for the Lua language.
|
-- SMTP client support for the Lua language.
|
||||||
-- LuaSocket toolkit.
|
-- LuaSocket toolkit.
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id: smtp.lua,v 1.47 2009/05/27 09:31:35 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- LuaSocket helper module
|
-- LuaSocket helper module
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id: socket.lua,v 1.22 2005/11/22 08:33:29 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
31
src/tcp.c
31
src/tcp.c
@ -1,8 +1,6 @@
|
|||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* TCP object
|
* TCP object
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
*
|
|
||||||
* RCS ID: $Id: tcp.c,v 1.42 2009/05/27 09:31:35 diego Exp $
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -23,6 +21,7 @@ static int global_create6(lua_State *L);
|
|||||||
static int global_connect6(lua_State *L);
|
static int global_connect6(lua_State *L);
|
||||||
static int meth_connect(lua_State *L);
|
static int meth_connect(lua_State *L);
|
||||||
static int meth_listen(lua_State *L);
|
static int meth_listen(lua_State *L);
|
||||||
|
static int meth_getfamily(lua_State *L);
|
||||||
static int meth_bind(lua_State *L);
|
static int meth_bind(lua_State *L);
|
||||||
static int meth_send(lua_State *L);
|
static int meth_send(lua_State *L);
|
||||||
static int meth_getstats(lua_State *L);
|
static int meth_getstats(lua_State *L);
|
||||||
@ -49,6 +48,7 @@ static luaL_Reg tcp_methods[] = {
|
|||||||
{"close", meth_close},
|
{"close", meth_close},
|
||||||
{"connect", meth_connect},
|
{"connect", meth_connect},
|
||||||
{"dirty", meth_dirty},
|
{"dirty", meth_dirty},
|
||||||
|
{"getfamily", meth_getfamily},
|
||||||
{"getfd", meth_getfd},
|
{"getfd", meth_getfd},
|
||||||
{"getoption", meth_getoption},
|
{"getoption", meth_getoption},
|
||||||
{"getpeername", meth_getpeername},
|
{"getpeername", meth_getpeername},
|
||||||
@ -218,7 +218,7 @@ static int meth_bind(lua_State *L)
|
|||||||
struct addrinfo bindhints;
|
struct addrinfo bindhints;
|
||||||
memset(&bindhints, 0, sizeof(bindhints));
|
memset(&bindhints, 0, sizeof(bindhints));
|
||||||
bindhints.ai_socktype = SOCK_STREAM;
|
bindhints.ai_socktype = SOCK_STREAM;
|
||||||
bindhints.ai_family = tcp->domain;
|
bindhints.ai_family = tcp->family;
|
||||||
bindhints.ai_flags = AI_PASSIVE;
|
bindhints.ai_flags = AI_PASSIVE;
|
||||||
err = inet_trybind(&tcp->sock, address, port, &bindhints);
|
err = inet_trybind(&tcp->sock, address, port, &bindhints);
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -243,7 +243,7 @@ static int meth_connect(lua_State *L)
|
|||||||
memset(&connecthints, 0, sizeof(connecthints));
|
memset(&connecthints, 0, sizeof(connecthints));
|
||||||
connecthints.ai_socktype = SOCK_STREAM;
|
connecthints.ai_socktype = SOCK_STREAM;
|
||||||
/* make sure we try to connect only to the same family */
|
/* make sure we try to connect only to the same family */
|
||||||
connecthints.ai_family = tcp->domain;
|
connecthints.ai_family = tcp->family;
|
||||||
timeout_markstart(&tcp->tm);
|
timeout_markstart(&tcp->tm);
|
||||||
err = inet_tryconnect(&tcp->sock, address, port,
|
err = inet_tryconnect(&tcp->sock, address, port,
|
||||||
&tcp->tm, &connecthints);
|
&tcp->tm, &connecthints);
|
||||||
@ -269,6 +269,21 @@ static int meth_close(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*\
|
||||||
|
* Returns family as string
|
||||||
|
\*-------------------------------------------------------------------------*/
|
||||||
|
static int meth_getfamily(lua_State *L)
|
||||||
|
{
|
||||||
|
p_tcp tcp = (p_tcp) auxiliar_checkgroup(L, "tcp{any}", 1);
|
||||||
|
if (tcp->family == PF_INET6) {
|
||||||
|
lua_pushliteral(L, "inet6");
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
lua_pushliteral(L, "inet4");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Puts the sockt in listen mode
|
* Puts the sockt in listen mode
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
@ -346,9 +361,9 @@ static int meth_settimeout(lua_State *L)
|
|||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Creates a master tcp object
|
* Creates a master tcp object
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
static int tcp_create(lua_State *L, int domain) {
|
static int tcp_create(lua_State *L, int family) {
|
||||||
t_socket sock;
|
t_socket sock;
|
||||||
const char *err = inet_trycreate(&sock, domain, SOCK_STREAM);
|
const char *err = inet_trycreate(&sock, family, SOCK_STREAM);
|
||||||
/* try to allocate a system socket */
|
/* try to allocate a system socket */
|
||||||
if (!err) {
|
if (!err) {
|
||||||
/* allocate tcp object */
|
/* allocate tcp object */
|
||||||
@ -357,7 +372,7 @@ static int tcp_create(lua_State *L, int domain) {
|
|||||||
auxiliar_setclass(L, "tcp{master}", -1);
|
auxiliar_setclass(L, "tcp{master}", -1);
|
||||||
/* initialize remaining structure fields */
|
/* initialize remaining structure fields */
|
||||||
socket_setnonblocking(&sock);
|
socket_setnonblocking(&sock);
|
||||||
if (domain == PF_INET6) {
|
if (family == PF_INET6) {
|
||||||
int yes = 1;
|
int yes = 1;
|
||||||
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
|
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
|
||||||
(void *)&yes, sizeof(yes));
|
(void *)&yes, sizeof(yes));
|
||||||
@ -367,7 +382,7 @@ static int tcp_create(lua_State *L, int domain) {
|
|||||||
(p_error) socket_ioerror, &tcp->sock);
|
(p_error) socket_ioerror, &tcp->sock);
|
||||||
timeout_init(&tcp->tm, -1, -1);
|
timeout_init(&tcp->tm, -1, -1);
|
||||||
buffer_init(&tcp->buf, &tcp->io, &tcp->tm);
|
buffer_init(&tcp->buf, &tcp->io, &tcp->tm);
|
||||||
tcp->domain = domain;
|
tcp->family = family;
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
|
@ -25,7 +25,7 @@ typedef struct t_tcp_ {
|
|||||||
t_io io;
|
t_io io;
|
||||||
t_buffer buf;
|
t_buffer buf;
|
||||||
t_timeout tm;
|
t_timeout tm;
|
||||||
int domain;
|
int family;
|
||||||
} t_tcp;
|
} t_tcp;
|
||||||
|
|
||||||
typedef t_tcp *p_tcp;
|
typedef t_tcp *p_tcp;
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Timeout management functions
|
* Timeout management functions
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
*
|
|
||||||
* RCS ID: $Id: timeout.c,v 1.31 2009/05/27 09:31:35 diego Exp $
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
-- Unified SMTP/FTP subsystem
|
-- Unified SMTP/FTP subsystem
|
||||||
-- LuaSocket toolkit.
|
-- LuaSocket toolkit.
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id: tp.lua,v 1.23 2009/05/27 09:31:35 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
31
src/udp.c
31
src/udp.c
@ -1,8 +1,6 @@
|
|||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* UDP object
|
* UDP object
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
*
|
|
||||||
* RCS ID: $Id: udp.c,v 1.30 2009/05/27 09:31:35 diego Exp $
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -32,6 +30,7 @@ static int meth_send(lua_State *L);
|
|||||||
static int meth_sendto(lua_State *L);
|
static int meth_sendto(lua_State *L);
|
||||||
static int meth_receive(lua_State *L);
|
static int meth_receive(lua_State *L);
|
||||||
static int meth_receivefrom(lua_State *L);
|
static int meth_receivefrom(lua_State *L);
|
||||||
|
static int meth_getfamily(lua_State *L);
|
||||||
static int meth_getsockname(lua_State *L);
|
static int meth_getsockname(lua_State *L);
|
||||||
static int meth_getpeername(lua_State *L);
|
static int meth_getpeername(lua_State *L);
|
||||||
static int meth_setsockname(lua_State *L);
|
static int meth_setsockname(lua_State *L);
|
||||||
@ -50,6 +49,7 @@ static luaL_Reg udp_methods[] = {
|
|||||||
{"__tostring", auxiliar_tostring},
|
{"__tostring", auxiliar_tostring},
|
||||||
{"close", meth_close},
|
{"close", meth_close},
|
||||||
{"dirty", meth_dirty},
|
{"dirty", meth_dirty},
|
||||||
|
{"getfamily", meth_getfamily},
|
||||||
{"getfd", meth_getfd},
|
{"getfd", meth_getfd},
|
||||||
{"getpeername", meth_getpeername},
|
{"getpeername", meth_getpeername},
|
||||||
{"getsockname", meth_getsockname},
|
{"getsockname", meth_getsockname},
|
||||||
@ -226,6 +226,21 @@ static int meth_receivefrom(lua_State *L) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------------------------------------------*\
|
||||||
|
* Returns family as string
|
||||||
|
\*-------------------------------------------------------------------------*/
|
||||||
|
static int meth_getfamily(lua_State *L)
|
||||||
|
{
|
||||||
|
p_udp udp = (p_udp) auxiliar_checkgroup(L, "udp{any}", 1);
|
||||||
|
if (udp->family == PF_INET6) {
|
||||||
|
lua_pushliteral(L, "inet6");
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
lua_pushliteral(L, "inet4");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Select support methods
|
* Select support methods
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
@ -302,7 +317,7 @@ static int meth_setpeername(lua_State *L) {
|
|||||||
memset(&connecthints, 0, sizeof(connecthints));
|
memset(&connecthints, 0, sizeof(connecthints));
|
||||||
connecthints.ai_socktype = SOCK_DGRAM;
|
connecthints.ai_socktype = SOCK_DGRAM;
|
||||||
/* make sure we try to connect only to the same family */
|
/* make sure we try to connect only to the same family */
|
||||||
connecthints.ai_family = udp->domain;
|
connecthints.ai_family = udp->family;
|
||||||
err = inet_tryconnect(&udp->sock, address, port,
|
err = inet_tryconnect(&udp->sock, address, port,
|
||||||
tm, &connecthints);
|
tm, &connecthints);
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -338,7 +353,7 @@ static int meth_setsockname(lua_State *L) {
|
|||||||
struct addrinfo bindhints;
|
struct addrinfo bindhints;
|
||||||
memset(&bindhints, 0, sizeof(bindhints));
|
memset(&bindhints, 0, sizeof(bindhints));
|
||||||
bindhints.ai_socktype = SOCK_DGRAM;
|
bindhints.ai_socktype = SOCK_DGRAM;
|
||||||
bindhints.ai_family = udp->domain;
|
bindhints.ai_family = udp->family;
|
||||||
bindhints.ai_flags = AI_PASSIVE;
|
bindhints.ai_flags = AI_PASSIVE;
|
||||||
err = inet_trybind(&udp->sock, address, port, &bindhints);
|
err = inet_trybind(&udp->sock, address, port, &bindhints);
|
||||||
if (err) {
|
if (err) {
|
||||||
@ -356,9 +371,9 @@ static int meth_setsockname(lua_State *L) {
|
|||||||
/*-------------------------------------------------------------------------*\
|
/*-------------------------------------------------------------------------*\
|
||||||
* Creates a master udp object
|
* Creates a master udp object
|
||||||
\*-------------------------------------------------------------------------*/
|
\*-------------------------------------------------------------------------*/
|
||||||
static int udp_create(lua_State *L, int domain) {
|
static int udp_create(lua_State *L, int family) {
|
||||||
t_socket sock;
|
t_socket sock;
|
||||||
const char *err = inet_trycreate(&sock, domain, SOCK_DGRAM);
|
const char *err = inet_trycreate(&sock, family, SOCK_DGRAM);
|
||||||
/* try to allocate a system socket */
|
/* try to allocate a system socket */
|
||||||
if (!err) {
|
if (!err) {
|
||||||
/* allocate udp object */
|
/* allocate udp object */
|
||||||
@ -366,14 +381,14 @@ static int udp_create(lua_State *L, int domain) {
|
|||||||
auxiliar_setclass(L, "udp{unconnected}", -1);
|
auxiliar_setclass(L, "udp{unconnected}", -1);
|
||||||
/* initialize remaining structure fields */
|
/* initialize remaining structure fields */
|
||||||
socket_setnonblocking(&sock);
|
socket_setnonblocking(&sock);
|
||||||
if (domain == PF_INET6) {
|
if (family == PF_INET6) {
|
||||||
int yes = 1;
|
int yes = 1;
|
||||||
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
|
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
|
||||||
(void *)&yes, sizeof(yes));
|
(void *)&yes, sizeof(yes));
|
||||||
}
|
}
|
||||||
udp->sock = sock;
|
udp->sock = sock;
|
||||||
timeout_init(&udp->tm, -1, -1);
|
timeout_init(&udp->tm, -1, -1);
|
||||||
udp->domain = domain;
|
udp->family = family;
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
lua_pushnil(L);
|
lua_pushnil(L);
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
typedef struct t_udp_ {
|
typedef struct t_udp_ {
|
||||||
t_socket sock;
|
t_socket sock;
|
||||||
t_timeout tm;
|
t_timeout tm;
|
||||||
int domain;
|
int family;
|
||||||
} t_udp;
|
} t_udp;
|
||||||
typedef t_udp *p_udp;
|
typedef t_udp *p_udp;
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
/*=========================================================================*\
|
/*=========================================================================*\
|
||||||
* Unix domain socket
|
* Unix domain socket
|
||||||
* LuaSocket toolkit
|
* LuaSocket toolkit
|
||||||
*
|
|
||||||
* RCS ID: $Id: unix.c,v 1.14 2009/05/27 09:31:35 diego Exp $
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
15
src/url.lua
15
src/url.lua
@ -2,7 +2,6 @@
|
|||||||
-- URI parsing, composition and relative URL resolution
|
-- URI parsing, composition and relative URL resolution
|
||||||
-- LuaSocket toolkit.
|
-- LuaSocket toolkit.
|
||||||
-- Author: Diego Nehab
|
-- Author: Diego Nehab
|
||||||
-- RCS ID: $Id: url.lua,v 1.38 2006/04/03 04:45:42 diego Exp $
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
@ -16,7 +15,7 @@ module("socket.url")
|
|||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- Module version
|
-- Module version
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
_VERSION = "URL 1.0.1"
|
_VERSION = "URL 1.0.2"
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
-- Encodes a string into its escaped hexadecimal representation
|
-- Encodes a string into its escaped hexadecimal representation
|
||||||
@ -142,7 +141,7 @@ function parse(url, default)
|
|||||||
parsed.authority = n
|
parsed.authority = n
|
||||||
return ""
|
return ""
|
||||||
end)
|
end)
|
||||||
-- get query stringing
|
-- get query string
|
||||||
url = string.gsub(url, "%?(.*)", function(q)
|
url = string.gsub(url, "%?(.*)", function(q)
|
||||||
parsed.query = q
|
parsed.query = q
|
||||||
return ""
|
return ""
|
||||||
@ -158,9 +157,12 @@ function parse(url, default)
|
|||||||
if not authority then return parsed end
|
if not authority then return parsed end
|
||||||
authority = string.gsub(authority,"^([^@]*)@",
|
authority = string.gsub(authority,"^([^@]*)@",
|
||||||
function(u) parsed.userinfo = u; return "" end)
|
function(u) parsed.userinfo = u; return "" end)
|
||||||
authority = string.gsub(authority, ":([^:]*)$",
|
authority = string.gsub(authority, ":([^:%]]*)$",
|
||||||
function(p) parsed.port = p; return "" end)
|
function(p) parsed.port = p; return "" end)
|
||||||
if authority ~= "" then parsed.host = authority end
|
if authority ~= "" then
|
||||||
|
-- IPv6?
|
||||||
|
parsed.host = string.match(authority, "^%[(.+)%]$") or authority
|
||||||
|
end
|
||||||
local userinfo = parsed.userinfo
|
local userinfo = parsed.userinfo
|
||||||
if not userinfo then return parsed end
|
if not userinfo then return parsed end
|
||||||
userinfo = string.gsub(userinfo, ":([^:]*)$",
|
userinfo = string.gsub(userinfo, ":([^:]*)$",
|
||||||
@ -185,6 +187,9 @@ function build(parsed)
|
|||||||
local authority = parsed.authority
|
local authority = parsed.authority
|
||||||
if parsed.host then
|
if parsed.host then
|
||||||
authority = parsed.host
|
authority = parsed.host
|
||||||
|
if string.find(authority, ":") then -- IPv6?
|
||||||
|
authority = "[" .. authority .. "]"
|
||||||
|
end
|
||||||
if parsed.port then authority = authority .. ":" .. parsed.port end
|
if parsed.port then authority = authority .. ":" .. parsed.port end
|
||||||
local userinfo = parsed.userinfo
|
local userinfo = parsed.userinfo
|
||||||
if parsed.user then
|
if parsed.user then
|
||||||
|
@ -5,8 +5,6 @@
|
|||||||
* The code is now interrupt-safe.
|
* The code is now interrupt-safe.
|
||||||
* The penalty of calling select to avoid busy-wait is only paid when
|
* The penalty of calling select to avoid busy-wait is only paid when
|
||||||
* the I/O call fail in the first place.
|
* the I/O call fail in the first place.
|
||||||
*
|
|
||||||
* RCS ID: $Id: usocket.c,v 1.38 2007/10/13 23:55:20 diego Exp $
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
*
|
*
|
||||||
* The penalty of calling select to avoid busy-wait is only paid when
|
* The penalty of calling select to avoid busy-wait is only paid when
|
||||||
* the I/O call fail in the first place.
|
* the I/O call fail in the first place.
|
||||||
*
|
|
||||||
* RCS ID: $Id: wsocket.c,v 1.36 2007/06/11 23:44:54 diego Exp $
|
|
||||||
\*=========================================================================*/
|
\*=========================================================================*/
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
131
test/urltest.lua
131
test/urltest.lua
@ -8,7 +8,7 @@ local check_build_url = function(parsed)
|
|||||||
print("built is different from expected")
|
print("built is different from expected")
|
||||||
print(built)
|
print(built)
|
||||||
print(expected)
|
print(expected)
|
||||||
exit()
|
os.exit()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ local check_protect = function(parsed, path, unsafe)
|
|||||||
if built ~= path then
|
if built ~= path then
|
||||||
print(built, path)
|
print(built, path)
|
||||||
print("path composition failed.")
|
print("path composition failed.")
|
||||||
exit()
|
os.exit()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ local check_invert = function(url)
|
|||||||
if rebuilt ~= url then
|
if rebuilt ~= url then
|
||||||
print(url, rebuilt)
|
print(url, rebuilt)
|
||||||
print("original and rebuilt are different")
|
print("original and rebuilt are different")
|
||||||
exit()
|
os.exit()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -37,24 +37,24 @@ local check_parse_path = function(path, expect)
|
|||||||
for i = 1, math.max(table.getn(parsed), table.getn(expect)) do
|
for i = 1, math.max(table.getn(parsed), table.getn(expect)) do
|
||||||
if parsed[i] ~= expect[i] then
|
if parsed[i] ~= expect[i] then
|
||||||
print(path)
|
print(path)
|
||||||
exit()
|
os.exit()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if expect.is_directory ~= parsed.is_directory then
|
if expect.is_directory ~= parsed.is_directory then
|
||||||
print(path)
|
print(path)
|
||||||
print("is_directory mismatch")
|
print("is_directory mismatch")
|
||||||
exit()
|
os.exit()
|
||||||
end
|
end
|
||||||
if expect.is_absolute ~= parsed.is_absolute then
|
if expect.is_absolute ~= parsed.is_absolute then
|
||||||
print(path)
|
print(path)
|
||||||
print("is_absolute mismatch")
|
print("is_absolute mismatch")
|
||||||
exit()
|
os.exit()
|
||||||
end
|
end
|
||||||
local built = socket.url.build_path(expect)
|
local built = socket.url.build_path(expect)
|
||||||
if built ~= path then
|
if built ~= path then
|
||||||
print(built, path)
|
print(built, path)
|
||||||
print("path composition failed.")
|
print("path composition failed.")
|
||||||
exit()
|
os.exit()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ local check_absolute_url = function(base, relative, absolute)
|
|||||||
if res ~= absolute then
|
if res ~= absolute then
|
||||||
io.write("absolute: In test for '", relative, "' expected '",
|
io.write("absolute: In test for '", relative, "' expected '",
|
||||||
absolute, "' but got '", res, "'\n")
|
absolute, "' but got '", res, "'\n")
|
||||||
exit()
|
os.exit()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ local check_parse_url = function(gaba)
|
|||||||
io.write("parse: In test for '", url, "' expected ", i, " = '",
|
io.write("parse: In test for '", url, "' expected ", i, " = '",
|
||||||
v, "' but got '", tostring(parsed[i]), "'\n")
|
v, "' but got '", tostring(parsed[i]), "'\n")
|
||||||
for i,v in pairs(parsed) do print(i,v) end
|
for i,v in pairs(parsed) do print(i,v) end
|
||||||
exit()
|
os.exit()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for i, v in pairs(parsed) do
|
for i, v in pairs(parsed) do
|
||||||
@ -84,7 +84,7 @@ local check_parse_url = function(gaba)
|
|||||||
io.write("parse: In test for '", url, "' expected ", i, " = '",
|
io.write("parse: In test for '", url, "' expected ", i, " = '",
|
||||||
tostring(gaba[i]), "' but got '", v, "'\n")
|
tostring(gaba[i]), "' but got '", v, "'\n")
|
||||||
for i,v in pairs(parsed) do print(i,v) end
|
for i,v in pairs(parsed) do print(i,v) end
|
||||||
exit()
|
os.exit()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -304,6 +304,92 @@ check_parse_url{
|
|||||||
path = "path",
|
path = "path",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- IPv6 tests
|
||||||
|
|
||||||
|
check_parse_url{
|
||||||
|
url = "http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html",
|
||||||
|
scheme = "http",
|
||||||
|
host = "FEDC:BA98:7654:3210:FEDC:BA98:7654:3210",
|
||||||
|
authority = "[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80",
|
||||||
|
port = "80",
|
||||||
|
path = "/index.html"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_parse_url{
|
||||||
|
url = "http://[1080:0:0:0:8:800:200C:417A]/index.html",
|
||||||
|
scheme = "http",
|
||||||
|
host = "1080:0:0:0:8:800:200C:417A",
|
||||||
|
authority = "[1080:0:0:0:8:800:200C:417A]",
|
||||||
|
path = "/index.html"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_parse_url{
|
||||||
|
url = "http://[3ffe:2a00:100:7031::1]",
|
||||||
|
scheme = "http",
|
||||||
|
host = "3ffe:2a00:100:7031::1",
|
||||||
|
authority = "[3ffe:2a00:100:7031::1]",
|
||||||
|
}
|
||||||
|
|
||||||
|
check_parse_url{
|
||||||
|
url = "http://[1080::8:800:200C:417A]/foo",
|
||||||
|
scheme = "http",
|
||||||
|
host = "1080::8:800:200C:417A",
|
||||||
|
authority = "[1080::8:800:200C:417A]",
|
||||||
|
path = "/foo"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_parse_url{
|
||||||
|
url = "http://[::192.9.5.5]/ipng",
|
||||||
|
scheme = "http",
|
||||||
|
host = "::192.9.5.5",
|
||||||
|
authority = "[::192.9.5.5]",
|
||||||
|
path = "/ipng"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_parse_url{
|
||||||
|
url = "http://[::FFFF:129.144.52.38]:80/index.html",
|
||||||
|
scheme = "http",
|
||||||
|
host = "::FFFF:129.144.52.38",
|
||||||
|
port = "80",
|
||||||
|
authority = "[::FFFF:129.144.52.38]:80",
|
||||||
|
path = "/index.html"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_parse_url{
|
||||||
|
url = "http://[2010:836B:4179::836B:4179]",
|
||||||
|
scheme = "http",
|
||||||
|
host = "2010:836B:4179::836B:4179",
|
||||||
|
authority = "[2010:836B:4179::836B:4179]",
|
||||||
|
}
|
||||||
|
|
||||||
|
check_parse_url{
|
||||||
|
url = "//userinfo@[::FFFF:129.144.52.38]:port/path;params?query#fragment",
|
||||||
|
authority = "userinfo@[::FFFF:129.144.52.38]:port",
|
||||||
|
host = "::FFFF:129.144.52.38",
|
||||||
|
port = "port",
|
||||||
|
userinfo = "userinfo",
|
||||||
|
user = "userinfo",
|
||||||
|
path = "/path",
|
||||||
|
params = "params",
|
||||||
|
query = "query",
|
||||||
|
fragment = "fragment"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_parse_url{
|
||||||
|
url = "scheme://user:password@[::192.9.5.5]:port/path;params?query#fragment",
|
||||||
|
scheme = "scheme",
|
||||||
|
authority = "user:password@[::192.9.5.5]:port",
|
||||||
|
host = "::192.9.5.5",
|
||||||
|
port = "port",
|
||||||
|
userinfo = "user:password",
|
||||||
|
user = "user",
|
||||||
|
password = "password",
|
||||||
|
path = "/path",
|
||||||
|
params = "params",
|
||||||
|
query = "query",
|
||||||
|
fragment = "fragment"
|
||||||
|
}
|
||||||
|
|
||||||
print("testing URL building")
|
print("testing URL building")
|
||||||
check_build_url {
|
check_build_url {
|
||||||
url = "scheme://user:password@host:port/path;params?query#fragment",
|
url = "scheme://user:password@host:port/path;params?query#fragment",
|
||||||
@ -318,6 +404,30 @@ check_build_url {
|
|||||||
fragment = "fragment"
|
fragment = "fragment"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_build_url{
|
||||||
|
url = "//userinfo@[::FFFF:129.144.52.38]:port/path;params?query#fragment",
|
||||||
|
host = "::FFFF:129.144.52.38",
|
||||||
|
port = "port",
|
||||||
|
user = "userinfo",
|
||||||
|
path = "/path",
|
||||||
|
params = "params",
|
||||||
|
query = "query",
|
||||||
|
fragment = "fragment"
|
||||||
|
}
|
||||||
|
|
||||||
|
check_build_url{
|
||||||
|
url = "scheme://user:password@[::192.9.5.5]:port/path;params?query#fragment",
|
||||||
|
scheme = "scheme",
|
||||||
|
host = "::192.9.5.5",
|
||||||
|
port = "port",
|
||||||
|
user = "user",
|
||||||
|
password = "password",
|
||||||
|
path = "/path",
|
||||||
|
params = "params",
|
||||||
|
query = "query",
|
||||||
|
fragment = "fragment"
|
||||||
|
}
|
||||||
|
|
||||||
check_build_url {
|
check_build_url {
|
||||||
url = "scheme://user:password@host/path;params?query#fragment",
|
url = "scheme://user:password@host/path;params?query#fragment",
|
||||||
scheme = "scheme",
|
scheme = "scheme",
|
||||||
@ -520,5 +630,6 @@ check_invert("/b/c/d;param#fragment")
|
|||||||
check_invert("/b/c/d;param?query#fragment")
|
check_invert("/b/c/d;param?query#fragment")
|
||||||
check_invert("/b/c/d?query")
|
check_invert("/b/c/d?query")
|
||||||
check_invert("/b/c/d;param?query")
|
check_invert("/b/c/d;param?query")
|
||||||
|
check_invert("http://he:man@[::192.168.1.1]/a/b/c/i.html;type=moo?this=that#mark")
|
||||||
|
|
||||||
print("the library passed all tests")
|
print("the library passed all tests")
|
||||||
|
Loading…
Reference in New Issue
Block a user