Comparison

plugins/mod_s2s/mod_s2s.lua @ 6633:832987170da8

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Sun, 26 Apr 2015 00:07:36 +0200
parent 6626:071611bc4f1d
parent 6630:6735e2d735d6
child 6666:42fdc8dddf04
comparison
equal deleted inserted replaced
6626:071611bc4f1d 6633:832987170da8
34 local opt_keepalives = module:get_option_boolean("s2s_tcp_keepalives", module:get_option_boolean("tcp_keepalives", true)); 34 local opt_keepalives = module:get_option_boolean("s2s_tcp_keepalives", module:get_option_boolean("tcp_keepalives", true));
35 local secure_auth = module:get_option_boolean("s2s_secure_auth", false); -- One day... 35 local secure_auth = module:get_option_boolean("s2s_secure_auth", false); -- One day...
36 local secure_domains, insecure_domains = 36 local secure_domains, insecure_domains =
37 module:get_option_set("s2s_secure_domains", {})._items, module:get_option_set("s2s_insecure_domains", {})._items; 37 module:get_option_set("s2s_secure_domains", {})._items, module:get_option_set("s2s_insecure_domains", {})._items;
38 local require_encryption = module:get_option_boolean("s2s_require_encryption", false); 38 local require_encryption = module:get_option_boolean("s2s_require_encryption", false);
39
40 local measure_connections = module:measure("connections", "counter");
39 41
40 local sessions = module:shared("sessions"); 42 local sessions = module:shared("sessions");
41 43
42 local log = module._log; 44 local log = module._log;
43 45
575 session:close("connection-timeout"); 577 session:close("connection-timeout");
576 end); 578 end);
577 end 579 end
578 580
579 function listener.onconnect(conn) 581 function listener.onconnect(conn)
582 measure_connections(1);
580 conn:setoption("keepalive", opt_keepalives); 583 conn:setoption("keepalive", opt_keepalives);
581 local session = sessions[conn]; 584 local session = sessions[conn];
582 if not session then -- New incoming connection 585 if not session then -- New incoming connection
583 session = s2s_new_incoming(conn); 586 session = s2s_new_incoming(conn);
584 sessions[conn] = session; 587 sessions[conn] = session;
606 end 609 end
607 end 610 end
608 end 611 end
609 612
610 function listener.ondisconnect(conn, err) 613 function listener.ondisconnect(conn, err)
614 measure_connections(-1);
611 local session = sessions[conn]; 615 local session = sessions[conn];
612 if session then 616 if session then
613 sessions[conn] = nil; 617 sessions[conn] = nil;
614 if err and session.direction == "outgoing" and session.notopen then 618 if err and session.direction == "outgoing" and session.notopen then
615 (session.log or log)("debug", "s2s connection attempt failed: %s", err); 619 (session.log or log)("debug", "s2s connection attempt failed: %s", err);