Skip to content
Browse files

add resource attribute for XMPP (TSUN-174).

  • Loading branch information...
1 parent 4d370ef commit a0905a12aee81b085cd5031f7f6bce24e72a5282 @nniclausse nniclausse committed
View
7 doc/user_manual.html
@@ -96,7 +96,7 @@
<!--CUT DEF section 1 --><H1 ALIGN=center>Tsung User’s manual</H1><DIV CLASS="center">
<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1><TR><TD ALIGN=left NOWRAP bgcolor="#F2F2F2"> Version:</TD><TD ALIGN=left NOWRAP>1.4.2</TD></TR>
-<TR><TD ALIGN=left NOWRAP bgcolor="#F2F2F2"> Date :</TD><TD ALIGN=left NOWRAP>January 4, 2012</TD></TR>
+<TR><TD ALIGN=left NOWRAP bgcolor="#F2F2F2"> Date :</TD><TD ALIGN=left NOWRAP>January 9, 2012</TD></TR>
</TABLE>
</DIV><!--TOC section Contents-->
<H2 CLASS="section"><!--SEC ANCHOR -->Contents</H2><!--SEC END --><UL CLASS="toc"><LI CLASS="li-toc">
@@ -1994,7 +1994,10 @@ <H5 CLASS="paragraph"><!--SEC ANCHOR -->raw XML</H5><!--SEC END --><P>
</TABLE></TD></TR>
</TABLE></TD></TR>
</TABLE><P>Beware: you must encode XML characters like <FONT COLOR=purple>&lt;</FONT>
-,<FONT COLOR=purple>&gt;</FONT>, <FONT COLOR=purple>&amp;</FONT>, etc.</P><!--TOC subsubsection PostgreSQL-->
+,<FONT COLOR=purple>&gt;</FONT>, <FONT COLOR=purple>&amp;</FONT>, etc.</P><!--TOC paragraph resource-->
+<H5 CLASS="paragraph"><!--SEC ANCHOR -->resource</H5><!--SEC END --><P>By default, the XMPP resource is set to <FONT COLOR=purple>tsung</FONT>. Since
+version 1.4.3, you can override this (in all <TT>auth_*</TT> and
+<TT>register</TT> requests) using the <TT>resource</TT> attribute.</P><!--TOC subsubsection PostgreSQL-->
<H4 CLASS="subsubsection"><!--SEC ANCHOR --><A NAME="htoc59">6.6.4</A>  PostgreSQL</H4><!--SEC END --><P>For PostgreSQL, 4 types of requests are available:
</P><OL CLASS="enumerate" type=1><LI CLASS="li-enumerate">
connect (to a given database with a given username
View
6 doc/user_manual.tex
@@ -1618,6 +1618,12 @@ \subsubsection{Jabber/XMPP}
Beware: you must encode XML characters like \userinput{<}
,\userinput{>}, \userinput{\&}, etc.
+\paragraph{resource}
+
+By default, the XMPP resource is set to \userinput{tsung}. Since
+version 1.4.3, you can override this (in all \varname{auth\_*} and
+\varname{register} requests) using the \varname{resource} attribute.
+
\subsubsection{PostgreSQL}
For PostgreSQL, 4 types of requests are available:
View
1 include/ts_jabber.hrl
@@ -49,6 +49,7 @@
pubsub_service, %%ej: pubsub.localhost
group, %% roster group
node, %% pubsub node
+ resource,
node_type
}).
View
38 src/tsung/ts_jabber_common.erl
@@ -296,54 +296,54 @@ auth_get(Username, _Passwd, Type) ->
%%----------------------------------------------------------------------
%% Func: auth_set_plain/1
%%----------------------------------------------------------------------
-auth_set_plain(#jabber{username=Name,passwd=Passwd})->
- auth_set_plain(Name, Passwd, "auth").
+auth_set_plain(#jabber{username=Name,passwd=Passwd,resource=Resource})->
+ auth_set_plain(Name, Passwd, "auth", Resource).
%%----------------------------------------------------------------------
%% Func: auth_set_plain/3
%%----------------------------------------------------------------------
-auth_set_plain(Username, Passwd, Type) ->
+auth_set_plain(Username, Passwd, Type, Resource) ->
list_to_binary([
"<iq id='", ts_msg_server:get_id(list),
"' type='set' >",
"<query xmlns='jabber:iq:", Type, "'>",
"<username>", Username, "</username>",
- "<resource>tsung</resource>",
+ "<resource>", Resource,"</resource>",
"<password>", Passwd, "</password></query></iq>"]).
%%----------------------------------------------------------------------
%% Func: auth_set_digest/2
%%----------------------------------------------------------------------
-auth_set_digest(#jabber{username=Name,passwd=Passwd}, Sid)->
- auth_set_digest(Name, Passwd, "auth", Sid).
+auth_set_digest(#jabber{username=Name,passwd=Passwd, resource=Resource}, Sid)->
+ auth_set_digest(Name, Passwd, "auth", Sid, Resource).
%%----------------------------------------------------------------------
%% Func: auth_set_digest/4
%%----------------------------------------------------------------------
-auth_set_digest(Username, Passwd, Type, Sid) ->
+auth_set_digest(Username, Passwd, Type, Sid, Resource) ->
{Digest} = ts_digest:digest(Sid, Passwd),
list_to_binary([
"<iq id='", ts_msg_server:get_id(list),
"' type='set' >",
"<query xmlns='jabber:iq:", Type, "'>",
"<username>", Username, "</username>",
- "<resource>tsung</resource>",
+ "<resource>",Resource,"</resource>",
"<digest>", Digest, "</digest></query></iq>"]).
%%----------------------------------------------------------------------
%% Func: auth_set_sip/3
%%----------------------------------------------------------------------
-auth_set_sip(#jabber{username=Name,passwd=Passwd,domain=Domain}, Nonce, Realm)->
- auth_set_sip(Name, Passwd, Domain, "auth", Nonce, Realm).
+auth_set_sip(#jabber{username=Name,passwd=Passwd,domain=Domain,resource=Resource}, Nonce, Realm)->
+ auth_set_sip(Name, Passwd, Domain, "auth", Nonce, Realm,Resource).
%%----------------------------------------------------------------------
%% Func: auth_set_sip/6
%%----------------------------------------------------------------------
-auth_set_sip(Username, Passwd, Domain, Type, Nonce, Realm) ->
+auth_set_sip(Username, Passwd, Domain, Type, Nonce, Realm,Resource) ->
Jid = Username ++ "@" ++ Realm,
{SipDigest,Integrity} = ts_digest:sip_digest(Nonce, Jid, Realm, Passwd),
list_to_binary([
@@ -351,7 +351,7 @@ auth_set_sip(Username, Passwd, Domain, Type, Nonce, Realm) ->
"' type='set' >",
"<query xmlns='jabber:iq:", Type, "'>",
"<username>", Jid, "</username>",
- "<resource>tsung</resource>",
+ "<resource>",Resource,"</resource>",
"<x xmlns='xmpp:assert' version='1.0'>",
"<ContextInfo><ServiceValue><Realm>", Domain,
"</Realm></ServiceValue></ContextInfo>",
@@ -387,16 +387,18 @@ auth_sasl(Username, Passwd, Mechanism) ->
%%----------------------------------------------------------------------
%% Func: auth_sasl_bind/1
%%----------------------------------------------------------------------
-auth_sasl_bind(#jabber{username=Name,passwd=Passwd,domain=Domain})->
- auth_sasl_bind(Name, Passwd, Domain).
+auth_sasl_bind(#jabber{username=Name,passwd=Passwd,domain=Domain, resource=Resource})->
+ auth_sasl_bind(Name, Passwd, Domain, Resource).
%%----------------------------------------------------------------------
%% Func: auth_sasl_bind/3
%%----------------------------------------------------------------------
-auth_sasl_bind(_Username, _Passwd, _Domain) ->
+auth_sasl_bind(_Username, _Passwd, _Domain, Resource) ->
list_to_binary(["<iq type='set' id='",ts_msg_server:get_id(list),
-"' ><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource>tsung</resource></bind></iq>"]).
+ "' ><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'>",
+ "<resource>",Resource,"</resource>",
+ "</bind></iq>"]).
%%----------------------------------------------------------------------
@@ -417,8 +419,8 @@ auth_sasl_session(_Username, _Passwd, _Domain) ->
%% Func: registration/1
%% Purpose: register message
%%----------------------------------------------------------------------
-registration(#jabber{username=Name,passwd=Passwd})->
- auth_set_plain(Name, Passwd, "register").
+registration(#jabber{username=Name,passwd=Passwd,resource=Resource})->
+ auth_set_plain(Name, Passwd, "register",Resource).
%%----------------------------------------------------------------------
%% Func: message/3
View
2 src/tsung_controller/ts_config_jabber.erl
@@ -58,6 +58,7 @@ parse_config(Element = #xmlElement{name=jabber},
Data= ts_config:getAttr(string,Element#xmlElement.attributes, data,undefined),
Show= ts_config:getAttr(string,Element#xmlElement.attributes, show, "chat"),
Status= ts_config:getAttr(string,Element#xmlElement.attributes, status, "Available"),
+ Resource= ts_config:getAttr(string,Element#xmlElement.attributes, resource, "tsung"),
Type= list_to_atom(TypeStr),
Room = ts_config:getAttr(string,Element#xmlElement.attributes, room, undefined),
Nick = ts_config:getAttr(string,Element#xmlElement.attributes, nick, undefined),
@@ -128,6 +129,7 @@ parse_config(Element = #xmlElement{name=jabber},
size = Size,
show = Show,
status = Status,
+ resource = Resource,
room = Room,
nick = Nick,
group = Group,
View
3 tsung-1.0.dtd
@@ -221,7 +221,8 @@ repeat | if | change_type | foreach | set_option)*>
room CDATA #IMPLIED
group CDATA #IMPLIED
node CDATA #IMPLIED
- regexp CDATA #IMPLIED
+ regexp CDATA #IMPLIED
+ resource CDATA "tsung"
node_type CDATA #IMPLIED >
<!ELEMENT xmpp_authenticate EMPTY >

0 comments on commit a0905a1

Please sign in to comment.
Something went wrong with that request. Please try again.