author | Myhailo Danylenko <isbear@ukrpost.net> |
Wed, 16 Mar 2016 01:53:56 +0200 | |
changeset 66 | a40beb82130c |
parent 59 | 19cfaceda6bb |
permissions | -rw-r--r-- |
59
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
1 |
--[[ Copyright 2009-2016 Myhailo Danylenko |
23 | 2 |
|
3 |
This program is free software: you can redistribute it and/or modify |
|
4 |
it under the terms of the GNU General Public License as published by |
|
5 |
the Free Software Foundation, either version 2 of the License, or |
|
6 |
(at your option) any later version. |
|
7 |
||
8 |
This program is distributed in the hope that it will be useful, |
|
9 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 |
GNU General Public License for more details. |
|
12 |
||
13 |
You should have received a copy of the GNU General Public License |
|
14 |
along with this program. If not, see <http://www.gnu.org/licenses/>. ]] |
|
0 | 15 |
|
16
09b375e9ce32
Switch to new module organization scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
12
diff
changeset
|
16 |
local lm = require 'loudmouth' |
0 | 17 |
|
59
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
18 |
-- Argument is a table with keys: |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
19 |
-- * server - server name to connect to |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
20 |
-- * port - port to connect to |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
21 |
-- * type - proxy type |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
22 |
-- * username - uername to authenticate on proxy |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
23 |
-- * password - password to authenticate with |
0 | 24 |
function lm.proxy.create ( a ) |
25 |
if type ( a ) ~= "table" then |
|
6
90073cbb535d
Logging and chained methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
26 |
error "arguments should be in a table" |
0 | 27 |
end |
28 |
local p = lm.proxy.new () |
|
29 |
if a.server then |
|
30 |
p:server ( a.server ) |
|
31 |
end |
|
32 |
if a.port then |
|
33 |
p:port ( a.port ) |
|
34 |
end |
|
35 |
if a['type'] then |
|
36 |
p:type ( a['type'] ) |
|
37 |
end |
|
38 |
if a.username then |
|
39 |
p:username ( a.username ) |
|
40 |
end |
|
41 |
if a.password then |
|
42 |
p:password ( a.password ) |
|
43 |
end |
|
44 |
return p |
|
45 |
end |
|
46 |
||
59
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
47 |
-- Argument is a table with keys: |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
48 |
-- * fingerprint - fingerprint string |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
49 |
-- * callback - ssl error callback |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
50 |
-- * tls - string - one of "on", "required", "off" (default) |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
51 |
-- * ca_path - path to trusted certificates |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
52 |
-- * cipher_list - list of allowed ciphers to ues |
0 | 53 |
function lm.ssl.create ( a ) |
54 |
if not lm.ssl.supported () then |
|
55 |
-- XXX |
|
6
90073cbb535d
Logging and chained methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
56 |
-- error "ssl is not supported by your loudmouth library" |
0 | 57 |
return nil |
58 |
end |
|
59
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
59 |
local fp, cb, ut, rt, ca, cl |
0 | 60 |
local st = type ( a ) |
61 |
if st == "table" then |
|
62 |
fp = a.fingerprint |
|
63 |
cb = a.callback |
|
59
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
64 |
ca = a.ca_path |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
65 |
cl = a.cipher_list |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
66 |
tl = a.tls |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
67 |
if tl ~= nil then |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
68 |
if tl == "on" then |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
69 |
ut = true |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
70 |
rt = false |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
71 |
elseif tl == "required" then |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
72 |
ut = true |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
73 |
rt = true |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
74 |
end |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
75 |
end |
0 | 76 |
elseif st == "function" then |
77 |
cb = a |
|
78 |
elseif st == "string" then |
|
79 |
fp = a |
|
80 |
elseif st ~= "nil" then |
|
6
90073cbb535d
Logging and chained methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
81 |
error "unexpected type of argument" |
0 | 82 |
end |
42 | 83 |
local ssl |
0 | 84 |
if fp then |
85 |
if cb then |
|
42 | 86 |
ssl = lm.ssl.new ( fp, cb ) |
0 | 87 |
else |
42 | 88 |
ssl = lm.ssl.new ( fp ) |
0 | 89 |
end |
90 |
else |
|
91 |
if cb then |
|
42 | 92 |
ssl = lm.ssl.new ( cb ) |
0 | 93 |
else |
42 | 94 |
ssl = lm.ssl.new () |
0 | 95 |
end |
96 |
end |
|
59
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
97 |
if ca ~= nil then |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
98 |
ssl:ca_path ( ca ) |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
99 |
end |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
100 |
if cl ~= nil then |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
101 |
ssl:cipher_list ( cl ) |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
102 |
end |
42 | 103 |
if ut ~= nil then |
104 |
ssl:tls ( ut, rt ) |
|
105 |
end |
|
106 |
return ssl |
|
0 | 107 |
end |
108 |
||
59
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
109 |
-- Argument is a table with keys: |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
110 |
-- * server - server name |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
111 |
-- * context - glib main context |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
112 |
-- * port - server port |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
113 |
-- * jid - jid to connect with |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
114 |
-- * keep_alive_rate - rate of keep alive packets |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
115 |
-- * proxy - lm.proxy object or table |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
116 |
-- * ssl - lm.ssl object or table |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
117 |
-- * ondisconnect - disconnect callback |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
118 |
-- * handlers - table with { "type/priority" = function/object } mapping |
0 | 119 |
function lm.connection.create ( a ) |
120 |
local at = type (a) |
|
121 |
if at == "string" then |
|
122 |
return lm.connection.new ( a ) |
|
123 |
elseif at == "table" then |
|
124 |
local server = a.server |
|
125 |
if not server then |
|
6
90073cbb535d
Logging and chained methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
126 |
error "server name parameter required" |
0 | 127 |
end |
128 |
||
129 |
-- create connection object |
|
130 |
local c |
|
131 |
if a.context then |
|
132 |
c = lm.connection.new ( server, a.context ) |
|
133 |
else |
|
134 |
c = lm.connection.new ( server ) |
|
135 |
end |
|
136 |
||
137 |
-- connection parameters |
|
138 |
if a.port then |
|
139 |
c:port ( a.port ) |
|
140 |
end |
|
141 |
if a.jid then |
|
142 |
c:jid ( a.jid ) |
|
143 |
end |
|
144 |
if a.keep_alive_rate then |
|
145 |
c:keep_alive_rate ( a.keep_alive_rate ) |
|
146 |
end |
|
147 |
||
148 |
-- proxy |
|
149 |
if a.proxy then |
|
150 |
local pt = type ( a.proxy ) |
|
151 |
if pt == "userdata" then |
|
152 |
c:proxy ( a.proxy ) |
|
153 |
else |
|
154 |
local proxy = lm.proxy.create ( a.proxy ) |
|
155 |
c:proxy ( proxy ) |
|
156 |
end |
|
157 |
end |
|
158 |
||
159 |
-- ssl |
|
160 |
if a.ssl then |
|
161 |
local st = type ( a.ssl ) |
|
162 |
if st == "userdata" then |
|
163 |
c:ssl ( a.ssl ) |
|
164 |
else |
|
165 |
local ssl = lm.ssl.create ( a.ssl ) |
|
166 |
c:ssl ( ssl ) |
|
167 |
end |
|
168 |
end |
|
169 |
||
170 |
-- disconnect callback |
|
171 |
if a.ondisconnect then |
|
172 |
c:ondisconnect ( a.ondisconnect ) |
|
173 |
end |
|
174 |
||
175 |
-- message handlers |
|
176 |
if a.handlers then |
|
177 |
if type ( a.handlers ) ~= "table" then |
|
178 |
error ( "handlers parameter expected to be a table " .. |
|
179 |
"of the form { \"type/priority\" = function/object }" ) |
|
180 |
end |
|
181 |
for mhtype, handler in pairs ( a.handlers ) do |
|
182 |
local mtype, prio = mhtype:match ( "(.-)/(%d+)" ) |
|
183 |
if not mtype then |
|
184 |
mtype = mhtype |
|
185 |
prio = 0 |
|
186 |
else |
|
187 |
prio = tonumber ( prio ) |
|
188 |
end |
|
189 |
c:handler ( handler, mtype, prio ) |
|
190 |
end |
|
191 |
end |
|
192 |
||
193 |
return c |
|
194 |
else |
|
7
5db1448eb857
Message have node methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
6
diff
changeset
|
195 |
error "at least server name parameter required" |
0 | 196 |
end |
197 |
end |
|
198 |
||
66
a40beb82130c
node: Use new loudmouth feature - public attribute list (v0.9.7)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
59
diff
changeset
|
199 |
function lm.message_node.parse ( node ) |
a40beb82130c
node: Use new loudmouth feature - public attribute list (v0.9.7)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
59
diff
changeset
|
200 |
-- attributes |
a40beb82130c
node: Use new loudmouth feature - public attribute list (v0.9.7)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
59
diff
changeset
|
201 |
local r = node:attributes () |
a40beb82130c
node: Use new loudmouth feature - public attribute list (v0.9.7)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
59
diff
changeset
|
202 |
-- node value (text) |
a40beb82130c
node: Use new loudmouth feature - public attribute list (v0.9.7)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
59
diff
changeset
|
203 |
local value = n:value () |
a40beb82130c
node: Use new loudmouth feature - public attribute list (v0.9.7)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
59
diff
changeset
|
204 |
if value then |
a40beb82130c
node: Use new loudmouth feature - public attribute list (v0.9.7)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
59
diff
changeset
|
205 |
s[1] = value |
a40beb82130c
node: Use new loudmouth feature - public attribute list (v0.9.7)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
59
diff
changeset
|
206 |
end |
a40beb82130c
node: Use new loudmouth feature - public attribute list (v0.9.7)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
59
diff
changeset
|
207 |
-- children nodes |
18
6effa1929af7
Children node method removed
Myhailo Danylenko <isbear@ukrpost.net>
parents:
17
diff
changeset
|
208 |
local n = node:child () |
66
a40beb82130c
node: Use new loudmouth feature - public attribute list (v0.9.7)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
59
diff
changeset
|
209 |
for n in node:children () do |
0 | 210 |
local name = n:name () |
66
a40beb82130c
node: Use new loudmouth feature - public attribute list (v0.9.7)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
59
diff
changeset
|
211 |
if type ( r[name] ) ~= 'table' then |
a40beb82130c
node: Use new loudmouth feature - public attribute list (v0.9.7)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
59
diff
changeset
|
212 |
r[name] = { } |
0 | 213 |
end |
66
a40beb82130c
node: Use new loudmouth feature - public attribute list (v0.9.7)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
59
diff
changeset
|
214 |
table.insert ( r[name], lm.message_node.parse ( n ) ) |
0 | 215 |
end |
66
a40beb82130c
node: Use new loudmouth feature - public attribute list (v0.9.7)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
59
diff
changeset
|
216 |
return r |
0 | 217 |
end |
218 |
||
219 |
function lm.message.parse ( message ) |
|
66
a40beb82130c
node: Use new loudmouth feature - public attribute list (v0.9.7)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
59
diff
changeset
|
220 |
local r = lm.message_node.parse ( message ) |
a40beb82130c
node: Use new loudmouth feature - public attribute list (v0.9.7)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
59
diff
changeset
|
221 |
-- message type we treat in a special way |
0 | 222 |
local mtype, subtype = message:type () |
223 |
if subtype then |
|
224 |
mtype = mtype .. '-' .. subtype |
|
225 |
end |
|
66
a40beb82130c
node: Use new loudmouth feature - public attribute list (v0.9.7)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
59
diff
changeset
|
226 |
r['mtype'] = mtype |
0 | 227 |
return r |
228 |
end |
|
229 |
||
59
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
230 |
-- The same table, as for lm.connection.create, but with few more fields: |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
231 |
-- * ssl.validate - boolean |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
232 |
-- * preopen - callback to call after connection creation but before opening (to install log handler, for example) |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
233 |
-- * onopen - callback to call after connection is established, but before authentication |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
234 |
-- * onconnect - callback to call after connection will be established |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
235 |
-- * username - username to authenticate with |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
236 |
-- * password - password to authenticate with |
19cfaceda6bb
ssl: Add ssl:ca_path and ssl:cipher_list methods (v0.9.4)
Myhailo Danylenko <isbear@ukrpost.net>
parents:
46
diff
changeset
|
237 |
-- * resource - jabber resource to use |
0 | 238 |
function lm.connect ( a ) |
239 |
if type ( a ) ~= "table" then |
|
6
90073cbb535d
Logging and chained methods
Myhailo Danylenko <isbear@ukrpost.net>
parents:
0
diff
changeset
|
240 |
error "table expected as argument" |
0 | 241 |
end |
242 |
if a.ssl then |
|
243 |
if a.ssl.validate and not a.ssl.callback then |
|
244 |
a.ssl.callback = |
|
245 |
function ( obj, status ) |
|
246 |
return false |
|
247 |
end |
|
248 |
end |
|
249 |
end |
|
250 |
local c = lm.connection.create ( a ) |
|
36
41df6f2a7aa8
Add preconnect hook to lm.connect
Myhailo Danylenko <isbear@ukrpost.net>
parents:
23
diff
changeset
|
251 |
if type ( a.preopen ) == "function" then |
41df6f2a7aa8
Add preconnect hook to lm.connect
Myhailo Danylenko <isbear@ukrpost.net>
parents:
23
diff
changeset
|
252 |
a.preopen ( c ) -- XXX |
41df6f2a7aa8
Add preconnect hook to lm.connect
Myhailo Danylenko <isbear@ukrpost.net>
parents:
23
diff
changeset
|
253 |
end |
0 | 254 |
c:open ( |
255 |
function ( obj, status ) |
|
256 |
if status then |
|
257 |
if type ( a.onopen ) == "function" then |
|
258 |
a.onopen ( obj ) |
|
259 |
end |
|
260 |
c:authenticate ( a.username, a.password, a.resource, |
|
261 |
function ( obj, status ) |
|
262 |
if type ( a.onconnect ) == "function" then |
|
263 |
a.onconnect ( obj ) |
|
264 |
end |
|
265 |
end ) |
|
266 |
end |
|
267 |
end ) |
|
268 |
return c |
|
269 |
end |
|
270 |
||
16
09b375e9ce32
Switch to new module organization scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
12
diff
changeset
|
271 |
return lm |
09b375e9ce32
Switch to new module organization scheme
Myhailo Danylenko <isbear@ukrpost.net>
parents:
12
diff
changeset
|
272 |
|
36
41df6f2a7aa8
Add preconnect hook to lm.connect
Myhailo Danylenko <isbear@ukrpost.net>
parents:
23
diff
changeset
|
273 |
-- vim: se ts=4 sw=4: -- |