开发者

ejabberd ip address

Does anyone know if there's a direct way to map an IP address to a user logged into ejabberd? I found an indirect way by modifying ejabberd_receiver.erl and calling inet:peername(Socket) from here: Determining IP address and port of an incoming TCP/IP connection in Erlang

but there doesn't seem to be a way to link a socket to a user after they've successfully been authenticated. If anyone knows o开发者_StackOverflowf a way, please let me know! Thanks.


Depending on the size of your installation, you might want to run ejabberd_sm:dirty_get_sessions_list/0 and call get_user_ip/3 on each triple to implement a reverse lookup.


You can use From argument from handle_call or handle_info calls to get User, Server, Resource information. Then call:

Info = ejabberd_sm:get_user_info(User, Server, Resource), 
{ip, {Ip, Port}} = lists:keyfind(ip, 1, Info).
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜