Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add option to use legacy stream (no version send) (TSUN-230)

  • Loading branch information...
commit 12cdf334857c751c51cad60c31d7fa5898e13983 1 parent 2dbe72e
Nicolas Niclausse nniclausse authored
3  include/ts_jabber.hrl
@@ -51,7 +51,8 @@
51 51 node, %% pubsub node
52 52 resource,
53 53 node_type,
54   - subid
  54 + subid,
  55 + version %% 1.0 or "legacy", used by type=connect
55 56 }).
56 57
57 58 -define(setroster_intensity, 1/(ts_utils:get_val(setroster)*1000)).
21 src/test/ts_test_jabber.erl
@@ -124,6 +124,25 @@ pubsub_unsubscribe_test()->
124 124 {Rep,_}=ts_jabber:get_message(Req,#state_rcv{}),
125 125 ?assertEqual(RepOK,Rep ).
126 126
  127 +connect_legacy_test()->
  128 + erase(xmpp_user_id),
  129 + ts_msg_server:start(),
  130 + ts_user_server:reset(1),
  131 + Session = #jabber{id=0,username="foo",type='connect',passwd="bar",domain={domain,"localdomain"},resource="tsung", version="legacy"},
  132 + Req=ts_jabber:add_dynparams(false,[],Session,"localhost"),
  133 + RepOK= <<"<?xml version='1.0'?><stream:stream id='4' to='localdomain' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams'>" >>,
  134 + {Rep,_} = ts_jabber:get_message(Req,#state_rcv{}),
  135 + ?assertEqual(RepOK,Rep).
  136 +
  137 +connect_xmpp_test()->
  138 + erase(xmpp_user_id),
  139 + ts_msg_server:start(),
  140 + ts_user_server:reset(1),
  141 + Session = #jabber{id=0,username="foo",type='connect',passwd="bar",domain={domain,"localdomain"},resource="tsung", version="1.0"},
  142 + Req=ts_jabber:add_dynparams(false,[],Session,"localhost"),
  143 + RepOK= <<"<?xml version='1.0'?><stream:stream id='5' to='localdomain' xmlns='jabber:client' version='1.0' xmlns:stream='http://etherx.jabber.org/streams'>" >>,
  144 + {Rep,_} = ts_jabber:get_message(Req,#state_rcv{}),
  145 + ?assertEqual(RepOK,Rep).
127 146
128 147 choose_id_limit_test()->
129 148 ts_user_server:reset(3),
@@ -136,8 +155,6 @@ choose_id_limit_test()->
136 155 erase(xmpp_user_id),
137 156 ?assertExit(no_free_userid, ts_jabber:choose_or_cache_user_id(0,"user","pwd")).
138 157
139   -
140   -
141 158 myset_env()->
142 159 myset_env(0).
143 160 myset_env(Val)->
10 src/tsung/ts_jabber_common.erl
@@ -277,13 +277,19 @@ get_message2(Jabber=#jabber{type = 'auth_sasl_session'}) ->
277 277 %%----------------------------------------------------------------------
278 278 %% Func: connect/1
279 279 %%----------------------------------------------------------------------
280   -connect(#jabber{domain=Domain}) ->
  280 +connect(#jabber{domain=Domain, version = Version}) ->
  281 + VersionStr = case Version of
  282 + "legacy" ->
  283 + "";
  284 + V when is_list(V) ->
  285 + "version='" ++ Version ++"' "
  286 + end,
281 287 list_to_binary([
282 288 "<?xml version='1.0'?><stream:stream id='",
283 289 ts_msg_server:get_id(list),
284 290 "' to='",
285 291 Domain,
286   - "' xmlns='jabber:client' version='1.0' xmlns:stream='http://etherx.jabber.org/streams'>"]).
  292 + "' xmlns='jabber:client' ",VersionStr,"xmlns:stream='http://etherx.jabber.org/streams'>"]).
287 293
288 294 %%----------------------------------------------------------------------
289 295 %% Func: close/0
4 src/tsung_controller/ts_config_jabber.erl
@@ -60,6 +60,7 @@ parse_config(Element = #xmlElement{name=jabber},
60 60 Status= ts_config:getAttr(string,Element#xmlElement.attributes, status, "Available"),
61 61 Resource= ts_config:getAttr(string,Element#xmlElement.attributes, resource, "tsung"),
62 62 Type= list_to_atom(TypeStr),
  63 + Version = ts_config:getAttr(string,Element#xmlElement.attributes, version, "1.0"),
63 64 Room = ts_config:getAttr(string,Element#xmlElement.attributes, room, undefined),
64 65 Nick = ts_config:getAttr(string,Element#xmlElement.attributes, nick, undefined),
65 66 Group = ts_config:getAttr(string,Element#xmlElement.attributes, group, "Tsung Group"),
@@ -138,7 +139,8 @@ parse_config(Element = #xmlElement{name=jabber},
138 139 pubsub_service = PubSub_service,
139 140 node = Node,
140 141 node_type = NodeType,
141   - subid = SubId
  142 + subid = SubId,
  143 + version = Version
142 144 }
143 145 },
144 146 ts_config:mark_prev_req(Id-1, Tab, CurS),
1  tsung-1.0.dtd
@@ -224,6 +224,7 @@ repeat | if | change_type | foreach | set_option)*>
224 224 regexp CDATA #IMPLIED
225 225 resource CDATA "tsung"
226 226 node_type CDATA #IMPLIED
  227 + version CDATA #IMPLIED
227 228 subid CDATA #IMPLIED >
228 229
229 230 <!ELEMENT xmpp_authenticate EMPTY >

0 comments on commit 12cdf33

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