Class: Vines::Stream::Component

Inherits:
Vines::Stream
  • Object
show all
Defined in:
lib/vines/stream/component.rb,
lib/vines/stream/component/ready.rb,
lib/vines/stream/component/start.rb,
lib/vines/stream/component/handshake.rb

Overview

Implements the XMPP protocol for trusted, external component (XEP-0114) streams. This serves connected streams using the jabber:component:accept namespace.

Defined Under Namespace

Classes: Handshake, Ready, Start

Constant Summary

Constants inherited from Vines::Stream

ERROR, PAD

Instance Attribute Summary collapse

Attributes inherited from Vines::Stream

#config, #domain, #user

Instance Method Summary collapse

Methods inherited from Vines::Stream

#advance, #available_resources, #cert_domain_matches?, #close_connection, #connected_resources, #create_parser, #encrypt, #encrypt?, #error, #interested_resources, #post_init, #receive_data, #reset, #router, #ssl_verify_peer, #storage, #unbind, #update_user_streams, #vhost, #write

Methods included from Log

#log

Constructor Details

#initialize(config) ⇒ Component

Returns a new instance of Component.



12
13
14
15
16
17
# File 'lib/vines/stream/component.rb', line 12

def initialize(config)
  super
  @remote_domain = nil
  @stream_id = Kit.uuid
  advance(Start.new(self))
end

Instance Attribute Details

#remote_domainObject (readonly)

Returns the value of attribute remote_domain.



10
11
12
# File 'lib/vines/stream/component.rb', line 10

def remote_domain
  @remote_domain
end

Instance Method Details

#max_stanza_sizeObject



19
20
21
# File 'lib/vines/stream/component.rb', line 19

def max_stanza_size
  config[:component].max_stanza_size
end

#ready?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/vines/stream/component.rb', line 23

def ready?
  state.class == Component::Ready
end

#secretObject



40
41
42
43
# File 'lib/vines/stream/component.rb', line 40

def secret
  password = config.component_password(@remote_domain)
  Digest::SHA1.hexdigest(@stream_id + password)
end

#start(node) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/vines/stream/component.rb', line 31

def start(node)
  @remote_domain = node['to']
  send_stream_header
  raise StreamErrors::ImproperAddressing unless valid_address?(@remote_domain)
  raise StreamErrors::HostUnknown unless config.component?(@remote_domain)
  raise StreamErrors::InvalidNamespace unless node.namespaces['xmlns'] == NAMESPACES[:component]
  raise StreamErrors::InvalidNamespace unless node.namespaces['xmlns:stream'] == NAMESPACES[:stream]
end

#stream_typeObject



27
28
29
# File 'lib/vines/stream/component.rb', line 27

def stream_type
  :component
end