Skip navigation
6830 Views 14 Replies Latest reply: Oct 15, 2007 9:53 AM by Brandon bergman RSS
Bronze 26 posts since
Jun 13, 2007
Currently Being Moderated

Oct 8, 2007 11:53 AM

IPPlugin help

I was wondering if anyone had any luck with the IPPlugin for Openfire.

I would like to use the plugin so I can retrieve IP addresses of JID's

to use in the spawning of Dameware (a remote PC tool) to essentially

auto-connect to a user on Spark. I have the Spark plugin working so it

can spawn dameware by right-clicking a user and selecting "Connect via

Dameware", but thats it.

 

 

This is the code snippet I am using to generate the custom IQ packet:


XMPPConnection conn = SparkManager.getConnection();
IQ registerIQ = new IQ () {
public String getChildElementXML() {
return "<query xmlns=\"nu:john:ip\">" +
"<data>me@jabber.server/spark</data> \n" +
"</query>";
}
};
registerIQ.setType(IQ.Type.GET);
conn.sendPacket(registerIQ); 

 

 

This is what is sent:

 

 

 


<iq id="MW8bP-129" type="get">
  <query xmlns="nu:john:ip">
    <data>me@jabber.server/spark</data> 
</query>
</iq>


 

 

 

This is what is returned:


<iq id="MW8bP-129" to="me@jabber.server/spark" type="error">
  <error code="503" type="CANCEL">
    <service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"></service-unavailable>
  </error>
</iq>

 

Any help/suggestions would be greatly appreciated!!! Thanks!

 

Brandon

  • Gaston Dombiak Jiver 3,863 posts since
    Sep 26, 2001
    Currently Being Moderated
    Oct 8, 2007 4:11 PM (in response to Brandon bergman)
    Re: IPPlugin help

    Hey Brandon,

     

    You should try to connect the developer of the plugin. I don't think the plugin actually works (at least the version available in sourceforge from February 9, 2007). I see that the logic is in place but the plugin is not correctly adding its service to the server. Bottom line, that logic is never used.

     

    Regards,

     

      -- Gato

      • Gaston Dombiak Jiver 3,863 posts since
        Sep 26, 2001
        Currently Being Moderated
        Oct 8, 2007 4:39 PM (in response to Brandon bergman)
        Re: IPPlugin help

        Hey Brandon,

         

        Probably the fastest solution would be to get the source code of the plugin and finish it. I would highly recommend adding permission control and changing the namespace being used. The plugin is now trying to work as an IQHandler. I think that it should work as a component. You can see how the broadcast or search plugins work to see a running example of components in Openfire. In a few hours you should have the new plugin running.

         

          -- Gato

  • johjar Bronze 84 posts since
    May 12, 2005
    Currently Being Moderated
    Oct 9, 2007 12:33 AM (in response to Brandon bergman)
    Re: IPPlugin help

     

    Hi Brandon,

     

     

    I wrote the plugin and posted it on Sourceforge, but I never got around to write the client part using it (which makes me a moron since I just assumed everything worked). I hope you had some use of the code anyway, and figure out how to make it work for you. I'll be happy to help in any way I can but Gato seems to have already suggested a solution (thanx btw) :).

     

     

    Cheers,

     

     

    /John

     

     

        • Gaston Dombiak Jiver 3,863 posts since
          Sep 26, 2001
          Currently Being Moderated
          Oct 9, 2007 12:50 PM (in response to Brandon bergman)
          Re: IPPlugin help

          Hey Brandon,

           

          Do not use getExtension(String name, String namespace) unless you have created your own PacketExtension and registed it. You can instead just get the dom4j Element of the IQ packet by using IQ#getChildElement(). It will return the fist dom4j element inside of the IQ packet (which should always be 1 or 0).

           

          Regards,

           

            -- Gato

            • Gaston Dombiak Jiver 3,863 posts since
              Sep 26, 2001
              Currently Being Moderated
              Oct 9, 2007 1:11 PM (in response to Brandon bergman)
              Re: IPPlugin help

              You might want to check that the IQ packet is of type GET and that it does contain a child element. Moreover, you might want to check that the namespace is correct too. Ignore IQ packets of type RESULT or ERROR and in any other case return an IQ error. Even if you have an Exception you have to return an IQ of type error. IQ senders expect an IQ response.

               

                -- Gato

              • Bronze 21 posts since
                Aug 1, 2001
                Currently Being Moderated
                Oct 10, 2007 12:57 PM (in response to Gaston Dombiak)
                Re: IPPlugin help

                 

                Hey guys,

                 

                 

                I  developed a plugin that returns the IP of a client as well as geo information (latitude, longitude, etc.).  The code for that is located here:  http://www.igniterealtime.org/community/message/126666#126666

                 

                 

                My plugin was slightly different in that it was written for use with a web app where the IP from the client session was the IP of the server where the web app was located.  So, the IP had to be set from the client initiating the XMPP session.  It would be set every time a user logged in using code like:

                 

                 

                             GEOIQ geoRequest = new GEOIQ();

                             geoRequest.setType(IQ.Type.SET);

                             geoRequest.setTo("jabberServer.com");

                             geoRequest.setJid(jidValue);

                             geoRequest.setIp(request.getRemoteAddr());

                 

                 

                 

                You don't need to do that since your ClientSession should have a connection with the right IP of the client.  I modified the attached GEOIQHandler to use the session IP if it wasn't explicitly set by code like that above.  Note I didn't compile or test this changed handler code (but the code in the referenced append was tested and worked well on the server and client) but it should work.  Let me know...

                 

                 

                Thanks,

                 

                 

                Jay

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                Attachments:
                  • Gaston Dombiak Jiver 3,863 posts since
                    Sep 26, 2001
                    Currently Being Moderated
                    Oct 15, 2007 9:50 AM (in response to Brandon bergman)
                    Re: IPPlugin help

                    Hey Brandon,

                     

                    You are doing everything in the correct way. Smack is receiving the XML from the server (as seen in the raw tab) but it does not know how to parse it. That is your last step that you need to implement. You need to create a new IQProvider in Smack and register it. Read this document for more information.

                     

                    Regards,

                     

                      -- Gato

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points