Sat, 10 Apr 2021 00:28:05 +0200
clix.raw: Allow unsandboxed arbitrary code execution
Useful for doing things to clix/verse internals
135
c8cad3c42f3d
clix.raw: Import verse, don't rely on globals
Kim Alvefur <zash@zash.se>
parents:
134
diff
changeset
|
1 | local verse = require "verse"; |
150
af9b9acb10d6
clix.raw: Track and print response to iq stanza given as cli argument
Kim Alvefur <zash@zash.se>
parents:
149
diff
changeset
|
2 | local xml = require "util.xml"; |
19
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 | short_opts.i = "interactive"; |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 | short_opts.e = "echo"; |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 | |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 | return function (opts, args) |
27
5b58c002d6ad
clix.*: Add --short-help and make sure they are working correctly
Matthew Wild <mwild1@gmail.com>
parents:
23
diff
changeset
|
7 | if opts.short_help then |
5b58c002d6ad
clix.*: Add --short-help and make sure they are working correctly
Matthew Wild <mwild1@gmail.com>
parents:
23
diff
changeset
|
8 | print("Send/receive raw XML to/from the server"); |
5b58c002d6ad
clix.*: Add --short-help and make sure they are working correctly
Matthew Wild <mwild1@gmail.com>
parents:
23
diff
changeset
|
9 | return; |
5b58c002d6ad
clix.*: Add --short-help and make sure they are working correctly
Matthew Wild <mwild1@gmail.com>
parents:
23
diff
changeset
|
10 | end |
46
b5d6e443e571
raw: If using --stdin and not --interactive then buffer all data before connecting, more reliable in a non-interactive environment
Matthew Wild <mwild1@gmail.com>
parents:
27
diff
changeset
|
11 | |
b5d6e443e571
raw: If using --stdin and not --interactive then buffer all data before connecting, more reliable in a non-interactive environment
Matthew Wild <mwild1@gmail.com>
parents:
27
diff
changeset
|
12 | local send_xml; |
b5d6e443e571
raw: If using --stdin and not --interactive then buffer all data before connecting, more reliable in a non-interactive environment
Matthew Wild <mwild1@gmail.com>
parents:
27
diff
changeset
|
13 | if opts.stdin then |
b5d6e443e571
raw: If using --stdin and not --interactive then buffer all data before connecting, more reliable in a non-interactive environment
Matthew Wild <mwild1@gmail.com>
parents:
27
diff
changeset
|
14 | send_xml = io.read("*a"); |
b5d6e443e571
raw: If using --stdin and not --interactive then buffer all data before connecting, more reliable in a non-interactive environment
Matthew Wild <mwild1@gmail.com>
parents:
27
diff
changeset
|
15 | end |
b5d6e443e571
raw: If using --stdin and not --interactive then buffer all data before connecting, more reliable in a non-interactive environment
Matthew Wild <mwild1@gmail.com>
parents:
27
diff
changeset
|
16 | |
19
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 | local function on_connect(conn) |
83
040fadcc86f9
clix.raw: Print one incoming stanza per line, instead of raw incoming data.
Kim Alvefur <zash@zash.se>
parents:
68
diff
changeset
|
18 | local print = print; |
040fadcc86f9
clix.raw: Print one incoming stanza per line, instead of raw incoming data.
Kim Alvefur <zash@zash.se>
parents:
68
diff
changeset
|
19 | local function stprint(stanza) |
040fadcc86f9
clix.raw: Print one incoming stanza per line, instead of raw incoming data.
Kim Alvefur <zash@zash.se>
parents:
68
diff
changeset
|
20 | if stanza.attr.to == conn.jid then |
040fadcc86f9
clix.raw: Print one incoming stanza per line, instead of raw incoming data.
Kim Alvefur <zash@zash.se>
parents:
68
diff
changeset
|
21 | stanza.attr.to = nil; |
040fadcc86f9
clix.raw: Print one incoming stanza per line, instead of raw incoming data.
Kim Alvefur <zash@zash.se>
parents:
68
diff
changeset
|
22 | end |
133
be3b857e991f
clix.raw: Use indentation when prettyprinting if available in util.stanza
Kim Alvefur <zash@zash.se>
parents:
132
diff
changeset
|
23 | if opts.pretty and stanza.indent then |
be3b857e991f
clix.raw: Use indentation when prettyprinting if available in util.stanza
Kim Alvefur <zash@zash.se>
parents:
132
diff
changeset
|
24 | return print(stanza:indent(1, " "):pretty_print()); |
be3b857e991f
clix.raw: Use indentation when prettyprinting if available in util.stanza
Kim Alvefur <zash@zash.se>
parents:
132
diff
changeset
|
25 | end |
83
040fadcc86f9
clix.raw: Print one incoming stanza per line, instead of raw incoming data.
Kim Alvefur <zash@zash.se>
parents:
68
diff
changeset
|
26 | return print(stanza); |
040fadcc86f9
clix.raw: Print one incoming stanza per line, instead of raw incoming data.
Kim Alvefur <zash@zash.se>
parents:
68
diff
changeset
|
27 | end |
040fadcc86f9
clix.raw: Print one incoming stanza per line, instead of raw incoming data.
Kim Alvefur <zash@zash.se>
parents:
68
diff
changeset
|
28 | conn:hook("stanza", stprint) |
46
b5d6e443e571
raw: If using --stdin and not --interactive then buffer all data before connecting, more reliable in a non-interactive environment
Matthew Wild <mwild1@gmail.com>
parents:
27
diff
changeset
|
29 | if opts.interactive then |
19
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 | local stdin = { |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 | getfd = function () return 0; end; |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 | dirty = function (self) return false; end; |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 | settimeout = function () end; |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 | send = function (_, d) return #d, 0; end; |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 | close = function () end; |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 | receive = function (_, patt) |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 | local data = io.stdin:read(patt); |
68
b7d92ed9c268
clix.raw: Add a small sandbox with util.stanza functions
Kim Alvefur <zash@zash.se>
parents:
46
diff
changeset
|
38 | if data == nil then |
b7d92ed9c268
clix.raw: Add a small sandbox with util.stanza functions
Kim Alvefur <zash@zash.se>
parents:
46
diff
changeset
|
39 | conn:close(); |
b7d92ed9c268
clix.raw: Add a small sandbox with util.stanza functions
Kim Alvefur <zash@zash.se>
parents:
46
diff
changeset
|
40 | end |
19
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 | if opts.echo then |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 | io.write(data, patt == "*l" and "\n" or ""); |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
43 | end |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
44 | return data; |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
45 | end |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
46 | }; |
132
3addfb97296c
clix.raw: Add a shorthand for top level stanza attributes
Kim Alvefur <zash@zash.se>
parents:
85
diff
changeset
|
47 | local stwrap; |
3addfb97296c
clix.raw: Add a shorthand for top level stanza attributes
Kim Alvefur <zash@zash.se>
parents:
85
diff
changeset
|
48 | do |
3addfb97296c
clix.raw: Add a shorthand for top level stanza attributes
Kim Alvefur <zash@zash.se>
parents:
85
diff
changeset
|
49 | local f_mt, r_mt = {}, {}; |
3addfb97296c
clix.raw: Add a shorthand for top level stanza attributes
Kim Alvefur <zash@zash.se>
parents:
85
diff
changeset
|
50 | function f_mt:__call(...) if ... and type(...) == "string" then return self{ to=... } end return self._f(...) end |
3addfb97296c
clix.raw: Add a shorthand for top level stanza attributes
Kim Alvefur <zash@zash.se>
parents:
85
diff
changeset
|
51 | function f_mt:__index(k) return setmetatable({_st = self._f{ type = k }}, r_mt); end |
3addfb97296c
clix.raw: Add a shorthand for top level stanza attributes
Kim Alvefur <zash@zash.se>
parents:
85
diff
changeset
|
52 | function r_mt:__call(to) self._st.attr.to = to; return self._st end |
3addfb97296c
clix.raw: Add a shorthand for top level stanza attributes
Kim Alvefur <zash@zash.se>
parents:
85
diff
changeset
|
53 | function stwrap(f) return setmetatable({_f=f},f_mt) end |
3addfb97296c
clix.raw: Add a shorthand for top level stanza attributes
Kim Alvefur <zash@zash.se>
parents:
85
diff
changeset
|
54 | end |
68
b7d92ed9c268
clix.raw: Add a small sandbox with util.stanza functions
Kim Alvefur <zash@zash.se>
parents:
46
diff
changeset
|
55 | local env = setmetatable({}, { __index = { |
b7d92ed9c268
clix.raw: Add a small sandbox with util.stanza functions
Kim Alvefur <zash@zash.se>
parents:
46
diff
changeset
|
56 | s = verse.stanza, |
132
3addfb97296c
clix.raw: Add a shorthand for top level stanza attributes
Kim Alvefur <zash@zash.se>
parents:
85
diff
changeset
|
57 | m = stwrap(verse.message), |
3addfb97296c
clix.raw: Add a shorthand for top level stanza attributes
Kim Alvefur <zash@zash.se>
parents:
85
diff
changeset
|
58 | p = stwrap(verse.presence), |
3addfb97296c
clix.raw: Add a shorthand for top level stanza attributes
Kim Alvefur <zash@zash.se>
parents:
85
diff
changeset
|
59 | iq = stwrap(verse.iq), |
85
8bc27e310e64
clix.raw: Add a ping command to the sandbox
Kim Alvefur <zash@zash.se>
parents:
84
diff
changeset
|
60 | ping = function(host) |
8bc27e310e64
clix.raw: Add a ping command to the sandbox
Kim Alvefur <zash@zash.se>
parents:
84
diff
changeset
|
61 | return verse.iq{ type="get", to=host}:tag("ping", {xmlns="urn:xmpp:ping"}); |
8bc27e310e64
clix.raw: Add a ping command to the sandbox
Kim Alvefur <zash@zash.se>
parents:
84
diff
changeset
|
62 | end, |
134
d1fa853325b9
clix.raw: Add sevral shorthand functions for common queries
Kim Alvefur <zash@zash.se>
parents:
133
diff
changeset
|
63 | version = function(host) |
d1fa853325b9
clix.raw: Add sevral shorthand functions for common queries
Kim Alvefur <zash@zash.se>
parents:
133
diff
changeset
|
64 | return verse.iq{ type="get", to=host}:query"jabber:iq:version"; |
d1fa853325b9
clix.raw: Add sevral shorthand functions for common queries
Kim Alvefur <zash@zash.se>
parents:
133
diff
changeset
|
65 | end, |
d1fa853325b9
clix.raw: Add sevral shorthand functions for common queries
Kim Alvefur <zash@zash.se>
parents:
133
diff
changeset
|
66 | vcard = function(who) |
d1fa853325b9
clix.raw: Add sevral shorthand functions for common queries
Kim Alvefur <zash@zash.se>
parents:
133
diff
changeset
|
67 | return verse.iq{ type="get", to=who}:tag("vCard",{xmlns="vcard-temp"}); |
d1fa853325b9
clix.raw: Add sevral shorthand functions for common queries
Kim Alvefur <zash@zash.se>
parents:
133
diff
changeset
|
68 | end, |
138
1783d4226ba1
clix.raw: Give access to the verse pubsub module
Kim Alvefur <zash@zash.se>
parents:
137
diff
changeset
|
69 | pubsub = function(...) |
1783d4226ba1
clix.raw: Give access to the verse pubsub module
Kim Alvefur <zash@zash.se>
parents:
137
diff
changeset
|
70 | return conn.pubsub(...); |
1783d4226ba1
clix.raw: Give access to the verse pubsub module
Kim Alvefur <zash@zash.se>
parents:
137
diff
changeset
|
71 | end, |
134
d1fa853325b9
clix.raw: Add sevral shorthand functions for common queries
Kim Alvefur <zash@zash.se>
parents:
133
diff
changeset
|
72 | disco = function (to, node) |
d1fa853325b9
clix.raw: Add sevral shorthand functions for common queries
Kim Alvefur <zash@zash.se>
parents:
133
diff
changeset
|
73 | return verse.iq{ type="get", to=to }:tag("query", { xmlns="http://jabber.org/protocol/disco#info", node = node }); |
d1fa853325b9
clix.raw: Add sevral shorthand functions for common queries
Kim Alvefur <zash@zash.se>
parents:
133
diff
changeset
|
74 | end, |
d1fa853325b9
clix.raw: Add sevral shorthand functions for common queries
Kim Alvefur <zash@zash.se>
parents:
133
diff
changeset
|
75 | items = function (to, node) |
d1fa853325b9
clix.raw: Add sevral shorthand functions for common queries
Kim Alvefur <zash@zash.se>
parents:
133
diff
changeset
|
76 | return verse.iq{ type="get", to=to }:tag("query", { xmlns="http://jabber.org/protocol/disco#items", node = node }); |
d1fa853325b9
clix.raw: Add sevral shorthand functions for common queries
Kim Alvefur <zash@zash.se>
parents:
133
diff
changeset
|
77 | end, |
d1fa853325b9
clix.raw: Add sevral shorthand functions for common queries
Kim Alvefur <zash@zash.se>
parents:
133
diff
changeset
|
78 | join = function (roomnick) |
d1fa853325b9
clix.raw: Add sevral shorthand functions for common queries
Kim Alvefur <zash@zash.se>
parents:
133
diff
changeset
|
79 | return verse.presence({ to=roomnick }):tag("x", { xmlns="http://jabber.org/protocol/muc" }); |
d1fa853325b9
clix.raw: Add sevral shorthand functions for common queries
Kim Alvefur <zash@zash.se>
parents:
133
diff
changeset
|
80 | end, |
68
b7d92ed9c268
clix.raw: Add a small sandbox with util.stanza functions
Kim Alvefur <zash@zash.se>
parents:
46
diff
changeset
|
81 | }}); |
19
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
82 | local function on_incoming(stdin, data) |
68
b7d92ed9c268
clix.raw: Add a small sandbox with util.stanza functions
Kim Alvefur <zash@zash.se>
parents:
46
diff
changeset
|
83 | if not data then |
b7d92ed9c268
clix.raw: Add a small sandbox with util.stanza functions
Kim Alvefur <zash@zash.se>
parents:
46
diff
changeset
|
84 | conn:close(); |
b7d92ed9c268
clix.raw: Add a small sandbox with util.stanza functions
Kim Alvefur <zash@zash.se>
parents:
46
diff
changeset
|
85 | return |
b7d92ed9c268
clix.raw: Add a small sandbox with util.stanza functions
Kim Alvefur <zash@zash.se>
parents:
46
diff
changeset
|
86 | end |
b7d92ed9c268
clix.raw: Add a small sandbox with util.stanza functions
Kim Alvefur <zash@zash.se>
parents:
46
diff
changeset
|
87 | if data:sub(1,1) ~= "<" then |
153
56546fb3429b
clix.raw: Allow unsandboxed arbitrary code execution
Kim Alvefur <zash@zash.se>
parents:
152
diff
changeset
|
88 | local sandboxed = true; |
56546fb3429b
clix.raw: Allow unsandboxed arbitrary code execution
Kim Alvefur <zash@zash.se>
parents:
152
diff
changeset
|
89 | if data:sub(1,1) == ">" then |
56546fb3429b
clix.raw: Allow unsandboxed arbitrary code execution
Kim Alvefur <zash@zash.se>
parents:
152
diff
changeset
|
90 | sandboxed = false; |
56546fb3429b
clix.raw: Allow unsandboxed arbitrary code execution
Kim Alvefur <zash@zash.se>
parents:
152
diff
changeset
|
91 | data = data:sub(2); |
56546fb3429b
clix.raw: Allow unsandboxed arbitrary code execution
Kim Alvefur <zash@zash.se>
parents:
152
diff
changeset
|
92 | else |
56546fb3429b
clix.raw: Allow unsandboxed arbitrary code execution
Kim Alvefur <zash@zash.se>
parents:
152
diff
changeset
|
93 | data = "return "..data; |
56546fb3429b
clix.raw: Allow unsandboxed arbitrary code execution
Kim Alvefur <zash@zash.se>
parents:
152
diff
changeset
|
94 | end |
56546fb3429b
clix.raw: Allow unsandboxed arbitrary code execution
Kim Alvefur <zash@zash.se>
parents:
152
diff
changeset
|
95 | local chunk, err = loadstring(data, "@stdin"); |
84
1b4e64176288
clix.raw: Nicer error reporting from the sandbox.
Kim Alvefur <zash@zash.se>
parents:
83
diff
changeset
|
96 | if not chunk then |
1b4e64176288
clix.raw: Nicer error reporting from the sandbox.
Kim Alvefur <zash@zash.se>
parents:
83
diff
changeset
|
97 | conn:error(err); |
1b4e64176288
clix.raw: Nicer error reporting from the sandbox.
Kim Alvefur <zash@zash.se>
parents:
83
diff
changeset
|
98 | return; |
1b4e64176288
clix.raw: Nicer error reporting from the sandbox.
Kim Alvefur <zash@zash.se>
parents:
83
diff
changeset
|
99 | end |
68
b7d92ed9c268
clix.raw: Add a small sandbox with util.stanza functions
Kim Alvefur <zash@zash.se>
parents:
46
diff
changeset
|
100 | data = ""; |
153
56546fb3429b
clix.raw: Allow unsandboxed arbitrary code execution
Kim Alvefur <zash@zash.se>
parents:
152
diff
changeset
|
101 | if sandboxed then |
56546fb3429b
clix.raw: Allow unsandboxed arbitrary code execution
Kim Alvefur <zash@zash.se>
parents:
152
diff
changeset
|
102 | setfenv(chunk, env); |
56546fb3429b
clix.raw: Allow unsandboxed arbitrary code execution
Kim Alvefur <zash@zash.se>
parents:
152
diff
changeset
|
103 | end |
68
b7d92ed9c268
clix.raw: Add a small sandbox with util.stanza functions
Kim Alvefur <zash@zash.se>
parents:
46
diff
changeset
|
104 | local ok, ret = pcall(chunk); |
b7d92ed9c268
clix.raw: Add a small sandbox with util.stanza functions
Kim Alvefur <zash@zash.se>
parents:
46
diff
changeset
|
105 | if ok then |
b7d92ed9c268
clix.raw: Add a small sandbox with util.stanza functions
Kim Alvefur <zash@zash.se>
parents:
46
diff
changeset
|
106 | data = ret |
84
1b4e64176288
clix.raw: Nicer error reporting from the sandbox.
Kim Alvefur <zash@zash.se>
parents:
83
diff
changeset
|
107 | else |
1b4e64176288
clix.raw: Nicer error reporting from the sandbox.
Kim Alvefur <zash@zash.se>
parents:
83
diff
changeset
|
108 | conn:error(ret); |
1b4e64176288
clix.raw: Nicer error reporting from the sandbox.
Kim Alvefur <zash@zash.se>
parents:
83
diff
changeset
|
109 | return; |
68
b7d92ed9c268
clix.raw: Add a small sandbox with util.stanza functions
Kim Alvefur <zash@zash.se>
parents:
46
diff
changeset
|
110 | end |
b7d92ed9c268
clix.raw: Add a small sandbox with util.stanza functions
Kim Alvefur <zash@zash.se>
parents:
46
diff
changeset
|
111 | end |
b7d92ed9c268
clix.raw: Add a small sandbox with util.stanza functions
Kim Alvefur <zash@zash.se>
parents:
46
diff
changeset
|
112 | if data then |
b7d92ed9c268
clix.raw: Add a small sandbox with util.stanza functions
Kim Alvefur <zash@zash.se>
parents:
46
diff
changeset
|
113 | conn:send(data); |
b7d92ed9c268
clix.raw: Add a small sandbox with util.stanza functions
Kim Alvefur <zash@zash.se>
parents:
46
diff
changeset
|
114 | end |
19
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
115 | if not opts.interactive then |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
116 | conn:close(); |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
117 | end |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
118 | end |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
119 | stdin = require "net.server".wrapclient(stdin, "stdin", 0, { |
152
c729365f1091
clix.raw: Handle (ignore, successfully) read timeouts on stdin
Kim Alvefur <zash@zash.se>
parents:
151
diff
changeset
|
120 | onincoming = on_incoming, ondisconnect = function () conn:close() end, onreadtimeout = function () return true; end |
19
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
121 | }, "*l"); |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
122 | else |
149 | 123 | if not send_xml then |
124 | send_xml = table.concat(args, " "); | |
46
b5d6e443e571
raw: If using --stdin and not --interactive then buffer all data before connecting, more reliable in a non-interactive environment
Matthew Wild <mwild1@gmail.com>
parents:
27
diff
changeset
|
125 | end |
150
af9b9acb10d6
clix.raw: Track and print response to iq stanza given as cli argument
Kim Alvefur <zash@zash.se>
parents:
149
diff
changeset
|
126 | send_xml = assert(xml.parse(send_xml)); |
af9b9acb10d6
clix.raw: Track and print response to iq stanza given as cli argument
Kim Alvefur <zash@zash.se>
parents:
149
diff
changeset
|
127 | if send_xml.name == "iq" then |
af9b9acb10d6
clix.raw: Track and print response to iq stanza given as cli argument
Kim Alvefur <zash@zash.se>
parents:
149
diff
changeset
|
128 | conn:send_iq(send_xml, function () |
af9b9acb10d6
clix.raw: Track and print response to iq stanza given as cli argument
Kim Alvefur <zash@zash.se>
parents:
149
diff
changeset
|
129 | conn:close(); |
af9b9acb10d6
clix.raw: Track and print response to iq stanza given as cli argument
Kim Alvefur <zash@zash.se>
parents:
149
diff
changeset
|
130 | end); |
af9b9acb10d6
clix.raw: Track and print response to iq stanza given as cli argument
Kim Alvefur <zash@zash.se>
parents:
149
diff
changeset
|
131 | else |
af9b9acb10d6
clix.raw: Track and print response to iq stanza given as cli argument
Kim Alvefur <zash@zash.se>
parents:
149
diff
changeset
|
132 | conn:send(send_xml); |
af9b9acb10d6
clix.raw: Track and print response to iq stanza given as cli argument
Kim Alvefur <zash@zash.se>
parents:
149
diff
changeset
|
133 | conn:close(); |
af9b9acb10d6
clix.raw: Track and print response to iq stanza given as cli argument
Kim Alvefur <zash@zash.se>
parents:
149
diff
changeset
|
134 | end |
19
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
135 | end |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
136 | |
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
137 | end |
137
7130d5ec115c
clix.raw: Allow specifying extra plugins to load
Kim Alvefur <zash@zash.se>
parents:
136
diff
changeset
|
138 | local plugins = {}; |
7130d5ec115c
clix.raw: Allow specifying extra plugins to load
Kim Alvefur <zash@zash.se>
parents:
136
diff
changeset
|
139 | for i=#args,1,-1 do |
7130d5ec115c
clix.raw: Allow specifying extra plugins to load
Kim Alvefur <zash@zash.se>
parents:
136
diff
changeset
|
140 | if args[i]:sub(1,1) == "+" then |
7130d5ec115c
clix.raw: Allow specifying extra plugins to load
Kim Alvefur <zash@zash.se>
parents:
136
diff
changeset
|
141 | table.insert(plugins, table.remove(args, i):sub(2)) |
7130d5ec115c
clix.raw: Allow specifying extra plugins to load
Kim Alvefur <zash@zash.se>
parents:
136
diff
changeset
|
142 | end |
7130d5ec115c
clix.raw: Allow specifying extra plugins to load
Kim Alvefur <zash@zash.se>
parents:
136
diff
changeset
|
143 | end |
7130d5ec115c
clix.raw: Allow specifying extra plugins to load
Kim Alvefur <zash@zash.se>
parents:
136
diff
changeset
|
144 | return clix_connect(opts, on_connect, plugins); |
19
3a0a156e0a79
clix.raw: New command to set up a raw XML in/out session with the server
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
145 | end |