I am developing an app which can respond to user's chat message. I need to know the IP address of the chat message sender. I am doing my app on Google app Engine and using XMPP protocol for chatting purposes. How to detect IP address of a chat message sender using XMPP protocol?
2
votes
2 Answers
2
votes
0
votes
How to get my public IP from XMPP bind message?
http://xmpp.org/extensions/xep-0279.html
First the client sends an IQ-get request to its server.
Example 1. Client requests its IP address from the server
<iq from='[email protected]/orchard'
id='ik2s7159'
type='get'>
<address xmlns='urn:xmpp:sic:1'/>
</iq>
The server then returns an IQ-result containing an element containing an element specifying the client's external IP address and, optionally, a element specifying the client's external port.
Example 2. Server returns IP address and port
<iq id='ik2s7159'
to='[email protected]/orchard'
type='result'>
<address xmlns='urn:xmpp:sic:1'>
<ip>192.168.4.1</ip>
<port>12345</port>
</iq>
Note that the IP address could be IPv4 or IPv6.
Example 3. Server returns IPv6 address
<iq id='ik2s7159'
to='[email protected]/orchard'
type='result'>
<address xmlns='urn:xmpp:sic:1'>
<ip>2001:db8::9:1</ip>
<port>12345</port>
</address>
</iq>