Comparison

plugins/mod_s2s/s2sout.lib.lua @ 8483:6d47b74926dd

mod_s2s: Remove tostring() in logging since this is handled by util.format now
author Kim Alvefur <zash@zash.se>
date Thu, 21 Dec 2017 07:00:56 +0100
parent 8267:42fad8465537
child 8896:739deb514140
comparison
equal deleted inserted replaced
8482:8b2219011386 8483:6d47b74926dd
66 function host_session.sends2s(data) 66 function host_session.sends2s(data)
67 if not buffer then 67 if not buffer then
68 buffer = {}; 68 buffer = {};
69 host_session.send_buffer = buffer; 69 host_session.send_buffer = buffer;
70 end 70 end
71 log("debug", "Buffering data on unconnected s2sout to %s", tostring(host_session.to_host)); 71 log("debug", "Buffering data on unconnected s2sout to %s", host_session.to_host);
72 buffer[#buffer+1] = data; 72 buffer[#buffer+1] = data;
73 log("debug", "Buffered item %d: %s", #buffer, tostring(data)); 73 log("debug", "Buffered item %d: %s", #buffer, data);
74 end 74 end
75 end 75 end
76 end 76 end
77 77
78 function s2sout.attempt_connection(host_session, err) 78 function s2sout.attempt_connection(host_session, err)
127 return s2sout.try_connect(host_session, connect_host, connect_port, err); 127 return s2sout.try_connect(host_session, connect_host, connect_port, err);
128 elseif host_session.srv_hosts and #host_session.srv_hosts > host_session.srv_choice then -- Not our first attempt, and we also have SRV 128 elseif host_session.srv_hosts and #host_session.srv_hosts > host_session.srv_choice then -- Not our first attempt, and we also have SRV
129 host_session.srv_choice = host_session.srv_choice + 1; 129 host_session.srv_choice = host_session.srv_choice + 1;
130 local srv_choice = host_session.srv_hosts[host_session.srv_choice]; 130 local srv_choice = host_session.srv_hosts[host_session.srv_choice];
131 connect_host, connect_port = srv_choice.target or to_host, srv_choice.port or connect_port; 131 connect_host, connect_port = srv_choice.target or to_host, srv_choice.port or connect_port;
132 host_session.log("info", "Connection failed (%s). Attempt #%d: This time to %s:%d", tostring(err), host_session.srv_choice, connect_host, connect_port); 132 host_session.log("info", "Connection failed (%s). Attempt #%d: This time to %s:%d", err, host_session.srv_choice, connect_host, connect_port);
133 else 133 else
134 host_session.log("info", "Failed in all attempts to connect to %s", tostring(host_session.to_host)); 134 host_session.log("info", "Failed in all attempts to connect to %s", host_session.to_host);
135 -- We're out of options 135 -- We're out of options
136 return false; 136 return false;
137 end 137 end
138 138
139 if not (connect_host and connect_port) then 139 if not (connect_host and connect_port) then
140 -- Likely we couldn't resolve DNS 140 -- Likely we couldn't resolve DNS
141 log("warn", "Hmm, we're without a host (%s) and port (%s) to connect to for %s, giving up :(", tostring(connect_host), tostring(connect_port), tostring(to_host)); 141 log("warn", "Hmm, we're without a host (%s) and port (%s) to connect to for %s, giving up :(", connect_host, connect_port, to_host);
142 return false; 142 return false;
143 end 143 end
144 144
145 return s2sout.try_connect(host_session, connect_host, connect_port); 145 return s2sout.try_connect(host_session, connect_host, connect_port);
146 end 146 end