XMPP仕様簡単解説

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    2 Favorites & 1 Group

    XMPP仕様簡単解説 - Presentation Transcript

    1.  
    2. 規格
      • RFC2779: IM requirements
      • RFC3920: XMPP Core
      • RFC3921: XMPP IM & Presence
      • XEP-0030: Service Discovery
      • XEP-0045: Multi-User Chat
      沢山あるけど,基本はこんな感じ
    3. JID 各パーツは 1023B 以下 “ @ “ とか “ / “ とかも含めて 3071B 以下 IPv4address / IPv6address = address-literal ( internationalized domain label ) = sub-domain ( sub-domain 1 * ( “ . “ sub-domain ) ) = fqdn fqdn / address-literal = domain [ node “ @ ” ] domain [ “ / ” resource ] = jid
    4. メッセージ転送 ( client / server )
      • JID の to 属性の hostname がサーバ名と一致
      • to 属性に書かれた JID が以下の場合
        • < user @ example . com >
        • < user @ example . com / resource >
      < user @ example . com > < user @ example . com / resouce > 一致するアカウントがなければ無視,もしくはエラー
      • 一致するリソースがなければ
      • presense: 無視
      • iq: エラー
      • message: < user @ domain > と同様の処理
      • リソースが複数ある場合( message の場合)
      • プライオリ値最大のリソースに配信
      • priority 宣言がなければ 0 相当
      • priority が負の場合には配信禁止
    5. メッセージ転送 ( server / server )
      • _xmpp-server . _tcp . example . com で DNS を検索
      • _im . < proto > . example . com で DNS を検索( IM の場合) _pres . < proto > . example . com で DNS を検索( presence, iq の場合)
      • DNS で A レコードを検索して, TCP 5269 にアクセス(サーバ間通信)
      • サーバクライアント間通信の場合,サーバが使うのは TCP 5222
    6. セッション TCP TLS SASL Resource Binding ( user @ domain / resource ) クライアント サーバ < session / > < message / >, < presence / > option メッセージの やりとりをする までに必要な 設定
    7. message syntax
      • < message type = “ chat “ / >
      • < message type = “ error “ / >
      • < message type = “ groupchat “ / >
      • < message type = “ headline “ / >
        • 配信やブロードキャストで使用
      • < message type = “ normal “ / >
        • type で何も指定していなかったり,理解できない指定があった場合に適用
      • message の子要素は option
      • 以下の要素は namespace を指定せずに使用可
        • < message >< subject / >< / message >
        • < message >< body / >< / message >
        • < message >< thread / >< / message >
    8. IQ ( Info / Query ) syntax Requesting Entity Responding Entity < iq type = ‘ get ‘ id = ‘ 1 ‘ > < iq type = ‘ result ‘ id = ‘ 1 ‘ > < iq type = ‘ set ‘ id = ‘ 2 ‘ > < iq type = ‘ error ‘ id = ‘ 2 ‘ > type 属性は4 種類 理由がない限り必須 id 属性も理由がない限り必須
    9. Psi2OpenFire (設定)
      • Psi の設定
        • Connection proxy: None
        • Compress traffic: No
        • Send &quot;keep-alive&quot; packets: Yes
        • Manually Specify Server Host/Port: No
        • Encrypt connection: When available
        • Ignore SSL warnings: No ← こうすると,エラーが出て来るけど continue する
        • Probe legacy SSL port: No ← ここを No にすると明示的に TLS を使う
        • Allow plaintext authentication: Never
      • XML Console を開くと,赤字で C2S ストリーム,黄字で S2C ストリーム表示
      • OpenFire はほぼ Default 設定で,ユーザを一人分設定
    10. Psi2OpenFire ( TLS 開設まで) -- C2S— <?xml version=&quot;1.0&quot;?> <stream:stream xmlns:stream=&quot;http://etherx.jabber.org/streams&quot; version=&quot;1.0&quot; xmlns=&quot;jabber:client&quot; to=&quot;foo.hoge.co.jp&quot; xml:lang=&quot;en&quot; xmlns:xml=&quot;http://www.w3.org/XML/1998/namespace&quot; > -- S2C -- <?xml version='1.0' encoding='UTF-8'?> <stream:stream xmlns:stream=&quot;http://etherx.jabber.org/streams&quot; xmlns=&quot;jabber:client&quot; from=&quot;foo.hoge.co.jp&quot; id=&quot;b9a694d9&quot; xml:lang=&quot;en&quot; version=&quot;1.0&quot;> -- S2C -- -- TLS による通信要求 -- <stream:features> <starttls xmlns=&quot;urn:ietf:params:xml:ns:xmpp-tls&quot;/> <mechanisms xmlns=&quot;urn:ietf:params:xml:ns:xmpp-sasl&quot;> <mechanism>PLAIN</mechanism> <mechanism>CRAM-MD5</mechanism> <mechanism>ANONYMOUS</mechanism> <mechanism>DIGEST-MD5</mechanism> </mechanisms> <compression xmlns=&quot;http://jabber.org/features/compress&quot;> <method>zlib</method> </compression> <auth xmlns=&quot;http://jabber.org/features/iq-auth&quot;/> <register xmlns=&quot;http://jabber.org/features/iq-register&quot;/> </stream:features> -- C2S -- -- TLS による通信開始 -- <starttls xmlns=&quot;urn:ietf:params:xml:ns:xmpp-tls&quot;/> -- S2C -- -- サーバが TLS 開始を確認 -- <proceed xmlns=&quot;urn:ietf:params:xml:ns:xmpp-tls&quot;/> よくみると,サーバは一度に要求 してるが,クライアントはひとつずつ 応えている
    11. セッション TCP TLS SASL Resource Binding ( user @ domain / resource ) クライアント サーバ < session / > < message / >, < presence / > option メッセージの やりとりをする までに必要な 設定
    12. Psi2OpenFire ( SASL 開設まで) -- C2S -- -- TLS による通信開始 -- <?xml version=&quot;1.0&quot;?> <stream:stream xmlns:stream=&quot;http://etherx.jabber.org/streams&quot; version=&quot;1.0&quot; xmlns=&quot;jabber:client&quot; to=&quot;foo.hoge.co.jp&quot; xml:lang=&quot;en&quot; xmlns:xml=&quot;http://www.w3.org/XML/1998/namespace&quot; > -- S2C -- -- サーバからの応答開始 -- <?xml version='1.0' encoding='UTF-8'?> <stream:stream xmlns:stream=&quot;http://etherx.jabber.org/streams&quot; xmlns=&quot;jabber:client&quot; from=&quot;foo.hoge.co.jp&quot; id=&quot;b9a694d9&quot; xml:lang=&quot;en&quot; version=&quot;1.0&quot;> -- S2C -- -- SASL 要求 -- <stream:features> <mechanisms xmlns=&quot;urn:ietf:params:xml:ns:xmpp-sasl&quot;> <mechanism>PLAIN</mechanism> <mechanism>CRAM-MD5</mechanism> <mechanism>ANONYMOUS</mechanism> <mechanism>DIGEST-MD5</mechanism> </mechanisms> <compression xmlns=&quot;http://jabber.org/features/compress&quot;> <method>zlib</method> </compression> <auth xmlns=&quot;http://jabber.org/features/iq-auth&quot;/> <register xmlns=&quot;http://jabber.org/features/iq-register&quot;/> </stream:features> -- C2S -- <auth xmlns=&quot;urn:ietf:params:xml:ns:xmpp-sasl“ mechanism=&quot;DIGEST-MD5&quot; /> -- S2C -- <challenge xmlns=&quot;urn:ietf:params:xml:ns:xmpp-sasl&quot;>...</challenge> -- C2S -- -- クライアントがレスポンスを送信 -- <response xmlns=&quot;urn:ietf:params:xml:ns:xmpp-sasl&quot;>...</response> -- S2C -- -- サーバが認証成功宣言 -- <success xmlns=&quot;urn:ietf:params:xml:ns:xmpp-sasl&quot;>...</success> GTalk は SSL を使ってるので TLS での通信要求はでない
    13. セッション TCP TLS SASL Resource Binding ( user @ domain / resource ) クライアント サーバ < session / > < message / >, < presence / > option メッセージの やりとりをする までに必要な 設定
    14. Psi2OpenFire (圧縮モード設定まで) -- C2S -- -- SASL ベースで再度アクセス -- <?xml version=&quot;1.0&quot;?> <stream:stream xmlns:stream=&quot;http://etherx.jabber.org/streams&quot; version=&quot;1.0&quot; xmlns=&quot;jabber:client&quot; to=&quot;foo.hoge.co.jp&quot; xml:lang=&quot;en&quot; xmlns:xml=&quot;http://www.w3.org/XML/1998/namespace&quot; > -- S2C -- -- サーバ応答 -- <?xml version='1.0' encoding='UTF-8'?> <stream:stream xmlns:stream=&quot;http://etherx.jabber.org/streams&quot; xmlns=&quot;jabber:client&quot; from=&quot;foo.hoge.co.jp&quot; id=&quot;b9a694d9&quot; xml:lang=&quot;en&quot; version=&quot;1.0&quot;> -- S2C -- -- traffic を圧縮するかどうかを確認してる -- -- Psi で &quot;Compress traffic&quot; にチェックしてないので無反応 -- <stream:features> <compression xmlns=&quot;http://jabber.org/features/compress&quot;> <method>zlib</method> </compression> <bind xmlns=&quot;urn:ietf:params:xml:ns:xmpp-bind&quot;/> <session xmlns=&quot;urn:ietf:params:xml:ns:xmpp-session&quot;/> </stream:features>
    15. Psi2OpenFire ( Roster 取得まで) -- C2S -- -- Client asks server to bind a resource: -- -- RFC3920 7. Resource Binding -- <iq type=&quot;set&quot; id=&quot;bind_1&quot; > <bind xmlns=&quot;urn:ietf:params:xml:ns:xmpp-bind&quot;> <resource>Psi</resource> </bind> </iq> -- S2C -- -- Server informs client of successful resource binding: -- -- RFC3920 7. Resource Binding -- <iq xmlns=&quot;jabber:client&quot; type=&quot;result&quot; id=&quot;bind_1&quot; to=&quot;foo.hoge.co.jp/b9a694d9&quot; > <bind xmlns=&quot;urn:ietf:params:xml:ns:xmpp-bind&quot;> <jid> daiba@foo.hoge.co.jp/Psi </jid> </bind> </iq> -- C2S -- -- Client requests session with server: -- -- RFC3921 3. Session Establishment -- <iq type=&quot;set&quot; id=&quot;aab5a&quot; > <session xmlns=&quot;urn:ietf:params:xml:ns:xmpp-session&quot;/> </iq> -- S2C -- --Server informs client that session has been created -- -- この段階で &quot;active resource&quot; としてサーバに登録された -- <iq type=&quot;result&quot; id=&quot;aab5a&quot; to=&quot;daiba@foo.hoge.co.jp/Psi&quot; > <session xmlns=&quot;urn:ietf:params:xml:ns:xmpp-session&quot;/> </iq> -- C2S -- -- Client requests current roster from server: -- -- 7.3. Retrieving One's Roster on Login -- <iq type=&quot;get&quot; id=&quot;aab6a&quot; > <query xmlns=&quot;jabber:iq:roster&quot;/> </iq> -- S2C -- -- Client receives roster from server: -- <iq type=&quot;result&quot; id=&quot;aab6a&quot; to=&quot;daiba@foo.hoge.co.jp/Psi&quot; > <query xmlns=&quot;jabber:iq:roster&quot;/> </iq> resource ってのは, [email_address] / Psi の “ Psi “ の部分
    16. Psi2OpenFire ( Priority 設定まで) -- C2S -- -- Presence priority: -- -- RFC3921 5.4. Specifying Presence Priority -- <presence> <priority>5</priority> <c xmlns=&quot;http://jabber.org/protocol/caps&quot; node=&quot;http://psi-im.org/caps&quot; ver=&quot;0.11-dev-rev8&quot; ext=&quot;cs ep-notify html&quot; /> </presence>
    17. Psi2GoogleTalk ( Roster 取得) -- C2S -- -- Client requests current roster from server: -- -- 7.3. Retrieving One's Roster on Login -- <iq type=&quot;get&quot; id=&quot;aab6a&quot; > <query xmlns=&quot;jabber:iq:roster&quot;/> </iq> -- S2C -- -- Client receives roster from server: -- <iq type=&quot;result&quot; to=&quot;daibak@gmail.com/griffin9EB3DE9D&quot; id=&quot;aab6a&quot; > <query xmlns=&quot;jabber:iq:roster&quot;> <item subscription=“both” name=“ 誰か &quot; jid=“noname@gmail.com&quot; /> <item subscription=&quot;both&quot; jid=&quot;twitter@twitter.com&quot; /> <item subscription=&quot;both&quot; jid=&quot;jaiku@jaiku.com&quot; > <group>Buddies</group> </item> </query> </iq>
    18. Psi2GoogleTalk ( vCard 取得) -- C2S -- -- vCard Action: Resulting Stanza -- -- XEP-0054 6.2 URI Query Types -- <iq type=&quot;get&quot; to=&quot;daibak@gmail.com&quot; id=&quot;aab9a&quot; > <vCard xmlns=&quot;vcard-temp“ version=&quot;2.0“ prodid=&quot;-//HandGen//NONSGML vGen v1.0//EN&quot; /> </iq> <iq from= [email_address] type=&quot;result“ to=daibak@gmail.com/griffin9EB3DE9D id=&quot;aab9a&quot; > <vCard xmlns=&quot;vcard-temp&quot;> <FN>Keiichi daiba</FN> <PHOTO> <TYPE>image/jpeg</TYPE> <BINVAL>...</BINVAL> </PHOTO> </vCard> </iq> バイナリデータをBasa64? 変換して埋め込んである
    19. Psi2GoogleTalk (メッセージ送受信) -- BOT にメッセージを送る -- <message type=&quot;chat&quot; to=&quot;en2ja@bot.talk.google.com&quot; id=&quot;aabea&quot; > <body>general</body> <active xmlns=&quot;http://jabber.org/protocol/chatstates&quot;/> </message> <message from=&quot;en2ja@bot.talk.google.com&quot; type=&quot;chat&quot; to=&quot;daibak@gmail.com/griffinEB79CC3A&quot; > <body> 全般 </body> </message>
    20. Psi2OpenFire (ルーム作成) -- C2S -- -- チャットルーム作成 -- <presence to=&quot;test@ conference .foo.hoge.co.jp/test&quot; > <priority>0</priority> <x xmlns=&quot;http://jabber.org/protocol/muc&quot;> <history maxchars=&quot;0&quot; /> </x> </presence> -- S2C – -- 成功 -- <presence from=test@conference.foo.hoge.co.jp/test to=“daiba@foo.hoge.co.jp/Psi&quot; > <priority>0</priority> <x xmlns=&quot;http://jabber.org/protocol/muc#user&quot;> <item affiliation=&quot;owner“ role=&quot;moderator“ jid=“daiba@foo.hoge.co.jp/Psi&quot; /> <status code=&quot;201&quot; /> </x> </presence> “ conference “ は OpenFire のデフォルト設定 ルーム名 “ test “ ,ニックネームも “ test “ -- C2S -- <iq type=&quot;set&quot; to=&quot;test@conference.foo.hoge.co.jp&quot; id=&quot;aac1a&quot; > <query xmlns=&quot;http://jabber.org/protocol/muc#owner&quot;> <x xmlns=&quot;jabber:x:data&quot; type=&quot;submit&quot; /> </query> </iq> -- S2C – <message from=test@conference.foo.hoge.co.jp type=&quot;groupchat“ to=“daiba@foo.hoge.co.jp/Psi&quot; > <body> This room is locked from entry until configuration is confirmed. </body> </message> <message from=test@conference.foo.hoge.co.jp type=&quot;groupchat“ to=“daiba@foo.hoge.co.jp/Psi&quot; > <body>This room is now unlocked.</body> </message> 作成した状態ではLOCKされてるので submit してUNLOCK
    21. Psi2OpenFire (設定確認) -- C2S -- -- 設定確認 – <iq from=‘daiba@foo.hoge.co.jp/Psi' id='config1' to='test@conference.foo.hoge.co.jp' type='get'> <query xmlns='http://jabber.org/protocol/muc#owner'/> </iq> -- S2C -- -- 確認したデータ -- <iq from=test@conference.foo.hoge.co.jp type=&quot;result“ id=&quot;config1“ to=“daiba@foo.hoge.co.jp/Psi&quot; > <query xmlns=&quot;http://jabber.org/protocol/muc#owner&quot;> <x xmlns=&quot;jabber:x:data&quot; type=&quot;form&quot; > <title>Room configuration</title> <instructions>...</instructions> <field type=&quot;hidden&quot; var=&quot;FORM_TYPE&quot; > <value>http://jabber.org/protocol/muc#roomconfig</value> </field> <field type=&quot;text-single“ label=&quot;Room Name“ var=&quot;muc#roomconfig_roomname&quot; > <value>test</value> </field> ... <field type=&quot;list-single“ label=&quot;Maximum Room Occupants“ var=&quot;muc#roomconfig_maxusers&quot; > <value>30</value> <option label=&quot;10&quot; > <value>10</value> </option> <option label=&quot;20&quot; > <value>20</value> </option> <option label=&quot;30&quot; > <value>30</value> </option> <option label=&quot;40&quot; > <value>40</value> </option> <option label=&quot;50&quot; > <value>50</value> </option> <option label=&quot;None&quot; > <value>0</value> </option> </field> ... </x> </query> </iq> 初期設定で, 参加可能な人数は30 パラメータを何も 指定しないとすべての 設定を返す
    22. Psi2OpenFire (設定変更) -- 設定変更 -- -- C2S -- <iq from=‘daiba@foo.hoge.co.jp/Psi' id='create2' to='test@conference.foo.hoge.co.jp' type='set'> <query xmlns='http://jabber.org/protocol/muc#owner'> <x xmlns='jabber:x:data' type='submit'> <field var='muc#roomconfig_maxusers'> <value>0</value> </field> </x> </query> </iq> -- S2C -- <iq from=test@conference.turk.nttr.co.jp type=&quot;result“ id=&quot;create2“ to=“daiba@foo.hoge.co.jp/Psi&quot; /> Psi の XML コンソールを使って手動で XML 送信 < value > 0 < / value > が最大入室無制限

    daibadaiba, 2 years ago

    custom

    3686 views, 2 favs, 1 embeds more stats

    XMPPの仕様を簡単に解説します

    More Info

    © All Rights Reserved

    Go to text version
    • Total Views 3686
      • 3612 on SlideShare
      • 74 from embeds
    • Comments 0
    • Favorites 2
    • Downloads 33
    Most viewed embeds
    • 74 views on http://d.hatena.ne.jp

    more

    All embeds
    • 74 views on http://d.hatena.ne.jp

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as innappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel