1

I'm trying to read users os "Windows XP, Windows 7, Linux .... etc" when they connected I'm working on ejabberd 2.1.x but nothing shown to me.

What I'm doing is :

-module(mod_test).

-behaviour(gen_mod).

%% gen_mod callbacks
-export([start/2, stop/1]).

%% hook handlers
-export([user_send_packet/3, filter_packet/1]).

-include("ejabberd.hrl").
-include("jlib.hrl").

-define(PROCNAME, ejabberd_mod_filter).

start(Host, _Opts) ->
    ejabberd_hooks:add(user_send_packet, Host, ?MODULE, user_send_packet, 75),
    ejabberd_hooks:add(filter_packet, global, ?MODULE, filter_packet, 75),
    ok.

stop(Host) ->
    ejabberd_hooks:delete(filter_packet, global, ?MODULE, filter_packet, 75),
    ejabberd_hooks:delete(user_send_packet, Host, ?MODULE, user_send_packet, 75),
    ok.

user_send_packet(_From, _To, _Packet) ->
    ok.

filter_packet({From, To, Packet}) ->
    io:format("~p", [Packet]),
filter_packet(Arg) ->
    Arg.

It's return with all users data like (status, resource, caps ... etc) else (version, os, client name) are there any way to do this ?

I belive there is away to do this cuz in (muc chat) there is many bot do this like if I type :

version some_user

return to me with this msg :

name : Psi+
version : 1.1
os : Windows XP

but I don't know how they do this.

Mr. zero
  • 245
  • 4
  • 18
  • Out of interest, is there any particular reason why you're on ejabberd 2.1.x? There have been many newer releases since. – legoscia May 25 '16 at 13:03
  • Take a look at the [os](http://erlang.org/doc/man/os.html) erlang module. Maybe it will lead you for the solution. – A. Sarid May 25 '16 at 13:42
  • 1
    @legoscia I've been working on this version before 3 years and I added to it many things and fixed some bugs so I don't want to change this version to the newer version. In my case : catch (name, os, version) of client is it possible to get these information when user login to the server ? – Mr. zero May 26 '16 at 13:21
  • @A.Sarid no, I didn't mean os module. os : like what user using (Windows, Linux) it's provided by xmpp protocol – Mr. zero May 26 '16 at 13:24

1 Answers1

2

You can get this information by sending a "Software Version" request to the client as described in XEP-0092. This is something ejabberd usually doesn't do, so you may have to write code for tracking responses yourself. (The basic idea is that the server sends the request with a certain id, and then needs to check for responses with that same id, taking timeouts and errors into account.)

legoscia
  • 39,593
  • 22
  • 116
  • 167