<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE xep SYSTEM 'xep.dtd' [
  <!ENTITY % ents SYSTEM 'xep.ent'>
%ents;
]>
<?xml-stylesheet type='text/xsl' href='xep.xsl'?>
<xep>
<header>
  <title>Server IP Check</title>
  <abstract>This specification defines a simple XMPP extension that enables a client to discover its external IP address.</abstract>
  &LEGALNOTICE;
  <number>0279</number>
  <status>Deferred</status>
  <type>Standards Track</type>
  <sig>Standards</sig>
  <approver>Council</approver>
  <dependencies>
    <spec>XMPP Core</spec>
  </dependencies>
  <supersedes/>
  <supersededby/>
  <shortname>sic</shortname>
  &stpeter;
  &diana;
  &thiago;
  <revision>
    <version>0.2</version>
    <date>2013-04-17</date>
    <initials>psa</initials>
    <remark><p>Modified XML format so server can return port as well as IP address; incremented protocol version from 0 to 1.</p></remark>
  </revision>
  <revision>
    <version>0.1</version>
    <date>2010-03-05</date>
    <initials>psa</initials>
    <remark><p>Initial published version.</p></remark>
  </revision>
  <revision>
    <version>0.0.2</version>
    <date>2009-03-10</date>
    <initials>psa</initials>
    <remark><p>Removed client inclusion of its IP address; added IPv6 example.</p></remark>
  </revision>
  <revision>
    <version>0.0.1</version>
    <date>2009-03-10</date>
    <initials>psa</initials>
    <remark><p>First draft.</p></remark>
  </revision>
</header>

<section1 topic='Introduction' anchor='intro'>
  <p>There are times when a client might want or need to discover what its external Internet Protocol (IP) address and port are, e.g. when gathering transport candidates for protocols such as &xep0065; or &xep0176;. One way to do so is for the client to ask the XMPP server to which it has connected. This specification defines such a method. The information provided by the server cannot necessarily be relied upon because there might be intermediate entities between the client and the server, but if the IP address and port returned by the server is different from the client's notion of its IP address and port then at the very least the client has received a hint that it might be behind a network address translator (NAT) and therefore cannot usefully provide its private IP address as a candidate for use in multimedia negotiations.</p>
</section1>

<section1 topic='Protocol' anchor='proto'>
  <p>First the client sends an IQ-get request to its server.</p>
  <example caption="Client requests its IP address from the server"><![CDATA[
<iq from='romeo@montague.lit/orchard'
    id='ik2s7159'
    type='get'>
  <address xmlns='urn:xmpp:sic:1'/>
</iq>
]]></example>
  <p>The server then returns an IQ-result containing an &lt;address/&gt; element containing an &lt;ip/&gt; element specifying the client's external IP address and, optionally, a &lt;port/&gt; element specifying the client's external port.</p>
  <example caption="Server returns IP address and port"><![CDATA[
<iq id='ik2s7159'
    to='romeo@montague.lit/orchard'
    type='result'>
  <address xmlns='urn:xmpp:sic:1'>
    <ip>192.168.4.1</ip>
    <port>12345</port>
</iq>
]]></example>
  <p>Note that the IP address could be IPv4 or IPv6.</p>
  <example caption="Server returns IPv6 address"><![CDATA[
<iq id='ik2s7159'
    to='romeo@montague.lit/orchard'
    type='result'>
  <address xmlns='urn:xmpp:sic:1'>
    <ip>2001:db8::9:1</ip>
    <port>12345</port>
  </address>
</iq>
]]></example>
</section1>

<section1 topic='Determining Support' anchor='support'>
  <p>If an entity supports this protocol, it MUST report that by including a service discovery feature of "urn:xmpp:sic:1" in response to disco#info requests &NSNOTE;.</p>
  <example caption="Service discovery information request"><![CDATA[
<iq from='romeo@montague.lit/orchard'
    id='ux71f395'
    to='montague.lit'
    type='get'>
  <query xmlns='http://jabber.org/protocol/disco#info'/>
</iq>
]]></example>
  <example caption="Service discovery information response"><![CDATA[
<iq from='montague.lit'
    id='ux71f395'
    to='romeo@montague.lit/orchard'
    type='result'>
  <query xmlns='http://jabber.org/protocol/disco#info'>
    <feature var='urn:xmpp:sic:1'/>
  </query>
</iq>
]]></example>
</section1>

<section1 topic='Security Considerations' anchor='security'>
  <p>&xmppcore; specifies that client IP addresses shall not be made public. If a client requests its own IP address, that policy is not violated. However, a server MUST NOT return the IP address of another client (e.g., if a connected client sends a SIC request to the bare JID of another user); instead, it MUST return a &forbidden; error.</p>
</section1>

<section1 topic='IANA Considerations' anchor='iana'>
  <p>This document requires no interaction with &IANA;.</p>
</section1>

<section1 topic='XMPP Registrar Considerations' anchor='registrar'>
  <section2 topic='Protocol Namespaces' anchor='registrar-ns'>
    <p>This specification defines the following XML namespace:</p>
    <ul>
      <li>urn:xmpp:sic:1</li>
    </ul>
    <p>Upon advancement of this specification from a status of Experimental to a status of Draft, the &REGISTRAR; shall add the foregoing namespace to the registry located at &NAMESPACES;, as described in Section 4 of &xep0053;.</p>
  </section2>
  <section2 topic='Protocol Versioning' anchor='registrar-versioning'>
    &NSVER;
  </section2>
</section1>

<section1 topic='XML Schema' anchor='schema'>
  <code><![CDATA[
<?xml version='1.0' encoding='UTF-8'?>

<xs:schema
    xmlns:xs='http://www.w3.org/2001/XMLSchema'
    targetNamespace='urn:xmpp:sic:1'
    xmlns='urn:xmpp:sic:1'
    elementFormDefault='qualified'>

  <xs:element name='address' type='xs:string'/>
  <xs:element name='address'>
    <xs:complexType>
      <xs:sequence minOccurs='0'>
        <xs:element name='ip' maxOccurs='unbounded' type='xs:string'/>
        <xs:element name='port' maxOccurs='unbounded' type='xs:positiveInteger' use='optional'/>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

</xs:schema>
]]></code>
</section1>

<section1 topic='Acknowledgements' anchor='ack'>
  <p>Thanks to Joe Hildebrand for his feedback.</p>
</section1>

</xep>
