powered by Jive Software

A plugin to know the ip of a user

Well, I’'m a new developer and I need to know the IP of a online jid user.

The best opcion I think that was to do a plugin.

I know than this information is available in the web-admin, but I need something like the user_service plugin, and to do:

http://example.com:9090/plugins/userService/userservice?type=getIP&jid=aaaa@serv er.com9090/plugins/userService/userservice?type=getIP&jid=aaaa@server.com”

There fore, is this possible with the wildfire Api ?

Thanks,

P.D: … excuse me for my simple english !!

Hi Jose,

Take a look at this post from awhile back.

Hope that helps,

Ryan

Following your advise, I’'m trying to do somethig like

"String address = XMPPServer.getInstance().getSessionManager().getSession(packet.getFrom()).getCo nnection().getInetAddress().getHostAddress();

"

Well, in my case, when I call this:

http://localhost:9090/plugins/userService/userservice?type=getIP&secret=hhhhh&ji d=usuario@dom.comugins/userService/userservice?type=getIP&secret=hhhhh&jid=usuario@dom.com”

In the source of the plugin do this:

JID jID=new JID(strJid);

XMPPServer server = XMPPServer.getInstance();

SessionManager sessionManager=server.getSessionManager();

ClientSession clientSession=sessionManager.getSession(jID);

String strIp=clientSession.getConnection().getInetAddress().getHostAddress();

But, I receive this in my navigator:

HTTP ERROR: 500

org.jivesoftware.wildfire.SessionManager.getSession(Lorg/xmpp/packet/JID;)Lorg/j ivesoftware/wildfire/ClientSession;

What is wrong ???

Thanks a lot

Hi Jose,

In order for the code to work you need to supply a JID that includes a resource, so your url would have to look like this:

http://localhost:9090/plugins/userService/userservice?type=getIP&secret=hhhhh&ji d=usuario@dom.com/sparkugins/userService/userservice?type=getIP&secret=hhhhh&jid=usuario@dom.com/spark”

Notice the “/spark”. The resource is needed since it’'s possible for one user to be logged in using more than one resource, i.e., “/work”, “/home”, etc.

Hope that helps,

Ryan

Thanks Ryan !!!

I already have my first plugin !!! jjejeje

Cool!

Do you care to share the plugin? Been looking all over for this… Along the same lines, to be able to see all of the following info would be REALLY helpful:

  1. User IP

  2. Referrer

  3. IP Country ( would need a geoip database for this )

Thanks!

Hey Ross,

I did this last year, check out this post http://www.igniterealtime.org/forum/message.jspa?messageID=126666#126666.

I see I didn’‘t include the code that sets the IP. It’'s analagous to the GET, just a SET with the IP of the client. If you have any questions let me know…

Thanks,

Jay

This metod are added to the UserServicePlugin for to do this

public String getIp(String jid) throws UserNotFoundException{

String strIp;

JID jID=new JID(jid);

XMPPServer server = XMPPServer.getInstance();

SessionManager sessionManager=server.getSessionManager();

ClientSession clientSession=sessionManager.getSession(jID);

strIp=clientSession.getConnection().getInetAddress().getHostAddress();

return strIp;

}

Message was edited by: weiser01

Hi Jose/Jay/Ryan,

I am unix sys admin, with zero knowledge on Development/java code etc…

I tried to download the plugin from the below url, but no luck .

http://www.igniterealtime.org/forum/message.jspa?messageID=126666#126666.

Actually my requirement is to log all the ip’s that are hitting my connection manager server (exposed to internet which is in DMZ).

Can you please let me know, is there any plugin which can capture/log all the ip’s hitting CM and by EOD, i can have a look at them ?

Thanks in Advance,

MOULI