Software /
code /
prosody
Comparison
core/s2smanager.lua @ 343:cae2178b5623
Log sent s2s stanzas
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 19 Nov 2008 05:11:37 +0000 |
parent | 337:4a1dd1c2c219 |
child | 344:ed5824e9dd94 |
comparison
equal
deleted
inserted
replaced
342:52f75260a22d | 343:cae2178b5623 |
---|---|
74 if true then | 74 if true then |
75 session.trace = newproxy(true); | 75 session.trace = newproxy(true); |
76 getmetatable(session.trace).__gc = function () open_sessions = open_sessions - 1; print("s2s session got collected, now "..open_sessions.." s2s sessions are allocated") end; | 76 getmetatable(session.trace).__gc = function () open_sessions = open_sessions - 1; print("s2s session got collected, now "..open_sessions.." s2s sessions are allocated") end; |
77 end | 77 end |
78 open_sessions = open_sessions + 1; | 78 open_sessions = open_sessions + 1; |
79 local w = conn.write; | 79 local w, log = conn.write, logger_init("s2sin"..tostring(conn):match("[a-f0-9]+$")); |
80 session.sends2s = function (t) w(tostring(t)); end | 80 session.sends2s = function (t) log("debug", "sending: %s", tostring(t)); w(tostring(t)); end |
81 return session; | 81 return session; |
82 end | 82 end |
83 | 83 |
84 function new_outgoing(from_host, to_host) | 84 function new_outgoing(from_host, to_host) |
85 local host_session = { to_host = to_host, from_host = from_host, notopen = true, type = "s2sout_unauthed", direction = "outgoing" }; | 85 local host_session = { to_host = to_host, from_host = from_host, notopen = true, type = "s2sout_unauthed", direction = "outgoing" }; |
122 | 122 |
123 -- Register this outgoing connection so that xmppserver_listener knows about it | 123 -- Register this outgoing connection so that xmppserver_listener knows about it |
124 -- otherwise it will assume it is a new incoming connection | 124 -- otherwise it will assume it is a new incoming connection |
125 cl.register_outgoing(conn, host_session); | 125 cl.register_outgoing(conn, host_session); |
126 | 126 |
127 local log; | |
127 do | 128 do |
128 local conn_name = "s2sout"..tostring(conn):match("[a-f0-9]*$"); | 129 local conn_name = "s2sout"..tostring(conn):match("[a-f0-9]*$"); |
129 host_session.log = logger_init(conn_name); | 130 log = logger_init(conn_name); |
131 host_session.log = log; | |
130 end | 132 end |
131 | 133 |
132 local w = conn.write; | 134 local w = conn.write; |
133 host_session.sends2s = function (t) w(tostring(t)); end | 135 host_session.sends2s = function (t) log("debug", "sending: %s", tostring(t)); w(tostring(t)); end |
134 | 136 |
135 conn.write(format([[<stream:stream xmlns='jabber:server' xmlns:db='jabber:server:dialback' xmlns:stream='http://etherx.jabber.org/streams' from='%s' to='%s' version='1.0'>]], from_host, to_host)); | 137 conn.write(format([[<stream:stream xmlns='jabber:server' xmlns:db='jabber:server:dialback' xmlns:stream='http://etherx.jabber.org/streams' from='%s' to='%s' version='1.0'>]], from_host, to_host)); |
136 | 138 |
137 return host_session; | 139 return host_session; |
138 end | 140 end |