Skip to content

Instantly share code, notes, and snippets.

@ndarilek
Created June 1, 2009 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ndarilek/121591 to your computer and use it in GitHub Desktop.
Save ndarilek/121591 to your computer and use it in GitHub Desktop.
require "rubygems"
require "blather/client"
module Test
extend Blather::DSL
setup("user@localhost/test", "secret", "localhost", 5222)
#setup("component.localhost", "secret", "localhost", 5347)
when_ready do
puts "Ready"
end
def self.run
client.run
end
end
EM.run do
Blather.logger.level = Logger::DEBUG
Test.run
end
D, [2009-06-01T11:41:42.718697 #13976] DEBUG -- : NEW JID: user@localhost/test
D, [2009-06-01T11:41:42.719382 #13976] DEBUG -- : SENDING: (/var/lib/gems/1.8/gems/blather-0.3.4/lib/blather/stream.rb:164:in `stopped') <stream:stream to='localhost' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en' >
D, [2009-06-01T11:41:42.720892 #13976] DEBUG -- :
------------------------------
D, [2009-06-01T11:41:42.721080 #13976] DEBUG -- : << <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='48262308' from='localhost' version='1.0'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism></mechanisms><auth xmlns='http://jabber.org/features/iq-auth'></auth></stream:features>
D, [2009-06-01T11:41:42.721195 #13976] DEBUG -- : PARSING: (<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='48262308' from='localhost' version='1.0'><stream:features><mechanisms xmlns='urn:ietf:params:xml:ns:xmpp-sasl'><mechanism>DIGEST-MD5</mechanism><mechanism>PLAIN</mechanism></mechanisms><auth xmlns='http://jabber.org/features/iq-auth'></auth></stream:features>)
D, [2009-06-01T11:41:42.721558 #13976] DEBUG -- : START ELEM: ({:ns=>{"stream"=>"http://etherx.jabber.org/streams", nil=>"jabber:client"}, :elem=>"stream", :uri=>"http://etherx.jabber.org/streams", :prefix=>"stream", :attrs=>{"from"=>"localhost", "id"=>"48262308", "version"=>"1.0"}})
D, [2009-06-01T11:41:42.722266 #13976] DEBUG -- : RECEIVING (stream) <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="localhost" id="48262308" version="1.0"/>
D, [2009-06-01T11:41:42.722755 #13976] DEBUG -- : START ELEM: ({:ns=>{}, :elem=>"features", :uri=>"http://etherx.jabber.org/streams", :prefix=>"stream", :attrs=>{}})
D, [2009-06-01T11:41:42.723191 #13976] DEBUG -- : START ELEM: ({:ns=>{nil=>"urn:ietf:params:xml:ns:xmpp-sasl"}, :elem=>"mechanisms", :uri=>"urn:ietf:params:xml:ns:xmpp-sasl", :prefix=>nil, :attrs=>{}})
D, [2009-06-01T11:41:42.723557 #13976] DEBUG -- : START ELEM: ({:ns=>{}, :elem=>"mechanism", :uri=>"urn:ietf:params:xml:ns:xmpp-sasl", :prefix=>nil, :attrs=>{}})
D, [2009-06-01T11:41:42.723796 #13976] DEBUG -- : CHARS: DIGEST-MD5
D, [2009-06-01T11:41:42.724005 #13976] DEBUG -- : END ELEM: {:elem=>"mechanism", :uri=>"urn:ietf:params:xml:ns:xmpp-sasl", :prefix=>nil}
D, [2009-06-01T11:41:42.724186 #13976] DEBUG -- : START ELEM: ({:ns=>{}, :elem=>"mechanism", :uri=>"urn:ietf:params:xml:ns:xmpp-sasl", :prefix=>nil, :attrs=>{}})
D, [2009-06-01T11:41:42.724403 #13976] DEBUG -- : CHARS: PLAIN
D, [2009-06-01T11:41:42.724578 #13976] DEBUG -- : END ELEM: {:elem=>"mechanism", :uri=>"urn:ietf:params:xml:ns:xmpp-sasl", :prefix=>nil}
D, [2009-06-01T11:41:42.724738 #13976] DEBUG -- : END ELEM: {:elem=>"mechanisms", :uri=>"urn:ietf:params:xml:ns:xmpp-sasl", :prefix=>nil}
D, [2009-06-01T11:41:42.724988 #13976] DEBUG -- : START ELEM: ({:ns=>{nil=>"http://jabber.org/features/iq-auth"}, :elem=>"auth", :uri=>"http://jabber.org/features/iq-auth", :prefix=>nil, :attrs=>{}})
D, [2009-06-01T11:41:42.725476 #13976] DEBUG -- : END ELEM: {:elem=>"auth", :uri=>"http://jabber.org/features/iq-auth", :prefix=>nil}
D, [2009-06-01T11:41:42.725688 #13976] DEBUG -- : END ELEM: {:elem=>"features", :uri=>"http://etherx.jabber.org/streams", :prefix=>"stream"}
D, [2009-06-01T11:41:42.725998 #13976] DEBUG -- : RECEIVING (features) <stream:features xmlns:stream="http://etherx.jabber.org/streams">
<mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<mechanism>DIGEST-MD5</mechanism>
<mechanism>PLAIN</mechanism>
</mechanisms>
<auth xmlns="http://jabber.org/features/iq-auth"/>
</stream:features>
D, [2009-06-01T11:41:42.726443 #13976] DEBUG -- : FEATURE: <mechanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl">
<mechanism>DIGEST-MD5</mechanism>
<mechanism>PLAIN</mechanism>
</mechanisms>
D, [2009-06-01T11:41:42.727115 #13976] DEBUG -- : SENDING: (/var/lib/gems/1.8/gems/blather-0.3.4/lib/blather/stream/sasl.rb:84:in `mechanisms') <auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="DIGEST-MD5"/>
D, [2009-06-01T11:41:42.729643 #13976] DEBUG -- :
------------------------------
D, [2009-06-01T11:41:42.729971 #13976] DEBUG -- : << <challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>bm9uY2U9IjYyODg3MDkyIixxb3A9ImF1dGgiLGNoYXJzZXQ9dXRmLTgsYWxnb3JpdGhtPW1kNS1zZXNzLHJlYWxtPSJsb2NhbGhvc3Qi</challenge>
D, [2009-06-01T11:41:42.730218 #13976] DEBUG -- : PARSING: (<challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>bm9uY2U9IjYyODg3MDkyIixxb3A9ImF1dGgiLGNoYXJzZXQ9dXRmLTgsYWxnb3JpdGhtPW1kNS1zZXNzLHJlYWxtPSJsb2NhbGhvc3Qi</challenge>)
D, [2009-06-01T11:41:42.730618 #13976] DEBUG -- : START ELEM: ({:ns=>{nil=>"urn:ietf:params:xml:ns:xmpp-sasl"}, :elem=>"challenge", :uri=>"urn:ietf:params:xml:ns:xmpp-sasl", :prefix=>nil, :attrs=>{}})
D, [2009-06-01T11:41:42.731229 #13976] DEBUG -- : CHARS: bm9uY2U9IjYyODg3MDkyIixxb3A9ImF1dGgiLGNoYXJzZXQ9dXRmLTgsYWxnb3JpdGhtPW1kNS1zZXNzLHJlYWxtPSJsb2NhbGhvc3Qi
D, [2009-06-01T11:41:42.731659 #13976] DEBUG -- : END ELEM: {:elem=>"challenge", :uri=>"urn:ietf:params:xml:ns:xmpp-sasl", :prefix=>nil}
D, [2009-06-01T11:41:42.732135 #13976] DEBUG -- : RECEIVING (challenge) <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">bm9uY2U9IjYyODg3MDkyIixxb3A9ImF1dGgiLGNoYXJzZXQ9dXRmLTgsYWxnb3JpdGhtPW1kNS1zZXNzLHJlYWxtPSJsb2NhbGhvc3Qi</challenge>
D, [2009-06-01T11:41:42.733166 #13976] DEBUG -- : CHALLENGE DECODE: {"algorithm"=>"md5-sess", "nonce"=>"62887092", "charset"=>"utf-8", "qop"=>"auth", "realm"=>"localhost"}
D, [2009-06-01T11:41:42.734249 #13976] DEBUG -- : CHALLENGE RESPONSE: {:username=>"\"user\"", :"digest-uri"=>"\"xmpp/localhost\"", :cnonce=>"\"ad13ad5bf83c9c584c6ff834ca87b7b8\"", :charset=>"utf-8", :response=>"a569447b4d610b2505605df02de2a787", :nc=>"00000001", :realm=>"\"localhost\"", :qop=>"auth", :nonce=>"\"62887092\""}
D, [2009-06-01T11:41:42.734682 #13976] DEBUG -- : CH RESP TXT: username="user",digest-uri="xmpp/localhost",cnonce="ad13ad5bf83c9c584c6ff834ca87b7b8",charset=utf-8,response=a569447b4d610b2505605df02de2a787,nc=00000001,realm="localhost",qop=auth,nonce="62887092"
D, [2009-06-01T11:41:42.735493 #13976] DEBUG -- : SENDING: (/var/lib/gems/1.8/gems/blather-0.3.4/lib/blather/stream/sasl.rb:100:in `challenge') <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl">bm9uY2U9IjYyODg3MDkyIixjaGFyc2V0PXV0Zi04LHVzZXJuYW1lPSJ1c2VyIixyZWFsbT0ibG9jYWxob3N0Iixjbm9uY2U9ImFkMTNhZDViZjgzYzljNTg0YzZmZjgzNGNhODdiN2I4IixuYz0wMDAwMDAwMSxxb3A9YXV0aCxkaWdlc3QtdXJpPSJ4bXBwL2xvY2FsaG9zdCIscmVzcG9uc2U9YTU2OTQ0N2I0ZDYxMGIyNTA1NjA1ZGYwMmRlMmE3ODc=</response>
D, [2009-06-01T11:41:42.738030 #13976] DEBUG -- :
------------------------------
D, [2009-06-01T11:41:42.738307 #13976] DEBUG -- : << <challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>cnNwYXV0aD1jMWY3NzZiM2Y5ZDViNzg4ZDE4YjcwOTc1MmVjNTU0Mw==</challenge>
D, [2009-06-01T11:41:42.738522 #13976] DEBUG -- : PARSING: (<challenge xmlns='urn:ietf:params:xml:ns:xmpp-sasl'>cnNwYXV0aD1jMWY3NzZiM2Y5ZDViNzg4ZDE4YjcwOTc1MmVjNTU0Mw==</challenge>)
D, [2009-06-01T11:41:42.738912 #13976] DEBUG -- : START ELEM: ({:ns=>{nil=>"urn:ietf:params:xml:ns:xmpp-sasl"}, :elem=>"challenge", :uri=>"urn:ietf:params:xml:ns:xmpp-sasl", :prefix=>nil, :attrs=>{}})
D, [2009-06-01T11:41:42.739373 #13976] DEBUG -- : CHARS: cnNwYXV0aD1jMWY3NzZiM2Y5ZDViNzg4ZDE4YjcwOTc1MmVjNTU0Mw==
D, [2009-06-01T11:41:42.739695 #13976] DEBUG -- : END ELEM: {:elem=>"challenge", :uri=>"urn:ietf:params:xml:ns:xmpp-sasl", :prefix=>nil}
D, [2009-06-01T11:41:42.740129 #13976] DEBUG -- : RECEIVING (challenge) <challenge xmlns="urn:ietf:params:xml:ns:xmpp-sasl">cnNwYXV0aD1jMWY3NzZiM2Y5ZDViNzg4ZDE4YjcwOTc1MmVjNTU0Mw==</challenge>
D, [2009-06-01T11:41:42.740862 #13976] DEBUG -- : CHALLENGE DECODE: {"rspauth"=>"c1f776b3f9d5b788d18b709752ec5543"}
D, [2009-06-01T11:41:42.741574 #13976] DEBUG -- : SENDING: (/var/lib/gems/1.8/gems/blather-0.3.4/lib/blather/stream/sasl.rb:100:in `challenge') <response xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
D, [2009-06-01T11:41:42.743845 #13976] DEBUG -- :
------------------------------
D, [2009-06-01T11:41:42.744230 #13976] DEBUG -- : << <success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'></success>
D, [2009-06-01T11:41:42.744479 #13976] DEBUG -- : PARSING: (<success xmlns='urn:ietf:params:xml:ns:xmpp-sasl'></success>)
D, [2009-06-01T11:41:42.744855 #13976] DEBUG -- : START ELEM: ({:ns=>{nil=>"urn:ietf:params:xml:ns:xmpp-sasl"}, :elem=>"success", :uri=>"urn:ietf:params:xml:ns:xmpp-sasl", :prefix=>nil, :attrs=>{}})
D, [2009-06-01T11:41:42.745453 #13976] DEBUG -- : END ELEM: {:elem=>"success", :uri=>"urn:ietf:params:xml:ns:xmpp-sasl", :prefix=>nil}
D, [2009-06-01T11:41:42.745975 #13976] DEBUG -- : RECEIVING (success) <success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>
D, [2009-06-01T11:41:42.746614 #13976] DEBUG -- : SASL SUCCESS
D, [2009-06-01T11:41:42.747218 #13976] DEBUG -- : SENDING: (/var/lib/gems/1.8/gems/blather-0.3.4/lib/blather/stream.rb:220:in `authenticate_sasl') <stream:stream to='localhost' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' xml:lang='en' >
D, [2009-06-01T11:41:42.749401 #13976] DEBUG -- :
------------------------------
D, [2009-06-01T11:41:42.749677 #13976] DEBUG -- : << <?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='37113662' from='localhost' version='1.0'><stream:features><ver xmlns='urn:xmpp:features:rosterver'><optional></optional></ver><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><required></required></bind><session xmlns='urn:ietf:params:xml:ns:xmpp-session'></session><feature var='vcard-temp'></feature></stream:features>
D, [2009-06-01T11:41:42.749960 #13976] DEBUG -- : PARSING: (<?xml version='1.0'?><stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' id='37113662' from='localhost' version='1.0'><stream:features><ver xmlns='urn:xmpp:features:rosterver'><optional></optional></ver><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><required></required></bind><session xmlns='urn:ietf:params:xml:ns:xmpp-session'></session><feature var='vcard-temp'></feature></stream:features>)
D, [2009-06-01T11:41:42.750441 #13976] DEBUG -- : START ELEM: ({:ns=>{"stream"=>"http://etherx.jabber.org/streams", nil=>"jabber:client"}, :elem=>"stream", :uri=>"http://etherx.jabber.org/streams", :prefix=>"stream", :attrs=>{"from"=>"localhost", "id"=>"37113662", "version"=>"1.0"}})
D, [2009-06-01T11:41:42.751278 #13976] DEBUG -- : RECEIVING (stream) <stream:stream xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" from="localhost" id="37113662" version="1.0"/>
D, [2009-06-01T11:41:42.751972 #13976] DEBUG -- : START ELEM: ({:ns=>{}, :elem=>"features", :uri=>"http://etherx.jabber.org/streams", :prefix=>"stream", :attrs=>{}})
D, [2009-06-01T11:41:42.752631 #13976] DEBUG -- : START ELEM: ({:ns=>{nil=>"urn:xmpp:features:rosterver"}, :elem=>"ver", :uri=>"urn:xmpp:features:rosterver", :prefix=>nil, :attrs=>{}})
D, [2009-06-01T11:41:42.753288 #13976] DEBUG -- : START ELEM: ({:ns=>{}, :elem=>"optional", :uri=>"urn:xmpp:features:rosterver", :prefix=>nil, :attrs=>{}})
D, [2009-06-01T11:41:42.753890 #13976] DEBUG -- : END ELEM: {:elem=>"optional", :uri=>"urn:xmpp:features:rosterver", :prefix=>nil}
D, [2009-06-01T11:41:42.754266 #13976] DEBUG -- : END ELEM: {:elem=>"ver", :uri=>"urn:xmpp:features:rosterver", :prefix=>nil}
D, [2009-06-01T11:41:42.754677 #13976] DEBUG -- : START ELEM: ({:ns=>{nil=>"urn:ietf:params:xml:ns:xmpp-bind"}, :elem=>"bind", :uri=>"urn:ietf:params:xml:ns:xmpp-bind", :prefix=>nil, :attrs=>{}})
D, [2009-06-01T11:41:42.755314 #13976] DEBUG -- : START ELEM: ({:ns=>{}, :elem=>"required", :uri=>"urn:ietf:params:xml:ns:xmpp-bind", :prefix=>nil, :attrs=>{}})
D, [2009-06-01T11:41:42.755887 #13976] DEBUG -- : END ELEM: {:elem=>"required", :uri=>"urn:ietf:params:xml:ns:xmpp-bind", :prefix=>nil}
D, [2009-06-01T11:41:42.756257 #13976] DEBUG -- : END ELEM: {:elem=>"bind", :uri=>"urn:ietf:params:xml:ns:xmpp-bind", :prefix=>nil}
D, [2009-06-01T11:41:42.756677 #13976] DEBUG -- : START ELEM: ({:ns=>{nil=>"urn:ietf:params:xml:ns:xmpp-session"}, :elem=>"session", :uri=>"urn:ietf:params:xml:ns:xmpp-session", :prefix=>nil, :attrs=>{}})
D, [2009-06-01T11:41:42.757442 #13976] DEBUG -- : END ELEM: {:elem=>"session", :uri=>"urn:ietf:params:xml:ns:xmpp-session", :prefix=>nil}
D, [2009-06-01T11:41:42.757969 #13976] DEBUG -- : START ELEM: ({:ns=>{}, :elem=>"feature", :uri=>"jabber:client", :prefix=>nil, :attrs=>{"var"=>"vcard-temp"}})
D, [2009-06-01T11:41:42.758579 #13976] DEBUG -- : END ELEM: {:elem=>"feature", :uri=>"jabber:client", :prefix=>nil}
D, [2009-06-01T11:41:42.758950 #13976] DEBUG -- : END ELEM: {:elem=>"features", :uri=>"http://etherx.jabber.org/streams", :prefix=>"stream"}
D, [2009-06-01T11:41:42.759406 #13976] DEBUG -- : RECEIVING (features) <stream:features xmlns:stream="http://etherx.jabber.org/streams">
<ver xmlns="urn:xmpp:features:rosterver">
<optional/>
</ver>
<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">
<required/>
</bind>
<session xmlns="urn:ietf:params:xml:ns:xmpp-session"/>
<stream:feature var="vcard-temp"/>
</stream:features>
D, [2009-06-01T11:41:42.760179 #13976] DEBUG -- : FEATURE: <ver xmlns="urn:xmpp:features:rosterver">
<optional/>
</ver>
Run with test.rb [options] user@server/resource password [host] [port]
-D, --debug Run in debug mode (you will see all XMPP communication)
-d, --daemonize Daemonize the process
--pid=[PID] Write the PID to this file
--log=[LOG] Write to the [LOG] file instead of stdout/stderr
-h, --help Show this message
-v, --version Show version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment