From 92914e09db33693c5a606ebd8bfaa8a5fe3ea8fe Mon Sep 17 00:00:00 2001 From: HAMANO Tsukasa Date: Wed, 18 Feb 2015 00:21:13 +0900 Subject: [PATCH] fix show_ip option --- mod_logxml/src/mod_logxml.erl | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mod_logxml/src/mod_logxml.erl b/mod_logxml/src/mod_logxml.erl index 5ac6238..3d89ae9 100644 --- a/mod_logxml/src/mod_logxml.erl +++ b/mod_logxml/src/mod_logxml.erl @@ -183,12 +183,15 @@ add_log(Io, Timezone, ShowIP, {Orientation, From, To, Packet}, _OSD) -> recv -> To end, LocalIPS = case ShowIP of - true -> - {UserIP, _Port} = ejabberd_sm:get_user_ip( - LocalJID#jid.user, - LocalJID#jid.server, - LocalJID#jid.resource), - io_lib:format("lip=\"~s\" ", [inet_parse:ntoa(UserIP)]); + true -> + case ejabberd_sm:get_user_ip( + LocalJID#jid.user, + LocalJID#jid.server, + LocalJID#jid.resource) of + {UserIP, _Port} -> + io_lib:format("lip=\"~s\" ", [inet_parse:ntoa(UserIP)]); + undefined -> "lip=\"undefined\" " + end; false -> "" end, TimestampISO = get_now_iso(Timezone),