comparison mod_net_proxy/mod_net_proxy.lua @ 2962:6b01600b9c02

mod_net_proxy: Adjusted log level of errors triggered by remote connections to 'warn'
author Pascal Mathis <mail@pascalmathis.com>
date Wed, 28 Mar 2018 19:03:10 +0200
parents 33227efa2cdc
children 504bb330e910
comparison
equal deleted inserted replaced
2961:33227efa2cdc 2962:6b01600b9c02
193 return PROTO_HANDLER_STATUS.POSTPONE, nil; 193 return PROTO_HANDLER_STATUS.POSTPONE, nil;
194 end 194 end
195 195
196 -- Ensure that version number is correct 196 -- Ensure that version number is correct
197 if version ~= 0x2 then 197 if version ~= 0x2 then
198 module:log("error", "Received unsupported PROXYv2 version from %s: %d", conn:ip(), version); 198 module:log("warn", "Received unsupported PROXYv2 version from %s: %d", conn:ip(), version);
199 return PROTO_HANDLER_STATUS.FAILURE, nil; 199 return PROTO_HANDLER_STATUS.FAILURE, nil;
200 end 200 end
201 201
202 local payload = session.buffer:sub(17); 202 local payload = session.buffer:sub(17);
203 if command == 0x0 then 203 if command == 0x0 then
257 setmetatable(proxy_data, proxy_data_mt); 257 setmetatable(proxy_data, proxy_data_mt);
258 258
259 -- Return successful response with gathered proxy data 259 -- Return successful response with gathered proxy data
260 return PROTO_HANDLER_STATUS.SUCCESS, proxy_data; 260 return PROTO_HANDLER_STATUS.SUCCESS, proxy_data;
261 else 261 else
262 module:log("error", "Received unsupported PROXYv2 command from %s: 0x%02X", conn:ip(), command); 262 module:log("warn", "Received unsupported PROXYv2 command from %s: 0x%02X", conn:ip(), command);
263 return PROTO_HANDLER_STATUS.FAILURE, nil; 263 return PROTO_HANDLER_STATUS.FAILURE, nil;
264 end 264 end
265 end 265 end
266 266
267 -- Wrap an existing connection with the provided proxy data. This will override several methods of the 'conn' object to 267 -- Wrap an existing connection with the provided proxy data. This will override several methods of the 'conn' object to
283 283
284 -- Attempt to find service by processing port<>service mappings 284 -- Attempt to find service by processing port<>service mappings
285 local mapping = mappings[conn:serverport()]; 285 local mapping = mappings[conn:serverport()];
286 if mapping == nil then 286 if mapping == nil then
287 conn:close(); 287 conn:close();
288 module:log("error", "Connection %s@%s terminated: Could not find mapping for port %d", 288 module:log("warn", "Connection %s@%s terminated: Could not find mapping for port %d",
289 conn:ip(), conn:proxyip(), conn:serverport()); 289 conn:ip(), conn:proxyip(), conn:serverport());
290 return; 290 return;
291 end 291 end
292 292
293 if mapping.service == nil then 293 if mapping.service == nil then
295 295
296 if service ~= nil then 296 if service ~= nil then
297 mapping.service = service; 297 mapping.service = service;
298 else 298 else
299 conn:close(); 299 conn:close();
300 module:log("error", "Connection %s@%s terminated: Could not process mapping for unknown service %s", 300 module:log("warn", "Connection %s@%s terminated: Could not process mapping for unknown service %s",
301 conn:ip(), conn:proxyip(), mapping.service_name); 301 conn:ip(), conn:proxyip(), mapping.service_name);
302 return; 302 return;
303 end 303 end
304 end 304 end
305 305
375 "see previous log messages.", conn:ip()); 375 "see previous log messages.", conn:ip());
376 return; 376 return;
377 else 377 else
378 -- This code should be never reached, but is included for completeness 378 -- This code should be never reached, but is included for completeness
379 conn:close(); 379 conn:close();
380 module:log("error", "Connection terminated: Received invalid protocol handler response with code %d", response); 380 module:log("warn", "Connection terminated: Received invalid protocol handler response with code %d", response);
381 return; 381 return;
382 end 382 end
383 end 383 end
384 384
385 function listener.ondisconnect(conn) 385 function listener.ondisconnect(conn)