diaspora-vines 0.1.26 → 0.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/conf/config.rb +1 -0
- data/lib/vines.rb +12 -5
- data/lib/vines/config/host.rb +9 -0
- data/lib/vines/kit.rb +7 -0
- data/lib/vines/node.rb +31 -0
- data/lib/vines/router.rb +5 -0
- data/lib/vines/stanza/presence.rb +16 -1
- data/lib/vines/storage.rb +10 -1
- data/lib/vines/storage/sql.rb +18 -5
- data/lib/vines/stream.rb +12 -10
- data/lib/vines/stream/client/bind_restart.rb +6 -0
- data/lib/vines/stream/http.rb +13 -11
- data/lib/vines/stream/server.rb +46 -13
- data/lib/vines/stream/server/auth_method.rb +78 -0
- data/lib/vines/stream/server/auth_restart.rb +27 -1
- data/lib/vines/stream/server/outbound/auth.rb +43 -9
- data/lib/vines/stream/server/outbound/auth_dialback_result.rb +39 -0
- data/lib/vines/stream/server/outbound/auth_external.rb +33 -0
- data/lib/vines/stream/server/outbound/{auth_result.rb → auth_external_result.rb} +1 -1
- data/lib/vines/stream/server/outbound/auth_restart.rb +8 -1
- data/lib/vines/stream/server/outbound/authoritative.rb +48 -0
- data/lib/vines/stream/server/outbound/start.rb +1 -1
- data/lib/vines/stream/server/start.rb +29 -2
- data/lib/vines/stream/state.rb +3 -17
- data/lib/vines/version.rb +1 -1
- data/test/storage/sql_test.rb +16 -0
- data/test/store_test.rb +3 -1
- data/test/stream/server/auth_method_test.rb +101 -0
- data/test/stream/server/outbound/auth_dialback_result_test.rb +37 -0
- data/test/stream/server/outbound/auth_external_test.rb +75 -0
- data/test/stream/server/outbound/auth_restart_test.rb +53 -0
- data/test/stream/server/outbound/auth_test.rb +59 -43
- data/test/stream/server/outbound/authoritative_test.rb +66 -0
- data/test/stream/server/outbound/start_test.rb +33 -0
- data/test/stream/server/start_test.rb +70 -0
- metadata +33 -10
- data/lib/vines/stream/server/outbound/tls.rb +0 -30
- data/lib/vines/stream/server/tls.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87d2b07cbe2ab258cc25dbcea4fb8429feebd806
|
4
|
+
data.tar.gz: 35994b6743c62749b50002ba80ea354dbe5d6116
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33bcb7a97e8af3a83576adea4ef702a80276505ea2970b58b02a52265d8fd2be25158b8dc86b77da6234b78b1f703a084824f0b8830de5db0fc051f78b51c10e
|
7
|
+
data.tar.gz: 42dbc10e518ac5238b399d97c714b169fee8cf72ba61ff58b73c8d4d3e7440d723e54cc95b9b17ca1076a58ecaf0f8c78412e3e16d2ce2490b831c55e5003ad4
|
data/conf/config.rb
CHANGED
data/lib/vines.rb
CHANGED
@@ -14,6 +14,7 @@ module Vines
|
|
14
14
|
:tls => 'urn:ietf:params:xml:ns:xmpp-tls'.freeze,
|
15
15
|
:bind => 'urn:ietf:params:xml:ns:xmpp-bind'.freeze,
|
16
16
|
:session => 'urn:ietf:params:xml:ns:xmpp-session'.freeze,
|
17
|
+
:stanzas => 'urn:ietf:params:xml:ns:xmpp-stanzas'.freeze,
|
17
18
|
:ping => 'urn:xmpp:ping'.freeze,
|
18
19
|
:delay => 'urn:xmpp:delay'.freeze,
|
19
20
|
:pubsub => 'http://jabber.org/protocol/pubsub'.freeze,
|
@@ -30,8 +31,11 @@ module Vines
|
|
30
31
|
:offline => 'msgoffline'.freeze,
|
31
32
|
:bosh => 'urn:xmpp:xbosh'.freeze,
|
32
33
|
:vcard => 'vcard-temp'.freeze,
|
34
|
+
:vcard_update => 'vcard-temp:x:update'.freeze,
|
33
35
|
:si => 'http://jabber.org/protocol/si'.freeze,
|
34
|
-
:byte_streams => 'http://jabber.org/protocol/bytestreams'.freeze
|
36
|
+
:byte_streams => 'http://jabber.org/protocol/bytestreams'.freeze,
|
37
|
+
:dialback => 'urn:xmpp:features:dialback'.freeze,
|
38
|
+
:legacy_dialback => 'jabber:server:dialback'.freeze
|
35
39
|
}.freeze
|
36
40
|
|
37
41
|
module Log
|
@@ -127,6 +131,7 @@ end
|
|
127
131
|
vines/daemon
|
128
132
|
vines/error
|
129
133
|
vines/kit
|
134
|
+
vines/node
|
130
135
|
vines/router
|
131
136
|
vines/token_bucket
|
132
137
|
vines/user
|
@@ -173,18 +178,20 @@ end
|
|
173
178
|
|
174
179
|
vines/stream/server
|
175
180
|
vines/stream/server/start
|
176
|
-
vines/stream/server/
|
181
|
+
vines/stream/server/auth_method
|
177
182
|
vines/stream/server/auth_restart
|
178
183
|
vines/stream/server/auth
|
179
184
|
vines/stream/server/final_restart
|
180
185
|
vines/stream/server/ready
|
181
186
|
|
182
187
|
vines/stream/server/outbound/start
|
183
|
-
vines/stream/server/outbound/
|
188
|
+
vines/stream/server/outbound/auth
|
184
189
|
vines/stream/server/outbound/tls_result
|
190
|
+
vines/stream/server/outbound/authoritative
|
185
191
|
vines/stream/server/outbound/auth_restart
|
186
|
-
vines/stream/server/outbound/
|
187
|
-
vines/stream/server/outbound/
|
192
|
+
vines/stream/server/outbound/auth_external
|
193
|
+
vines/stream/server/outbound/auth_external_result
|
194
|
+
vines/stream/server/outbound/auth_dialback_result
|
188
195
|
vines/stream/server/outbound/final_restart
|
189
196
|
vines/stream/server/outbound/final_features
|
190
197
|
|
data/lib/vines/config/host.rb
CHANGED
@@ -15,6 +15,7 @@ module Vines
|
|
15
15
|
@cross_domain_messages = false
|
16
16
|
@private_storage = false
|
17
17
|
@accept_self_signed = false
|
18
|
+
@force_s2s_encryption = false
|
18
19
|
@components, @pubsubs = {}, {}
|
19
20
|
validate_domain(@name)
|
20
21
|
instance_eval(&block)
|
@@ -30,6 +31,14 @@ module Vines
|
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
34
|
+
def force_s2s_encryption(enabled)
|
35
|
+
@force_s2s_encryption = !!enabled
|
36
|
+
end
|
37
|
+
|
38
|
+
def force_s2s_encryption?
|
39
|
+
@force_s2s_encryption
|
40
|
+
end
|
41
|
+
|
33
42
|
def accept_self_signed(enabled)
|
34
43
|
@accept_self_signed = !!enabled
|
35
44
|
end
|
data/lib/vines/kit.rb
CHANGED
@@ -19,5 +19,12 @@ module Vines
|
|
19
19
|
def self.auth_token
|
20
20
|
SecureRandom.hex(64)
|
21
21
|
end
|
22
|
+
|
23
|
+
# Generate a HMAC for dialback as recommended in XEP-0185
|
24
|
+
def self.dialback_key(key, receiving, originating, id)
|
25
|
+
digest = OpenSSL::Digest.new('sha256')
|
26
|
+
data = "#{receiving} #{originating} #{id}"
|
27
|
+
OpenSSL::HMAC.hexdigest(digest, digest.hexdigest(key), data)
|
28
|
+
end
|
22
29
|
end
|
23
30
|
end
|
data/lib/vines/node.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
module Vines
|
2
|
+
# Utility functions to work with nodes
|
3
|
+
module Node
|
4
|
+
|
5
|
+
STREAM = 'stream'.freeze
|
6
|
+
BODY = 'body'.freeze
|
7
|
+
|
8
|
+
module_function
|
9
|
+
|
10
|
+
# Check if node starts a new stream
|
11
|
+
def stream?(node)
|
12
|
+
node.name == STREAM && namespace(node) == NAMESPACES[:stream]
|
13
|
+
end
|
14
|
+
|
15
|
+
# Check if BOSH body
|
16
|
+
def body?(node)
|
17
|
+
node.name == BODY && namespace(node) == NAMESPACES[:http_bind]
|
18
|
+
end
|
19
|
+
|
20
|
+
# Get the namespace
|
21
|
+
def namespace(node)
|
22
|
+
namespace = node.namespace
|
23
|
+
namespace && namespace.href
|
24
|
+
end
|
25
|
+
|
26
|
+
# Convert to stanza
|
27
|
+
def to_stanza(node, stream)
|
28
|
+
Stanza.from_node(node, stream)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/vines/router.rb
CHANGED
@@ -96,6 +96,11 @@ module Vines
|
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
99
|
+
# Return stream by id
|
100
|
+
def stream_by_id(id)
|
101
|
+
(@servers+@clients.values.flatten+@components).find {|stream| stream.id == id }
|
102
|
+
end
|
103
|
+
|
99
104
|
# Returns the total number of streams connected to the server.
|
100
105
|
def size
|
101
106
|
clients = @clients.values.inject(0) {|sum, arr| sum + arr.size }
|
@@ -18,7 +18,7 @@ module Vines
|
|
18
18
|
unless self['type'].nil?
|
19
19
|
raise StanzaErrors::BadRequest.new(self, 'modify')
|
20
20
|
end
|
21
|
-
if Config.instance.max_offline_msgs > 0
|
21
|
+
if Config.instance.max_offline_msgs > 0 && !validate_to
|
22
22
|
check_offline_messages(stream.last_broadcast_presence)
|
23
23
|
end
|
24
24
|
dir = outbound? ? 'outbound' : 'inbound'
|
@@ -69,6 +69,12 @@ module Vines
|
|
69
69
|
stream.user.subscribed_from?(to) ? stream.available_resources(to) : []
|
70
70
|
end
|
71
71
|
|
72
|
+
# NOTE overriding vCard information is not concurring
|
73
|
+
# with XEP-153 due the fact that the user can only update
|
74
|
+
# his vCard via the Diaspora environment we should act
|
75
|
+
# the same way for the avatar update
|
76
|
+
override_vcard_update
|
77
|
+
|
72
78
|
broadcast(recipients)
|
73
79
|
broadcast(stream.available_resources(stream.user.jid))
|
74
80
|
|
@@ -162,6 +168,15 @@ module Vines
|
|
162
168
|
self['from'] = bare.to_s
|
163
169
|
end
|
164
170
|
end
|
171
|
+
|
172
|
+
def override_vcard_update
|
173
|
+
image_path = storage.find_avatar_by_jid(@node['from'])
|
174
|
+
return if image_path.nil?
|
175
|
+
photo_tag = "<photo><EXTVAL>#{image_path}</EXTVAL></photo>"
|
176
|
+
node = @node.xpath("//xmlns:x", 'xmlns' => NAMESPACES[:vcard_update]).first
|
177
|
+
node.remove unless node.blank?
|
178
|
+
@node << "<x xmlns=\"#{NAMESPACES[:vcard_update]}\">#{photo_tag}</x>"
|
179
|
+
end
|
165
180
|
end
|
166
181
|
end
|
167
182
|
end
|
data/lib/vines/storage.rb
CHANGED
@@ -230,7 +230,7 @@ module Vines
|
|
230
230
|
# message - The message you want to store.
|
231
231
|
#
|
232
232
|
# Returns nothing.
|
233
|
-
def
|
233
|
+
def save_message(from, to, message)
|
234
234
|
raise 'subclass must implement'
|
235
235
|
end
|
236
236
|
|
@@ -243,6 +243,15 @@ module Vines
|
|
243
243
|
raise 'subclass must implement'
|
244
244
|
end
|
245
245
|
|
246
|
+
# Retrieve the avatar url by jid.
|
247
|
+
#
|
248
|
+
# jid - The String or JID of the user.
|
249
|
+
#
|
250
|
+
# Returns string
|
251
|
+
def find_avatar_by_jid(jid)
|
252
|
+
raise 'subclass must implement'
|
253
|
+
end
|
254
|
+
|
246
255
|
private
|
247
256
|
|
248
257
|
# Determine if any of the arguments are nil or empty strings.
|
data/lib/vines/storage/sql.rb
CHANGED
@@ -112,10 +112,13 @@ module Vines
|
|
112
112
|
# add diaspora contacts
|
113
113
|
xuser.contacts.chat_enabled.each do |contact|
|
114
114
|
handle = contact.person.diaspora_handle
|
115
|
+
profile = contact.person.profile
|
116
|
+
name = "#{profile.first_name} #{profile.last_name}"
|
117
|
+
name = handle.gsub(/\@.*?$/, '') if name.strip.empty?
|
115
118
|
ask, subscription, groups = get_diaspora_flags(contact)
|
116
119
|
user.roster << Vines::Contact.new(
|
117
120
|
jid: handle,
|
118
|
-
name:
|
121
|
+
name: name,
|
119
122
|
subscription: subscription,
|
120
123
|
from_diaspora: true,
|
121
124
|
groups: groups,
|
@@ -162,8 +165,7 @@ module Vines
|
|
162
165
|
contact.update_attributes(
|
163
166
|
name: fresh.name,
|
164
167
|
ask: fresh.ask,
|
165
|
-
subscription: fresh.subscription
|
166
|
-
groups: get_external_groups)
|
168
|
+
subscription: fresh.subscription)
|
167
169
|
end
|
168
170
|
|
169
171
|
# add new contacts to roster
|
@@ -177,8 +179,7 @@ module Vines
|
|
177
179
|
jid: contact.jid.bare.to_s,
|
178
180
|
name: contact.name,
|
179
181
|
ask: contact.ask,
|
180
|
-
subscription: contact.subscription
|
181
|
-
groups: get_external_groups) unless jids.include?(contact.jid.bare.to_s)
|
182
|
+
subscription: contact.subscription) unless jids.include?(contact.jid.bare.to_s)
|
182
183
|
end
|
183
184
|
}
|
184
185
|
xuser.save
|
@@ -260,6 +261,18 @@ module Vines
|
|
260
261
|
end
|
261
262
|
with_connection :save_fragment
|
262
263
|
|
264
|
+
def find_avatar_by_jid(jid)
|
265
|
+
jid = JID.new(jid).bare.to_s
|
266
|
+
return nil if jid.empty?
|
267
|
+
|
268
|
+
person = Sql::Person.find_by_diaspora_handle(jid)
|
269
|
+
return nil if person.nil?
|
270
|
+
return nil if person.profile.nil?
|
271
|
+
return nil unless person.local?
|
272
|
+
person.profile.image_url
|
273
|
+
end
|
274
|
+
with_connection :find_avatar_by_jid
|
275
|
+
|
263
276
|
private
|
264
277
|
def establish_connection
|
265
278
|
ActiveRecord::Base.logger = log # using vines logger
|
data/lib/vines/stream.rb
CHANGED
@@ -8,9 +8,10 @@ module Vines
|
|
8
8
|
include Vines::Log
|
9
9
|
|
10
10
|
ERROR = 'error'.freeze
|
11
|
+
STREAM = 'stream'.freeze
|
11
12
|
PAD = 20
|
12
13
|
|
13
|
-
attr_reader :config, :domain
|
14
|
+
attr_reader :config, :domain, :id, :state
|
14
15
|
attr_accessor :user
|
15
16
|
|
16
17
|
def initialize(config)
|
@@ -122,7 +123,7 @@ module Vines
|
|
122
123
|
|
123
124
|
def ssl_verify_peer(pem)
|
124
125
|
# Skip verifying if user accept self-signed certificates
|
125
|
-
return if self.vhost.accept_self_signed?
|
126
|
+
return true if self.vhost.accept_self_signed?
|
126
127
|
# EM is supposed to close the connection when this returns false,
|
127
128
|
# but it only does that for inbound connections, not when we
|
128
129
|
# make a connection to another server.
|
@@ -265,6 +266,7 @@ module Vines
|
|
265
266
|
if error?(node)
|
266
267
|
close_stream
|
267
268
|
else
|
269
|
+
update_stream_id(node)
|
268
270
|
state.node(node)
|
269
271
|
end
|
270
272
|
rescue => e
|
@@ -286,14 +288,6 @@ module Vines
|
|
286
288
|
["#{label} stanza:".ljust(PAD), from, to, node])
|
287
289
|
end
|
288
290
|
|
289
|
-
# Inspects the current state of the stream's state machine. Provided as a
|
290
|
-
# method so subclasses can override the behavior.
|
291
|
-
#
|
292
|
-
# Returns the current Stream::State.
|
293
|
-
def state
|
294
|
-
@state
|
295
|
-
end
|
296
|
-
|
297
291
|
# Determine if this is a valid domain-only JID that can be used in
|
298
292
|
# stream initiation stanza headers.
|
299
293
|
#
|
@@ -303,5 +297,13 @@ module Vines
|
|
303
297
|
def valid_address?(jid)
|
304
298
|
JID.new(jid).domain? rescue false
|
305
299
|
end
|
300
|
+
|
301
|
+
def update_stream_id(id_or_node)
|
302
|
+
if id_or_node.is_a? String
|
303
|
+
@id = id_or_node.freeze
|
304
|
+
elsif Node.stream?(id_or_node) # move stream? method somewhere else?
|
305
|
+
@id = id_or_node['id'].freeze
|
306
|
+
end
|
307
|
+
end
|
306
308
|
end
|
307
309
|
end
|
@@ -13,6 +13,12 @@ module Vines
|
|
13
13
|
stream.start(node)
|
14
14
|
doc = Document.new
|
15
15
|
features = doc.create_element('stream:features') do |el|
|
16
|
+
# Session support is deprecated, but like we do it for Adium
|
17
|
+
# in the iq-session-stanza we have to serve the feature for Xabber.
|
18
|
+
# Otherwise it will disconnect after authentication!
|
19
|
+
el << doc.create_element('session', 'xmlns' => NAMESPACES[:session]) do |session|
|
20
|
+
session << doc.create_element('optional')
|
21
|
+
end
|
16
22
|
el << doc.create_element('bind', 'xmlns' => NAMESPACES[:bind])
|
17
23
|
end
|
18
24
|
stream.write(features)
|
data/lib/vines/stream/http.rb
CHANGED
@@ -46,19 +46,21 @@ module Vines
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def process_request(request)
|
49
|
-
if request.
|
50
|
-
request.
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
49
|
+
if request.method == 'POST'
|
50
|
+
if request.path == self.bind && request.options?
|
51
|
+
request.reply_to_options
|
52
|
+
elsif request.path == self.bind
|
53
|
+
body = Nokogiri::XML(request.body).root
|
54
|
+
if session = Sessions[body['sid']]
|
55
|
+
@session = session
|
56
|
+
else
|
57
|
+
@session = Http::Session.new(self)
|
58
|
+
end
|
59
|
+
@session.request(request)
|
60
|
+
@nodes.push(body)
|
57
61
|
end
|
58
|
-
@session.request(request)
|
59
|
-
@nodes.push(body)
|
60
62
|
else
|
61
|
-
request.
|
63
|
+
request.reply('It works!', 'text/plain')
|
62
64
|
end
|
63
65
|
end
|
64
66
|
|
data/lib/vines/stream/server.rb
CHANGED
@@ -15,7 +15,7 @@ module Vines
|
|
15
15
|
# yielded stream will be nil if the remote connection failed. We need to
|
16
16
|
# use a background thread to avoid blocking the server on DNS SRV
|
17
17
|
# lookups.
|
18
|
-
def self.start(config, to, from, &callback)
|
18
|
+
def self.start(config, to, from, dialback_verify_key = false, &callback)
|
19
19
|
op = proc do
|
20
20
|
Resolv::DNS.open do |dns|
|
21
21
|
dns.getresources("_xmpp-server._tcp.#{to}", Resolv::DNS::Resource::IN::SRV)
|
@@ -28,22 +28,22 @@ module Vines
|
|
28
28
|
def method_missing(name); self[name]; end
|
29
29
|
end
|
30
30
|
end
|
31
|
-
Server.connect(config, to, from, srv, callback)
|
31
|
+
Server.connect(config, to, from, srv, dialback_verify_key, callback)
|
32
32
|
end
|
33
33
|
EM.defer(proc { op.call rescue [] }, cb)
|
34
34
|
end
|
35
35
|
|
36
|
-
def self.connect(config, to, from, srv, callback)
|
36
|
+
def self.connect(config, to, from, srv, dialback_verify_key = false, callback)
|
37
37
|
if srv.empty?
|
38
38
|
# fiber so storage calls work properly
|
39
39
|
Fiber.new { callback.call(nil) }.resume
|
40
40
|
else
|
41
41
|
begin
|
42
42
|
rr = srv.shift
|
43
|
-
opts = {to: to, from: from, srv: srv, callback: callback}
|
43
|
+
opts = {to: to, from: from, srv: srv, dialback_verify_key: dialback_verify_key, callback: callback}
|
44
44
|
EM.connect(rr.target.to_s, rr.port, Server, config, opts)
|
45
45
|
rescue => e
|
46
|
-
connect(config, to, from, srv, callback)
|
46
|
+
connect(config, to, from, srv, dialback_verify_key, callback)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -53,10 +53,13 @@ module Vines
|
|
53
53
|
|
54
54
|
def initialize(config, options={})
|
55
55
|
super(config)
|
56
|
+
@outbound_tls_required = false
|
57
|
+
@peer_trusted = nil
|
56
58
|
@connected = false
|
57
59
|
@remote_domain = options[:to]
|
58
60
|
@domain = options[:from]
|
59
61
|
@srv = options[:srv]
|
62
|
+
@dialback_verify_key = options[:dialback_verify_key]
|
60
63
|
@callback = options[:callback]
|
61
64
|
@outbound = @remote_domain && @domain
|
62
65
|
start = @outbound ? Outbound::Start.new(self) : Start.new(self)
|
@@ -72,8 +75,30 @@ module Vines
|
|
72
75
|
config[:server].max_stanza_size
|
73
76
|
end
|
74
77
|
|
78
|
+
def ssl_verify_peer(pem)
|
79
|
+
@peer_trusted = @store.trusted?(pem)
|
80
|
+
true
|
81
|
+
end
|
82
|
+
|
83
|
+
def peer_trusted?
|
84
|
+
!@peer_trusted.nil? && @peer_trusted
|
85
|
+
end
|
86
|
+
|
87
|
+
def dialback_retry?
|
88
|
+
return false if @peer_trusted.nil? || @peer_trusted
|
89
|
+
true
|
90
|
+
end
|
91
|
+
|
75
92
|
def ssl_handshake_completed
|
76
|
-
|
93
|
+
@peer_trusted = cert_domain_matches?(@remote_domain) && peer_trusted?
|
94
|
+
end
|
95
|
+
|
96
|
+
def outbound_tls_required?
|
97
|
+
@outbound_tls_required
|
98
|
+
end
|
99
|
+
|
100
|
+
def outbound_tls_required(required)
|
101
|
+
@outbound_tls_required = required
|
77
102
|
end
|
78
103
|
|
79
104
|
# Return an array of allowed authentication mechanisms advertised as
|
@@ -99,10 +124,16 @@ module Vines
|
|
99
124
|
|
100
125
|
def notify_connected
|
101
126
|
@connected = true
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
127
|
+
self.callback!
|
128
|
+
@callback = nil
|
129
|
+
end
|
130
|
+
|
131
|
+
def callback!
|
132
|
+
@callback.call(self) if @callback
|
133
|
+
end
|
134
|
+
|
135
|
+
def dialback_verify_key?
|
136
|
+
@dialback_verify_key
|
106
137
|
end
|
107
138
|
|
108
139
|
def ready?
|
@@ -115,7 +146,6 @@ module Vines
|
|
115
146
|
@domain, @remote_domain = to, from unless @domain
|
116
147
|
send_stream_header
|
117
148
|
raise StreamErrors::NotAuthorized if domain_change?(to, from)
|
118
|
-
raise StreamErrors::UnsupportedVersion unless node['version'] == '1.0'
|
119
149
|
raise StreamErrors::ImproperAddressing unless valid_address?(@domain) && valid_address?(@remote_domain)
|
120
150
|
raise StreamErrors::HostUnknown unless config.vhost?(@domain) || config.pubsub?(@domain) || config.component?(@domain)
|
121
151
|
raise StreamErrors::NotAuthorized unless config.s2s?(@remote_domain) && config.allowed?(@domain, @remote_domain)
|
@@ -140,14 +170,17 @@ module Vines
|
|
140
170
|
end
|
141
171
|
|
142
172
|
def send_stream_header
|
173
|
+
stream_id = Kit.uuid
|
174
|
+
update_stream_id(stream_id)
|
143
175
|
attrs = {
|
144
176
|
'xmlns' => NAMESPACES[:server],
|
145
177
|
'xmlns:stream' => NAMESPACES[:stream],
|
178
|
+
'xmlns:db' => NAMESPACES[:legacy_dialback],
|
146
179
|
'xml:lang' => 'en',
|
147
|
-
'id' =>
|
180
|
+
'id' => stream_id,
|
181
|
+
'version' => '1.0',
|
148
182
|
'from' => @domain,
|
149
183
|
'to' => @remote_domain,
|
150
|
-
'version' => '1.0'
|
151
184
|
}
|
152
185
|
write "<stream:stream %s>" % attrs.to_a.map{|k,v| "#{k}='#{v}'"}.join(' ')
|
153
186
|
end
|