Software /
code /
prosody
Comparison
plugins/mod_s2s/s2sout.lib.lua @ 8911:cea6165a03d0
mod_s2s: Use session logger to ease debugging
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 14 Jun 2018 18:16:23 +0200 |
parent | 8910:28ec1e024379 |
child | 9413:127208a6107c |
comparison
equal
deleted
inserted
replaced
8910:28ec1e024379 | 8911:cea6165a03d0 |
---|---|
44 local function compare_srv_priorities(a,b) | 44 local function compare_srv_priorities(a,b) |
45 return a.priority < b.priority or (a.priority == b.priority and a.weight > b.weight); | 45 return a.priority < b.priority or (a.priority == b.priority and a.weight > b.weight); |
46 end | 46 end |
47 | 47 |
48 function s2sout.initiate_connection(host_session) | 48 function s2sout.initiate_connection(host_session) |
49 local log = host_session.log or log; | |
50 | |
49 initialize_filters(host_session); | 51 initialize_filters(host_session); |
50 host_session.version = 1; | 52 host_session.version = 1; |
51 | 53 |
52 host_session.resolver = adns.resolver(); | 54 host_session.resolver = adns.resolver(); |
53 host_session.resolver._resolver:settimeout(dns_timeout); | 55 host_session.resolver._resolver:settimeout(dns_timeout); |
82 end | 84 end |
83 | 85 |
84 function s2sout.attempt_connection(host_session, err) | 86 function s2sout.attempt_connection(host_session, err) |
85 local to_host = host_session.to_host; | 87 local to_host = host_session.to_host; |
86 local connect_host, connect_port = to_host and idna_to_ascii(to_host), 5269; | 88 local connect_host, connect_port = to_host and idna_to_ascii(to_host), 5269; |
89 local log = host_session.log or log; | |
87 | 90 |
88 if not connect_host then | 91 if not connect_host then |
89 return false; | 92 return false; |
90 end | 93 end |
91 | 94 |
164 end | 167 end |
165 end | 168 end |
166 | 169 |
167 function s2sout.try_connect(host_session, connect_host, connect_port, err) | 170 function s2sout.try_connect(host_session, connect_host, connect_port, err) |
168 host_session.connecting = true; | 171 host_session.connecting = true; |
172 local log = host_session.log or log; | |
169 | 173 |
170 if not err then | 174 if not err then |
171 local IPs = {}; | 175 local IPs = {}; |
172 host_session.ip_hosts = IPs; | 176 host_session.ip_hosts = IPs; |
173 local handle4, handle6; | 177 local handle4, handle6; |
264 | 268 |
265 return true; | 269 return true; |
266 end | 270 end |
267 | 271 |
268 function s2sout.make_connect(host_session, connect_host, connect_port) | 272 function s2sout.make_connect(host_session, connect_host, connect_port) |
269 (host_session.log or log)("debug", "Beginning new connection attempt to %s ([%s]:%d)", host_session.to_host, connect_host.addr, connect_port); | 273 local log = host_session.log or log; |
274 log("debug", "Beginning new connection attempt to %s ([%s]:%d)", host_session.to_host, connect_host.addr, connect_port); | |
270 | 275 |
271 -- Reset secure flag in case this is another | 276 -- Reset secure flag in case this is another |
272 -- connection attempt after a failed STARTTLS | 277 -- connection attempt after a failed STARTTLS |
273 host_session.secure = nil; | 278 host_session.secure = nil; |
274 host_session.encrypted = nil; | 279 host_session.encrypted = nil; |