Software /
code /
prosody-modules
Comparison
mod_tcpproxy/mod_tcpproxy.lua @ 1865:db8b256f51ff
mod_admin_web,mod_carbons,mod_csi_compat,mod_mam_muc,mod_tcpproxy: Explicitly return true
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 21 Sep 2015 20:03:08 +0200 |
parent | 1343:7dbde05b48a9 |
child | 4853:3804332c204e |
comparison
equal
deleted
inserted
replaced
1864:991a5f74f848 | 1865:db8b256f51ff |
---|---|
44 if ibb_tag.name == "open" then | 44 if ibb_tag.name == "open" then |
45 -- Starting a new stream | 45 -- Starting a new stream |
46 local to_host, to_port = ibb_tag.attr[host_attr], ibb_tag.attr[port_attr]; | 46 local to_host, to_port = ibb_tag.attr[host_attr], ibb_tag.attr[port_attr]; |
47 local jid, sid = stanza.attr.from, ibb_tag.attr.sid; | 47 local jid, sid = stanza.attr.from, ibb_tag.attr.sid; |
48 if not (to_host and to_port) then | 48 if not (to_host and to_port) then |
49 return origin.send(st.error_reply(stanza, "modify", "bad-request", "No host/port specified")); | 49 origin.send(st.error_reply(stanza, "modify", "bad-request", "No host/port specified")); |
50 return true; | |
50 elseif not sid or sid == "" then | 51 elseif not sid or sid == "" then |
51 return origin.send(st.error_reply(stanza, "modify", "bad-request", "No sid specified")); | 52 origin.send(st.error_reply(stanza, "modify", "bad-request", "No sid specified")); |
53 return true; | |
52 elseif ibb_tag.attr.stanza ~= "message" then | 54 elseif ibb_tag.attr.stanza ~= "message" then |
53 return origin.send(st.error_reply(stanza, "modify", "bad-request", "Only 'message' stanza transport is supported")); | 55 origin.send(st.error_reply(stanza, "modify", "bad-request", "Only 'message' stanza transport is supported")); |
56 return true; | |
54 end | 57 end |
55 local conn, err = socket.tcp(); | 58 local conn, err = socket.tcp(); |
56 if not conn then | 59 if not conn then |
57 return origin.send(st.error_reply(stanza, "wait", "resource-constraint", err)); | 60 origin.send(st.error_reply(stanza, "wait", "resource-constraint", err)); |
61 return true; | |
58 end | 62 end |
59 conn:settimeout(0); | 63 conn:settimeout(0); |
60 | 64 |
61 local success, err = conn:connect(to_host, to_port); | 65 local success, err = conn:connect(to_host, to_port); |
62 if not success and err ~= "timeout" then | 66 if not success and err ~= "timeout" then |
63 return origin.send(st.error_reply(stanza, "wait", "remote-server-not-found", err)); | 67 origin.send(st.error_reply(stanza, "wait", "remote-server-not-found", err)); |
68 return true; | |
64 end | 69 end |
65 | 70 |
66 local listener,seq = {}, 0; | 71 local listener,seq = {}, 0; |
67 function listener.onconnect(conn) | 72 function listener.onconnect(conn) |
68 origin.send(st.reply(stanza)); | 73 origin.send(st.reply(stanza)); |
86 if conn then | 91 if conn then |
87 local data = unb64(ibb_tag:get_text()); | 92 local data = unb64(ibb_tag:get_text()); |
88 if data then | 93 if data then |
89 conn:write(data); | 94 conn:write(data); |
90 else | 95 else |
91 return origin.send( | 96 origin.send( |
92 st.error_reply(stanza, "modify", "bad-request", "Invalid data (base64?)") | 97 st.error_reply(stanza, "modify", "bad-request", "Invalid data (base64?)") |
93 ); | 98 ); |
99 return true; | |
94 end | 100 end |
95 else | 101 else |
96 return origin.send(st.error_reply(stanza, "cancel", "item-not-found")); | 102 origin.send(st.error_reply(stanza, "cancel", "item-not-found")); |
103 return true; | |
97 end | 104 end |
98 elseif ibb_tag.name == "close" then | 105 elseif ibb_tag.name == "close" then |
99 if close_session(stanza.attr.from, ibb_tag.attr.sid) then | 106 if close_session(stanza.attr.from, ibb_tag.attr.sid) then |
100 origin.send(st.reply(stanza)); | 107 origin.send(st.reply(stanza)); |
101 else | 108 else |
102 return origin.send(st.error_reply(stanza, "cancel", "item-not-found")); | 109 origin.send(st.error_reply(stanza, "cancel", "item-not-found")); |
110 return true; | |
103 end | 111 end |
104 end | 112 end |
105 end | 113 end |
106 | 114 |
107 local function stanza_handler(event) | 115 local function stanza_handler(event) |