Re: [prosody-dev] prosody version 0.8.2: all conn / ip() are nil

40 views
Skip to first unread message

Kim Alvefur

unread,
Feb 18, 2013, 1:11:29 AM2/18/13
to proso...@googlegroups.com
On 2013-02-15 18:14, rkadeFR wrote:
> Hello everyone,

Hi,

> I'm currently implementing another command line for the telnet admin
> interface, and I'm facing one problem with the conn to search the ip of
> the session.
>
> I searched on the archives to know if the question has ever been asked,
> but I don't think so.
>
> So I would like to know why all my conn, or ip are at nil ?

I don't quite understand where this happens, could you perhaps show some
code?

>
> I browsed a bit the source code and I never find the call of the
> onconnect(conn) function with a normal conn.
>
> I only find the function called from net/server_event.lua, and it's
> called without any parameters.

This may be obscured a bit in server_select.lua, because it names it
dispatch() internally.

The call in server_event.lua I think you are referring to:

self:onconnect()

is equal to

self.onconnect(self)

so it does have a parameter.

--
Regards,
Kim "Zash" Alvefur

signature.asc

Kim Alvefur

unread,
Feb 18, 2013, 4:27:24 AM2/18/13
to rkadeFR, proso...@googlegroups.com
On 2013-02-18T10:07:08 CET, rkadeFR wrote:
> But unfortunately, all my conn:ip() or ip directly are at nil.
>
> If you have any hints of the cause?

What types of sessions are these? BOSH? Old-style SSL on 5223?

--
Kim "Zash" Alvefur

signature.asc

Kim Alvefur

unread,
Feb 18, 2013, 5:02:18 AM2/18/13
to rkadeFR, proso...@googlegroups.com
On 2013-02-18 10:33, rkadeFR wrote:
> I tried to print my session.type with :
> -- show all the persons form an ip
> function def_env.c2s:show_by_ip()
> local print, count = self.session.print, 0;
> show_c2s(function (session)
> -- print("ip "..session.conn:ip());
> print("type "..session.type);
> end);
> return true, "Total: "..count.." clients on this ip";
> end
>
> but it returns me :
> Error: /usr/lib/prosody/modules/mod_admin_telnet.lua:472: attempt to
> concatenate field 'type' (a nil value)

That seems broken. All sessions should have a type attribute.

Can you see from (debug) logs if there are any hints as to where the
session came from?

Also, try if session.conn:socket():getpeername() gives anything.

--
Kim

signature.asc
Message has been deleted
Message has been deleted

Kim Alvefur

unread,
Feb 18, 2013, 5:40:56 AM2/18/13
to rkadeFR, proso...@googlegroups.com
On 2013-02-18 11:19, rkadeFR wrote:
> Plus I tried to print every session directly, and it prints
> "martin...@jabber.interne.net/desk"

If print(session) gives you a JID then it's probably not a session you
have there.

--
Kim


signature.asc
Message has been deleted

Kim Alvefur

unread,
Feb 18, 2013, 5:49:48 AM2/18/13
to rkadeFR, proso...@googlegroups.com
The original show_c2s function in mod_admin_telnet does callback(jid,
session). It is likely that this is what you are using.

--
Kim

signature.asc

Daurnimator

unread,
Feb 18, 2013, 12:00:27 AM2/18/13
to proso...@googlegroups.com
On 16 February 2013 04:14, rkadeFR <grignon...@gmail.com> wrote:
I browsed a bit the source code and I never find the call of the onconnect(conn) function with a normal conn.
I only find the function called from net/server_event.lua, and it's called without any parameters.

Are you sure?
$ grep -r onconnect prosody-hg 
Reply all
Reply to author
Forward
0 new messages